public void Start() { LoadConfiguration(); while (true) { FetchOrders(); Devices.ForEach(UpdateDeviceLoad); if (!ComPorts.IsConnected()) { ComPorts.CreateConnectionIfNotOpen(); if (ComPorts.IsConnected()) { if (ComPorts.IsReady()) { Devices.ForEach(dev => dev.SendMaxLoad()); } else { WriteLine(" COM port device did not send READY! signal"); } } } if (ComPorts.IsConnected()) { Devices.ForEach(AdjustLocalDevice); } Devices.ForEach(IoTHubUtil.UploadLoadData); WriteLine(); WriteLine("... waiting (press CTRL-C to terminate)"); Thread.Sleep(10000); WriteLine(); WriteLine(); } // ReSharper disable once FunctionNeverReturns }
public void SendMaxLoad() => ComPorts.SendBytes($"{ComPortIndex}MAX{ToCString(InitialLoad)}");
public void SendLocalLoad() { ComPorts.SendBytes($"{ComPortIndex}VAL{ToCString(CurrentLoad)}"); WriteLine($" {this}: Value set to {ToCString(CurrentLoad)}"); }