Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9f3a8d350 | ||
|
|
615394a479 | ||
|
|
795488d01e |
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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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")]
|
||||||
|
|||||||
Reference in New Issue
Block a user