示例#1
0
        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
        }
示例#2
0
 public void SendMaxLoad() => ComPorts.SendBytes($"{ComPortIndex}MAX{ToCString(InitialLoad)}");
示例#3
0
 public void SendLocalLoad()
 {
     ComPorts.SendBytes($"{ComPortIndex}VAL{ToCString(CurrentLoad)}");
     WriteLine($"    {this}: Value set to {ToCString(CurrentLoad)}");
 }