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
|
||||
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);
|
||||
if (res)
|
||||
{
|
||||
@@ -124,6 +140,8 @@ namespace Gidrolock_Modbus_Scanner
|
||||
Console.WriteLine("Polling for alarm status, poll success: " + 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)
|
||||
{
|
||||
alarmStatus = true;
|
||||
@@ -146,42 +164,14 @@ namespace Gidrolock_Modbus_Scanner
|
||||
if (latestMessage.Data.Last() > 0)
|
||||
{
|
||||
cleaningStatus = true;
|
||||
buttonAlarm.Text = "Выключить";
|
||||
labelAlarm.Text = "вкл";
|
||||
buttonCleaning.Text = "Выключить";
|
||||
labelCleaning.Text = "вкл";
|
||||
}
|
||||
else
|
||||
{
|
||||
cleaningStatus = false;
|
||||
buttonAlarm.Text = "Включить";
|
||||
labelAlarm.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 = "выкл";
|
||||
buttonCleaning.Text = "Включить";
|
||||
labelCleaning.Text = "выкл";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -239,7 +229,7 @@ namespace Gidrolock_Modbus_Scanner
|
||||
bool res = false;
|
||||
Modbus.ReadRegAsync(modbusID, (FunctionCode)entry.registerType, entry.address, entry.length);
|
||||
isAwaitingResponse = true;
|
||||
await Task.Delay(2000).ContinueWith(_ =>
|
||||
Task.Delay(2000).ContinueWith(_ =>
|
||||
{
|
||||
if (isAwaitingResponse)
|
||||
{
|
||||
@@ -280,7 +270,7 @@ namespace Gidrolock_Modbus_Scanner
|
||||
ushort value = isValveClosed ? (ushort)0: (ushort)0xFF00;
|
||||
Modbus.WriteSingleAsync(FunctionCode.WriteCoil, modbusID, device.valveStatus.address, value);
|
||||
|
||||
await Task.Delay(2000).ContinueWith(_ =>
|
||||
Task.Delay(2000).ContinueWith(_ =>
|
||||
{
|
||||
if (isAwaitingResponse)
|
||||
{
|
||||
@@ -304,7 +294,7 @@ namespace Gidrolock_Modbus_Scanner
|
||||
ushort value = alarmStatus ? (ushort)0 : (ushort)0xFF00;
|
||||
Modbus.WriteSingleAsync(FunctionCode.WriteCoil, modbusID, device.alarmStatus.address, value);
|
||||
|
||||
await Task.Delay(2000).ContinueWith(_ =>
|
||||
Task.Delay(2000).ContinueWith(_ =>
|
||||
{
|
||||
if (isAwaitingResponse)
|
||||
{
|
||||
@@ -328,7 +318,7 @@ namespace Gidrolock_Modbus_Scanner
|
||||
ushort value = cleaningStatus ? (ushort)0 : (ushort)0xFF00;
|
||||
Modbus.WriteSingleAsync(FunctionCode.WriteCoil, modbusID, device.cleaningMode.address, value);
|
||||
|
||||
await Task.Delay(2000).ContinueWith(_ =>
|
||||
Task.Delay(2000).ContinueWith(_ =>
|
||||
{
|
||||
if (isAwaitingResponse)
|
||||
{
|
||||
@@ -359,7 +349,7 @@ namespace Gidrolock_Modbus_Scanner
|
||||
// send speed value to device
|
||||
// await for response
|
||||
Modbus.WriteSingleAsync(FunctionCode.WriteRegister, modbusID, device.baudRate.address, newSpeed);
|
||||
await Task.Delay(2000).ContinueWith(_ =>
|
||||
Task.Delay(2000).ContinueWith(_ =>
|
||||
{
|
||||
if (isAwaitingResponse)
|
||||
{
|
||||
|
||||
29
Main.cs
29
Main.cs
@@ -45,7 +45,8 @@ namespace Gidrolock_Modbus_Scanner
|
||||
upDownModbusID.Minimum = 1;
|
||||
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("Inteli", "INTELI");
|
||||
models.Add("Premium", "BUP485");
|
||||
@@ -287,7 +288,7 @@ namespace Gidrolock_Modbus_Scanner
|
||||
Device d = new Device();
|
||||
switch (dt)
|
||||
{
|
||||
case DeviceType.Standard:
|
||||
case DeviceType.StandardWifi:
|
||||
d.name = "Standard Wi-Fi RS485";
|
||||
d.id = 30;
|
||||
d.modelName = "STW485";
|
||||
@@ -308,6 +309,28 @@ namespace Gidrolock_Modbus_Scanner
|
||||
|
||||
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;
|
||||
case DeviceType.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 DeviceType { Standard, PremiumPlus, Inteli, Premium };
|
||||
public enum DeviceType { StandardWifi, StandardRadio, PremiumPlus, Inteli, Premium };
|
||||
|
||||
@@ -30,6 +30,6 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.9.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.9.0.0")]
|
||||
[assembly: AssemblyVersion("0.9.2.0")]
|
||||
[assembly: AssemblyFileVersion("0.9.1.0")]
|
||||
[assembly: NeutralResourcesLanguage("en")]
|
||||
|
||||
Reference in New Issue
Block a user