Files
gidrolock-configurator/Datasheet.cs

689 lines
28 KiB
C#
Raw Permalink Normal View History

2025-01-24 11:50:32 +03:00
using System;
2025-01-24 11:46:36 +03:00
using System.Collections;
2024-12-05 15:57:07 +03:00
using System.Collections.Generic;
using System.Diagnostics;
2024-12-05 15:57:07 +03:00
using System.Drawing;
2025-02-28 18:00:17 +03:00
using System.IO;
using System.IO.Ports;
2024-12-05 15:57:07 +03:00
using System.Linq;
using System.Security.Cryptography;
2025-02-28 18:00:17 +03:00
using System.Threading;
2024-12-05 15:57:07 +03:00
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Gidrolock_Modbus_Scanner
{
public partial class Datasheet : Form
{
2025-01-14 11:31:23 +03:00
byte modbusID;
Device device;
2025-04-09 15:26:50 +03:00
public static ModbusResponseEventArgs latestMessage;
2025-01-21 14:38:59 +03:00
2025-01-14 11:31:23 +03:00
SerialPort port = Modbus.port;
2024-12-16 11:35:20 +03:00
bool isPolling = false;
static bool isAwaitingResponse = false;
static bool responseReceived = false;
2025-01-21 14:38:59 +03:00
bool isValveClosed = false;
2025-01-21 14:38:59 +03:00
bool alarmStatus = false;
bool cleaningStatus = false;
2024-12-09 16:24:02 +03:00
2025-01-24 11:46:36 +03:00
List<WiredSensor> wiredSensors = new List<WiredSensor>();
List<WirelessSensor> wirelessSensors;
2025-02-28 18:00:17 +03:00
public static string firmwarePath;
2025-01-24 11:46:36 +03:00
Stopwatch stopwatch = new Stopwatch();
2025-02-28 18:00:17 +03:00
Thread fileThread = new Thread((ThreadStart)delegate
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = Application.StartupPath;
ofd.RestoreDirectory = true;
if (ofd.ShowDialog() == DialogResult.OK)
firmwarePath = ofd.FileName;
});
public Datasheet(byte modbusID, Device device) : base()
2024-12-05 15:57:07 +03:00
{
2025-01-24 11:46:36 +03:00
InitializeComponent();
firmwareProgressBar.Minimum = 0;
firmwareProgressBar.Maximum = 100;
2025-01-14 11:31:23 +03:00
nudModbusID.Minimum = 1;
nudModbusID.Maximum = 246;
2025-01-24 11:46:36 +03:00
nudModbusID.Value = modbusID;
2025-01-14 11:31:23 +03:00
this.modbusID = modbusID;
this.device = device;
2025-01-21 14:38:59 +03:00
2025-01-24 17:54:04 +03:00
cBoxSpeed.Items.Add("1200");
cBoxSpeed.Items.Add("2400");
cBoxSpeed.Items.Add("4800");
cBoxSpeed.Items.Add("9600");
cBoxSpeed.Items.Add("14400");
cBoxSpeed.Items.Add("19200");
cBoxSpeed.Items.Add("38400");
cBoxSpeed.Items.Add("57600");
cBoxSpeed.Items.Add("115200");
cBoxSpeed.Text = port.BaudRate.ToString();
2025-01-24 11:46:36 +03:00
labelModel.Text = device.name;
labelFirmware.Text = "v???";
2025-01-21 14:38:59 +03:00
if (!device.hasCleaningMode)
{
labelCleaning.Text = "Недоступна.";
buttonCleaning.Enabled = false;
}
2025-01-24 11:46:36 +03:00
if (!device.hasBattery)
labelBattery.Text = "Нет";
else labelBattery.Text = "???%";
Modbus.ResponseReceived += (sndr, msg) => { responseReceived = true; latestMessage = msg; isAwaitingResponse = false; };
2025-01-21 14:38:59 +03:00
2025-01-24 11:46:36 +03:00
for (int i = 0; i < device.wiredSensors; i++)
{
WiredSensor ws = new WiredSensor(i) { Width = 495, Height = 24 };
sensorPanel.Controls.Add(ws);
ws.Visible = true;
2025-02-28 18:00:17 +03:00
2025-01-24 11:46:36 +03:00
}
if (device.hasScenarioSensor)
{
ScenarioSensor scenSen = new ScenarioSensor() { Width = 495, Height = 24 };
sensorPanel.Controls.Add(scenSen);
scenSen.Visible = true;
}
2025-01-24 17:54:04 +03:00
if (device.wiredSensors < device.sensorAlarm.length)
2025-01-21 14:38:59 +03:00
{
2025-01-24 11:46:36 +03:00
wirelessSensors = new List<WirelessSensor>();
2025-01-24 17:54:04 +03:00
int wsrIndex = device.sensorAlarm.length - device.wiredSensors - (device.hasScenarioSensor ? 1 : 0);
2025-01-24 11:46:36 +03:00
for (int i = 0; i < wsrIndex; i++)
{
WirelessSensor wsr = new WirelessSensor(i) { Width = 495, Height = 24 };
sensorPanel.Controls.Add(wsr);
wsr.Visible = true;
}
}
for (int i = 0; i < sensorPanel.Controls.Count; i++)
sensorPanel.Controls[i].BackColor = i % 2 == 0 ? Color.White : Color.LightGray;
2025-01-21 14:38:59 +03:00
2025-01-24 11:46:36 +03:00
sensorPanel.Update();
2025-01-21 14:38:59 +03:00
}
private async void buttonPoll_Click(object sender, EventArgs e)
{
2025-04-09 15:26:50 +03:00
if (isPolling)
return;
2025-01-21 14:38:59 +03:00
// hardcoded for now, probably easier to keep it like this in the future
2025-01-24 11:46:36 +03:00
try
2025-01-21 14:38:59 +03:00
{
2025-04-09 15:26:50 +03:00
await Task.Run(() =>
{
2025-04-09 15:26:50 +03:00
bool res = PollEntry(device.firmware);
Console.WriteLine("Polling for alarm status, poll success: " + res);
if (res)
{
2025-04-09 15:26:50 +03:00
this.Invoke(new MethodInvoker(delegate { labelFirmware.Text = App.ByteArrayToUnicode(latestMessage.Data); }));
}
2025-04-09 15:26:50 +03:00
if (device.hasBattery)
2025-01-24 11:46:36 +03:00
{
2025-04-09 15:26:50 +03:00
res = PollEntry(device.batteryCharge);
if (res)
{
this.Invoke(new MethodInvoker(delegate { labelBattery.Text = latestMessage.Data.Last().ToString(); }));
}
2025-01-24 11:46:36 +03:00
}
2025-04-09 15:26:50 +03:00
res = PollEntry(device.valveStatus);
Console.WriteLine("Polling for valve status, poll success: " + res);
if (res)
2025-01-24 11:46:36 +03:00
{
2025-04-09 15:26:50 +03:00
if (latestMessage.Data.Last() > 0)
{
isValveClosed = true;
this.Invoke(new MethodInvoker(delegate { labelValve.Text = "Закрыт"; }));
this.Invoke(new MethodInvoker(delegate { buttonValve.Text = "Открыть"; }));
}
else
{
isValveClosed = false;
this.Invoke(new MethodInvoker(delegate { labelValve.Text = "Открыт"; }));
this.Invoke(new MethodInvoker(delegate { buttonValve.Text = "Закрыть"; }));
}
2025-01-24 11:46:36 +03:00
}
2025-04-09 15:26:50 +03:00
res = PollEntry(device.alarmStatus);
Console.WriteLine("Polling for alarm status, poll success: " + res);
2025-01-24 11:46:36 +03:00
if (res)
{
2025-04-09 15:26:50 +03:00
Console.WriteLine("Alarm data: " + Modbus.ByteArrayToString(latestMessage.Data));
Console.WriteLine("Alarm data.last: " + latestMessage.Data.Last().ToString());
2025-01-24 11:46:36 +03:00
if (latestMessage.Data.Last() > 0)
{
2025-04-09 15:26:50 +03:00
alarmStatus = true;
this.Invoke(new MethodInvoker(delegate { buttonAlarm.Text = "Выключить"; }));
this.Invoke(new MethodInvoker(delegate { labelAlarm.Text = "Протечка!"; }));
2025-01-24 11:46:36 +03:00
}
else
{
2025-04-09 15:26:50 +03:00
alarmStatus = false;
this.Invoke(new MethodInvoker(delegate { buttonAlarm.Text = "Авария"; }));
this.Invoke(new MethodInvoker(delegate { labelAlarm.Text = "нет"; }));
2025-01-24 11:46:36 +03:00
}
}
2025-04-09 15:26:50 +03:00
if (device.hasCleaningMode)
2025-04-02 12:40:39 +03:00
{
2025-04-09 15:26:50 +03:00
res = PollEntry(device.cleaningMode);
2025-04-02 12:40:39 +03:00
if (res)
{
2025-04-09 15:26:50 +03:00
if (latestMessage.Data.Last() > 0)
{
cleaningStatus = true;
this.Invoke(new MethodInvoker(delegate { buttonCleaning.Text = "Выключить"; }));
this.Invoke(new MethodInvoker(delegate { labelCleaning.Text = "вкл"; }));
}
else
{
cleaningStatus = false;
this.Invoke(new MethodInvoker(delegate { buttonCleaning.Text = "Включить"; }));
this.Invoke(new MethodInvoker(delegate { labelCleaning.Text = "выкл"; }));
}
2025-04-02 12:40:39 +03:00
}
}
2025-04-09 15:26:50 +03:00
if (device.wiredLineBreak != null || device.wiredLineBreak.Count > 0)
2025-01-24 11:46:36 +03:00
{
2025-04-09 15:26:50 +03:00
for (int i = 0; i < device.wiredLineBreak.Count; i++)
{
res = PollEntry(device.wiredLineBreak[i]);
if (res)
{
bool value = latestMessage.Data[0] > 0x00 ? true : false;
WiredSensor snsr = sensorPanel.Controls[i] as WiredSensor;
snsr.Invoke(new MethodInvoker(delegate { snsr.labelBreak.Text = value ? "Обрыв!" : "ОК"; }));
}
}
2025-01-24 11:46:36 +03:00
}
2025-01-24 17:54:04 +03:00
2025-04-09 15:26:50 +03:00
res = PollEntry(device.sensorAlarm);
if (res)
2025-01-24 17:54:04 +03:00
{
2025-04-09 15:26:50 +03:00
BitArray bArray = new BitArray(latestMessage.Data);
bool[] bools = new bool[bArray.Length];
bArray.CopyTo(bools, 0);
for (int i = 0; i < sensorPanel.Controls.Count; i++)
2025-01-24 17:54:04 +03:00
{
2025-04-09 15:26:50 +03:00
Sensor snsr = sensorPanel.Controls[i] as Sensor;
snsr.Invoke(new MethodInvoker(delegate { snsr.labelLeak.Text = bools[i] ? "Протечка!" : "нет"; }));
2025-01-24 17:54:04 +03:00
}
}
2025-04-09 15:26:50 +03:00
Console.WriteLine("Polling for radio status");
res = PollEntry(device.radioStatus);
if (res)
{
List<byte> values = new List<byte>(latestMessage.Data.Length / 2);
for (int i = 1; i < latestMessage.Data.Length; i += 2)
values.Add(latestMessage.Data[i]);
int add = device.wiredSensors + (device.hasScenarioSensor ? 1 : 0);
for (int i = 0; i < sensorPanel.Controls.Count - add; i++)
{
WirelessSensor snsr = sensorPanel.Controls[i + add] as WirelessSensor;
string txt = "нет";
switch (values[i])
{
case 1:
txt = "норма";
break;
case 2:
txt = "протечка";
break;
case 3:
txt = "разряжен";
break;
case 4:
txt = "потеря";
break;
}
snsr.Invoke(new MethodInvoker(delegate { snsr.labelStatus.Text = txt; }));
}
}
});
2025-01-21 14:38:59 +03:00
}
2025-01-24 11:46:36 +03:00
catch (Exception err) { MessageBox.Show(err.Message); }
}
2024-12-05 17:52:25 +03:00
2025-04-09 15:26:50 +03:00
bool PollEntry(Entry entry)
2025-01-21 14:38:59 +03:00
{
latestMessage = null;
2025-01-24 11:46:36 +03:00
bool res = false;
2025-01-21 14:38:59 +03:00
isAwaitingResponse = true;
2025-04-09 15:26:50 +03:00
isPolling = true;
Modbus.ReadRegAsync(modbusID, (FunctionCode)entry.registerType, entry.address, entry.length);
stopwatch.Restart();
while (isAwaitingResponse && latestMessage == null)
2025-01-24 11:46:36 +03:00
{
if (stopwatch.ElapsedMilliseconds > 5000)
2025-01-24 11:46:36 +03:00
{
Console.WriteLine("Response timed out.");
break;
2025-01-24 11:46:36 +03:00
}
}
2025-01-24 11:46:36 +03:00
if (latestMessage != null && latestMessage.Status != ModbusStatus.Error)
res = true;
Console.WriteLine("Poll attempt finished");
2025-04-09 15:26:50 +03:00
isPolling = false;
return res;
}
bool SetEntry(Entry entry, ushort value)
{
latestMessage = null;
bool res = false;
isAwaitingResponse = true;
isPolling = true;
FunctionCode fc = FunctionCode.WriteCoil;
if (entry.registerType == RegisterType.Holding)
fc = FunctionCode.WriteRegister;
Modbus.WriteSingleAsync(fc, modbusID, entry.address, value);
stopwatch.Restart();
while (isAwaitingResponse && latestMessage == null)
{
if (stopwatch.ElapsedMilliseconds > port.ReadTimeout)
{
Console.WriteLine("Response timed out.");
break;
}
}
if (latestMessage != null && latestMessage.Status == ModbusStatus.WriteSuccess)
res = true;
isPolling = false;
2025-01-24 11:46:36 +03:00
return res;
}
2025-01-21 14:38:59 +03:00
// Задать новый Slave ID для устройства
2025-01-24 11:46:36 +03:00
private async void buttonSetID_Click(object sender, EventArgs e)
{
byte newID = (byte)nudModbusID.Value; // should prevent assigning wrong ID if UpDown is fiddled with in the middle of request
isAwaitingResponse = true;
latestMessage = null;
2025-01-24 11:46:36 +03:00
Modbus.WriteSingleAsync(FunctionCode.WriteRegister, modbusID, 128, newID);
stopwatch.Restart();
while (isAwaitingResponse)
2025-01-21 14:38:59 +03:00
{
2025-04-09 15:26:50 +03:00
if (stopwatch.ElapsedMilliseconds > 10000)
2025-01-21 14:38:59 +03:00
{
Console.WriteLine("Response timed out.");
break;
2025-01-21 14:38:59 +03:00
}
}
2025-01-21 14:38:59 +03:00
2025-01-24 11:46:36 +03:00
if (latestMessage != null && latestMessage.Status != ModbusStatus.Error)
modbusID = newID;
2025-01-21 14:38:59 +03:00
}
2025-01-24 11:46:36 +03:00
// Кран
2025-01-24 11:46:36 +03:00
private async void buttonValve_Click(object sender, EventArgs e)
{
2025-04-09 15:26:50 +03:00
try
2024-12-09 16:24:02 +03:00
{
2025-04-09 15:26:50 +03:00
await Task.Run(() =>
2025-01-24 11:46:36 +03:00
{
2025-04-09 15:26:50 +03:00
ushort value = isValveClosed ? (ushort)0 : (ushort)0xFF00;
if (SetEntry(device.valveStatus, value))
{
isValveClosed = !isValveClosed;
labelValve.Invoke(new MethodInvoker(delegate { labelValve.Text = isValveClosed ? "Закрыт" : "Открыт"; }));
buttonValve.Invoke(new MethodInvoker(delegate { buttonValve.Text = isValveClosed ? "Открыть" : "Закрыть"; }));
}
});
}
2025-04-09 15:26:50 +03:00
catch (Exception err)
2025-01-24 11:46:36 +03:00
{
2025-04-09 15:26:50 +03:00
MessageBox.Show(err.Message, "Valve Set Error");
2025-01-24 11:46:36 +03:00
}
}
2025-01-17 10:40:18 +03:00
// Авария
2025-04-09 15:26:50 +03:00
private void buttonAlarm_Click(object sender, EventArgs e)
2025-01-17 10:40:18 +03:00
{
2025-01-24 11:46:36 +03:00
ushort value = alarmStatus ? (ushort)0 : (ushort)0xFF00;
2025-04-09 15:26:50 +03:00
if (SetEntry(device.alarmStatus, value))
2025-01-24 11:46:36 +03:00
{
alarmStatus = !alarmStatus;
labelAlarm.Text = alarmStatus ? "Протечка!" : "Нет";
buttonAlarm.Text = alarmStatus ? "Выключить" : "Авария";
}
}
// Режим уборки
2025-04-09 15:26:50 +03:00
private void buttonCleaning_Click(object sender, EventArgs e)
2025-01-24 11:46:36 +03:00
{
ushort value = cleaningStatus ? (ushort)0 : (ushort)0xFF00;
2025-04-09 15:26:50 +03:00
if (SetEntry(device.cleaningMode, value))
2025-01-24 11:46:36 +03:00
{
cleaningStatus = !cleaningStatus;
labelCleaning.Text = cleaningStatus ? "вкл" : "выкл";
buttonCleaning.Text = cleaningStatus ? "Выключить" : "Включить";
}
}
// Задать скорость передачи данных для устройства
2025-04-09 15:26:50 +03:00
private void buttonSetSpeed_Click(object sender, EventArgs e)
{
try
{
string str = cBoxSpeed.Items[cBoxSpeed.SelectedIndex].ToString();
str = str.Substring(0, str.Length - 2); //clip off two zeroes at the end
ushort newSpeed = (ushort)Int16.Parse(str);
2025-04-09 15:26:50 +03:00
Console.WriteLine("new speed: " + newSpeed);
if (SetEntry(device.baudRate, newSpeed))
{
2025-04-09 15:26:50 +03:00
//port.Close();
port.BaudRate = newSpeed * 100;
//port.Open();
}
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
2025-02-28 18:00:17 +03:00
// Выбор файла прошивки
2025-02-28 18:00:17 +03:00
private void BrowseFirmware_Click(object sender, EventArgs e)
{
try
{
fileThread.SetApartmentState(ApartmentState.STA);
2025-02-28 18:00:17 +03:00
fileThread.Start();
while (!fileThread.IsAlive) { Thread.Sleep(1); }
Thread.Sleep(1);
fileThread.Join();
}
catch (Exception err) { MessageBox.Show(err.Message); }
firmwarePathLabel.Invoke(new MethodInvoker(delegate { firmwarePathLabel.Text = firmwarePath; }));
2025-02-28 18:00:17 +03:00
}
// Запись прошивки
private async void WriteFirmware_Click(object sender, EventArgs e)
2025-02-28 18:00:17 +03:00
{
if (firmwarePath is null || firmwarePath.Length == 0)
{
MessageBox.Show("Выберите файл прошивки.");
return;
}
int cntr = 0;
2025-02-28 18:00:17 +03:00
FileStream fileStream = File.OpenRead(firmwarePath);
long bytesLeft = fileStream.Length;
long bytesTotal = fileStream.Length;
int count = 64;
byte[] buffer = new byte[count];
2025-02-28 18:00:17 +03:00
byte[] bdma;
short _flashAddr = 0;
byte[] flashAddr = new byte[2];
byte[] CRC;
2025-02-28 18:00:17 +03:00
List<byte> message;
bool firstMessageSent = false;
long bytesWritten = 0;
await Task.Run(() =>
2025-02-28 18:00:17 +03:00
{
while (bytesLeft > 0)
{
if (firstMessageSent && port.BaudRate != 9600) // after first message the device is sent into recovery mode which only supports 9600 bps
{
port.Close();
port.BaudRate = 9600;
port.Open();
}
2025-02-28 18:00:17 +03:00
count = bytesLeft > 64 ? 64 : (int)bytesLeft;
buffer = new byte[count];
fileStream.Read(buffer, 0, count);
2025-02-28 18:00:17 +03:00
bdma = new byte[2];
bdma[0] = (byte)((bytesLeft & 0xFF_00) >> 8);
bdma[1] = (byte)(bytesLeft & 0x00_FF);
flashAddr[0] = (byte)((_flashAddr & 0xFF_00) >> 8);
flashAddr[1] = (byte)(_flashAddr & 0x00_FF);
2025-02-28 18:00:17 +03:00
message = new List<byte>();
message.Add(modbusID); // device ID
message.Add(0x10); // function code
message.Add(0xFF); // register address
message.Add(0xFF); // register address
message.Add(0x00); // regCnt (?)
message.Add(0x21); // regCnt (?)
message.Add(0x42); // data bytecount
message.Add(flashAddr[0]);
message.Add(flashAddr[1]);
2025-02-28 18:00:17 +03:00
try
2025-02-28 18:00:17 +03:00
{
for (int i = 0; i < buffer.Length; i++)
{
message.Add(buffer[i]);
}
message.Add(0x00);
message.Add(0x00);
CRC = new byte[2];
Modbus.GetCRC(message.ToArray(), ref CRC);
message[message.Count - 2] = CRC[0];
message[message.Count - 1] = CRC[1];
responseReceived = false;
while (true)
{
if (cntr > 3)
{
Console.WriteLine("Response timed out 4 times in a row, aborting. Check connection.");
return;
}
isAwaitingResponse = true;
latestMessage = null;
Console.WriteLine("Outgoing firmware message: " + Modbus.ByteArrayToString(message.ToArray()));
port.Write(message.ToArray(), 0, message.Count);
stopwatch.Restart();
while (isAwaitingResponse)
{
if (stopwatch.ElapsedMilliseconds > port.ReadTimeout)
{
Console.WriteLine("Response timed out.");
cntr++;
break;
}
}
if (responseReceived)
{
if (latestMessage.Status == ModbusStatus.Error)
Console.WriteLine("Response received: Error!");
else
{
Console.WriteLine("Response received: all good;");
break;
}
}
}
cntr = 0;
bytesLeft -= count;
bytesWritten += count;
firmwareProgressBar.Invoke((MethodInvoker)delegate { firmwareProgressBar.Increment((int)(bytesWritten / bytesTotal) * 100); });
_flashAddr += (short)count;
if (port.BaudRate != 9600)
firstMessageSent = true;
if (bytesLeft <= 0)
Console.WriteLine("Reached the end of firmware file.");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Firmware writing error");
return;
}
}
2025-02-28 18:00:17 +03:00
/* Final Message */
message = new List<byte>();
message.Add(modbusID); // device ID
message.Add(0x10); // function code
message.Add(0xFF); // register address
message.Add(0xFF); // register address
message.Add(0x00); // regCnt (?)
message.Add(0x21); // regCnt (?)
message.Add(0x00); // data bytecount
message.Add(0x00); // CRC
message.Add(0x00); // CRC
CRC = new byte[2];
Modbus.GetCRC(message.ToArray(), ref CRC);
message[message.Count - 2] = CRC[0];
message[message.Count - 1] = CRC[1];
while (true)
{
2025-02-28 18:00:17 +03:00
isAwaitingResponse = true;
Console.WriteLine("Outgoing firmware message: " + Modbus.ByteArrayToString(message.ToArray()));
2025-02-28 18:00:17 +03:00
port.Write(message.ToArray(), 0, message.Count);
stopwatch.Restart();
2025-02-28 18:00:17 +03:00
while (isAwaitingResponse)
2025-02-28 18:00:17 +03:00
{
if (stopwatch.ElapsedMilliseconds > 1000)
2025-02-28 18:00:17 +03:00
{
Console.WriteLine("Response timed out.");
break;
2025-02-28 18:00:17 +03:00
}
}
if (responseReceived)
{
if (latestMessage.Status == ModbusStatus.Error)
Console.WriteLine("Response received: Error!");
else
{
Console.WriteLine("Response received: all good;");
break;
}
}
2025-02-28 18:00:17 +03:00
}
});
2025-02-28 18:00:17 +03:00
}
2025-01-24 11:46:36 +03:00
}
public class Sensor : FlowLayoutPanel
{
public Label labelName = new Label() { Width = 60, Height = 24 };
public Label labelLeakFluff = new Label() { Width = 60, Height = 24 };
public Label labelLeak = new Label() { Width = 50, Height = 24 };
}
public class WiredSensor : Sensor
{
public Label labelBreakFluff = new Label() { Width = 45, Height = 24 };
public Label labelBreak = new Label() { Width = 55, Height = 24 }; // обрыв линии для WSP+
2025-01-24 17:54:04 +03:00
//public Label labelWSPPlusFluff = new Label() { Width = 45, Height = 24 };
//public CheckBox wspPlusCheckbox = new CheckBox() { Width = 20, Height = 14 };
2025-01-24 11:46:36 +03:00
public WiredSensor(int count)
{
this.Margin = Padding.Empty;
this.Padding = new Padding(0, 5, 0, 0);
this.WrapContents = false;
this.BackColor = Color.White;
this.Height = 15;
this.FlowDirection = FlowDirection.LeftToRight;
this.Controls.Add(labelName);
this.Controls.Add(labelBreakFluff);
this.Controls.Add(labelBreak);
this.Controls.Add(labelLeakFluff);
this.Controls.Add(labelLeak);
2025-01-24 17:54:04 +03:00
//this.Controls.Add(labelWSPPlusFluff);
//this.Controls.Add(wspPlusCheckbox);
2025-01-24 11:46:36 +03:00
labelName.Text = "WSP " + (count + 1);
labelLeakFluff.Text = "Протечка:";
labelLeak.Text = "неизвестно";
labelBreakFluff.Text = "Обрыв:";
labelBreak.Text = "неизвестно";
2025-01-24 17:54:04 +03:00
//labelWSPPlusFluff.Text = "WSP+:";
//wspPlusCheckbox.Margin = Padding.Empty;
2025-01-17 10:40:18 +03:00
}
2025-01-24 11:46:36 +03:00
}
public class WirelessSensor : Sensor
{
2025-01-24 17:54:04 +03:00
public Label labelStatusFluff = new Label() { Width = 45, Height = 24 };
public Label labelStatus = new Label() { Width = 55, Height = 24 };
2025-01-17 10:40:18 +03:00
2025-01-24 11:46:36 +03:00
public WirelessSensor(int count)
2025-01-17 10:40:18 +03:00
{
2025-01-24 11:46:36 +03:00
this.Margin = Padding.Empty;
this.Padding = new Padding(0, 5, 0, 0);
this.BackColor = Color.White;
this.FlowDirection = FlowDirection.LeftToRight;
this.WrapContents = false;
this.Controls.Add(labelName);
2025-01-24 17:54:04 +03:00
this.Controls.Add(labelStatusFluff);
this.Controls.Add(labelStatus);
2025-01-24 11:46:36 +03:00
this.Controls.Add(labelLeakFluff);
this.Controls.Add(labelLeak);
labelName.Text = "WSR " + (count + 1);
labelLeakFluff.Text = "Протечка:";
labelLeak.Text = "неизвестно";
2025-01-24 17:54:04 +03:00
labelStatusFluff.Text = "Статус:";
labelStatus.Text = "неизвестно";
2025-01-17 10:40:18 +03:00
}
2025-01-24 11:46:36 +03:00
}
2025-01-21 14:38:59 +03:00
2025-01-24 11:46:36 +03:00
public class ScenarioSensor : Sensor
{
public ScenarioSensor()
2025-01-21 14:38:59 +03:00
{
2025-01-24 11:46:36 +03:00
labelName.Width = 172;
this.Margin = Padding.Empty;
this.Padding = new Padding(0, 5, 0, 0);
this.FlowDirection = FlowDirection.LeftToRight;
this.WrapContents = false;
2025-01-21 14:38:59 +03:00
2025-01-24 11:46:36 +03:00
this.Controls.Add(labelName);
this.Controls.Add(labelLeakFluff);
this.Controls.Add(labelLeak);
labelName.Text = "Сценарный датчик";
labelLeakFluff.Text = "Протечка:";
labelLeak.Text = "неизвестно";
}
}
}