Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9f3a8d350 | ||
|
|
615394a479 | ||
|
|
795488d01e | ||
|
|
88b833899d |
66
Datasheet.cs
66
Datasheet.cs
@@ -102,7 +102,23 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
// hardcoded for now, probably easier to keep it like this in the future
|
// hardcoded for now, probably easier to keep it like this in the future
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool res = await PollEntry(device.valveStatus); // for some reason main thread doesn't go
|
bool res = await PollEntry(device.firmware);
|
||||||
|
Console.WriteLine("Polling for alarm status, poll success: " + res);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
labelFirmware.Text = App.ByteArrayToUnicode(latestMessage.Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device.hasBattery)
|
||||||
|
{
|
||||||
|
res = await PollEntry(device.batteryCharge);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
labelBattery.Text = latestMessage.Data.Last().ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res = await PollEntry(device.valveStatus);
|
||||||
Console.WriteLine("Polling for valve status, poll success: " + res);
|
Console.WriteLine("Polling for valve status, poll success: " + res);
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
@@ -124,6 +140,8 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
Console.WriteLine("Polling for alarm status, poll success: " + res);
|
Console.WriteLine("Polling for alarm status, poll success: " + res);
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("Alarm data: " + Modbus.ByteArrayToString(latestMessage.Data));
|
||||||
|
Console.WriteLine("Alarm data.last: " + latestMessage.Data.Last().ToString());
|
||||||
if (latestMessage.Data.Last() > 0)
|
if (latestMessage.Data.Last() > 0)
|
||||||
{
|
{
|
||||||
alarmStatus = true;
|
alarmStatus = true;
|
||||||
@@ -146,42 +164,14 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
if (latestMessage.Data.Last() > 0)
|
if (latestMessage.Data.Last() > 0)
|
||||||
{
|
{
|
||||||
cleaningStatus = true;
|
cleaningStatus = true;
|
||||||
buttonAlarm.Text = "Выключить";
|
buttonCleaning.Text = "Выключить";
|
||||||
labelAlarm.Text = "вкл";
|
labelCleaning.Text = "вкл";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cleaningStatus = false;
|
cleaningStatus = false;
|
||||||
buttonAlarm.Text = "Включить";
|
buttonCleaning.Text = "Включить";
|
||||||
labelAlarm.Text = "выкл";
|
labelCleaning.Text = "выкл";
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (device.hasBattery)
|
|
||||||
{
|
|
||||||
res = await PollEntry(device.batteryCharge);
|
|
||||||
if (res)
|
|
||||||
{
|
|
||||||
labelBattery.Text = latestMessage.Data.Last().ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (device.hasCleaningMode)
|
|
||||||
{
|
|
||||||
res = await PollEntry(device.cleaningMode);
|
|
||||||
if (res)
|
|
||||||
{
|
|
||||||
if (latestMessage.Data.Last() > 0)
|
|
||||||
{
|
|
||||||
cleaningStatus = true;
|
|
||||||
buttonAlarm.Text = "Выключить";
|
|
||||||
labelAlarm.Text = "вкл";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cleaningStatus = false;
|
|
||||||
buttonAlarm.Text = "Включить";
|
|
||||||
labelAlarm.Text = "выкл";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,7 +229,7 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
bool res = false;
|
bool res = false;
|
||||||
Modbus.ReadRegAsync(modbusID, (FunctionCode)entry.registerType, entry.address, entry.length);
|
Modbus.ReadRegAsync(modbusID, (FunctionCode)entry.registerType, entry.address, entry.length);
|
||||||
isAwaitingResponse = true;
|
isAwaitingResponse = true;
|
||||||
await Task.Delay(2000).ContinueWith(_ =>
|
Task.Delay(2000).ContinueWith(_ =>
|
||||||
{
|
{
|
||||||
if (isAwaitingResponse)
|
if (isAwaitingResponse)
|
||||||
{
|
{
|
||||||
@@ -280,7 +270,7 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
ushort value = isValveClosed ? (ushort)0: (ushort)0xFF00;
|
ushort value = isValveClosed ? (ushort)0: (ushort)0xFF00;
|
||||||
Modbus.WriteSingleAsync(FunctionCode.WriteCoil, modbusID, device.valveStatus.address, value);
|
Modbus.WriteSingleAsync(FunctionCode.WriteCoil, modbusID, device.valveStatus.address, value);
|
||||||
|
|
||||||
await Task.Delay(2000).ContinueWith(_ =>
|
Task.Delay(2000).ContinueWith(_ =>
|
||||||
{
|
{
|
||||||
if (isAwaitingResponse)
|
if (isAwaitingResponse)
|
||||||
{
|
{
|
||||||
@@ -304,7 +294,7 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
ushort value = alarmStatus ? (ushort)0 : (ushort)0xFF00;
|
ushort value = alarmStatus ? (ushort)0 : (ushort)0xFF00;
|
||||||
Modbus.WriteSingleAsync(FunctionCode.WriteCoil, modbusID, device.alarmStatus.address, value);
|
Modbus.WriteSingleAsync(FunctionCode.WriteCoil, modbusID, device.alarmStatus.address, value);
|
||||||
|
|
||||||
await Task.Delay(2000).ContinueWith(_ =>
|
Task.Delay(2000).ContinueWith(_ =>
|
||||||
{
|
{
|
||||||
if (isAwaitingResponse)
|
if (isAwaitingResponse)
|
||||||
{
|
{
|
||||||
@@ -328,7 +318,7 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
ushort value = cleaningStatus ? (ushort)0 : (ushort)0xFF00;
|
ushort value = cleaningStatus ? (ushort)0 : (ushort)0xFF00;
|
||||||
Modbus.WriteSingleAsync(FunctionCode.WriteCoil, modbusID, device.cleaningMode.address, value);
|
Modbus.WriteSingleAsync(FunctionCode.WriteCoil, modbusID, device.cleaningMode.address, value);
|
||||||
|
|
||||||
await Task.Delay(2000).ContinueWith(_ =>
|
Task.Delay(2000).ContinueWith(_ =>
|
||||||
{
|
{
|
||||||
if (isAwaitingResponse)
|
if (isAwaitingResponse)
|
||||||
{
|
{
|
||||||
@@ -359,7 +349,7 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
// send speed value to device
|
// send speed value to device
|
||||||
// await for response
|
// await for response
|
||||||
Modbus.WriteSingleAsync(FunctionCode.WriteRegister, modbusID, device.baudRate.address, newSpeed);
|
Modbus.WriteSingleAsync(FunctionCode.WriteRegister, modbusID, device.baudRate.address, newSpeed);
|
||||||
await Task.Delay(2000).ContinueWith(_ =>
|
Task.Delay(2000).ContinueWith(_ =>
|
||||||
{
|
{
|
||||||
if (isAwaitingResponse)
|
if (isAwaitingResponse)
|
||||||
{
|
{
|
||||||
|
|||||||
29
Main.cs
29
Main.cs
@@ -45,7 +45,8 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
upDownModbusID.Minimum = 1;
|
upDownModbusID.Minimum = 1;
|
||||||
upDownModbusID.Maximum = 247;
|
upDownModbusID.Maximum = 247;
|
||||||
|
|
||||||
models.Add("Standard", "STW485");
|
models.Add("Standard Wi-Fi", "STW485");
|
||||||
|
models.Add("Standard Radio", "STR485");
|
||||||
models.Add("Premium Plus", "PRPLS1");
|
models.Add("Premium Plus", "PRPLS1");
|
||||||
models.Add("Inteli", "INTELI");
|
models.Add("Inteli", "INTELI");
|
||||||
models.Add("Premium", "BUP485");
|
models.Add("Premium", "BUP485");
|
||||||
@@ -287,7 +288,7 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
Device d = new Device();
|
Device d = new Device();
|
||||||
switch (dt)
|
switch (dt)
|
||||||
{
|
{
|
||||||
case DeviceType.Standard:
|
case DeviceType.StandardWifi:
|
||||||
d.name = "Standard Wi-Fi RS485";
|
d.name = "Standard Wi-Fi RS485";
|
||||||
d.id = 30;
|
d.id = 30;
|
||||||
d.modelName = "STW485";
|
d.modelName = "STW485";
|
||||||
@@ -308,6 +309,28 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
|
|
||||||
d.radioStatus = new Entry(RegisterType.Input, 1215, 21);
|
d.radioStatus = new Entry(RegisterType.Input, 1215, 21);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case DeviceType.StandardRadio:
|
||||||
|
d.name = "Standard Radio RS485";
|
||||||
|
d.id = 30;
|
||||||
|
d.modelName = "STR485";
|
||||||
|
d.firmware = new Entry(RegisterType.Input, 250, 6);
|
||||||
|
d.baudRate = new Entry(RegisterType.Holding, 110);
|
||||||
|
|
||||||
|
d.valveStatus = new Entry(RegisterType.Coil, 1202);
|
||||||
|
d.alarmStatus = new Entry(RegisterType.Coil, 1201);
|
||||||
|
|
||||||
|
d.hasCleaningMode = true;
|
||||||
|
d.cleaningMode = new Entry(RegisterType.Coil, 3);
|
||||||
|
|
||||||
|
d.hasBattery = false;
|
||||||
|
|
||||||
|
d.wiredSensors = 2;
|
||||||
|
d.hasScenarioSensor = false;
|
||||||
|
d.sensorAlarm = new Entry(RegisterType.Discrete, 1343, 23);
|
||||||
|
|
||||||
|
d.radioStatus = new Entry(RegisterType.Input, 1215, 21);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DeviceType.Inteli:
|
case DeviceType.Inteli:
|
||||||
d.modelName = "Inteli";
|
d.modelName = "Inteli";
|
||||||
@@ -355,4 +378,4 @@ public enum FunctionCode { ReadCoil = 1, ReadDiscrete = 2, ReadHolding = 3, Read
|
|||||||
//public enum SelectedPath { File, Folder };
|
//public enum SelectedPath { File, Folder };
|
||||||
|
|
||||||
|
|
||||||
public enum DeviceType { Standard, PremiumPlus, Inteli, Premium };
|
public enum DeviceType { StandardWifi, StandardRadio, PremiumPlus, Inteli, Premium };
|
||||||
|
|||||||
@@ -30,6 +30,6 @@ using System.Runtime.InteropServices;
|
|||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("0.9.0.0")]
|
[assembly: AssemblyVersion("0.9.2.0")]
|
||||||
[assembly: AssemblyFileVersion("0.9.0.0")]
|
[assembly: AssemblyFileVersion("0.9.1.0")]
|
||||||
[assembly: NeutralResourcesLanguage("en")]
|
[assembly: NeutralResourcesLanguage("en")]
|
||||||
|
|||||||
@@ -6,5 +6,6 @@
|
|||||||
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
||||||
- Standard Wi-Fi RS485
|
- Standard Wi-Fi RS485
|
||||||
|
- Standard Radio RS485
|
||||||
- Premium Plus
|
- Premium Plus
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user