示例#1
0
        internal Sensor GetSensorStatus(Sensor sensor, ModbusService modbusService)
        {
            var status = modbusService.GetSensorStatus(new Slave
            {
                DeviceNumber = (ushort)sensor.Id,
                SlaveId      = (byte)sensor.GatewayId,
            });

            sensor.Status = status ? 1 : 0;
            return(sensor);
        }
示例#2
0
 private void uxCheckStatusTimer_Tick(object sender, EventArgs e)
 {
     try
     {
         foreach (var node in _enableNodes)
         {
             var deviceNumber = (ushort)Convert.ToInt32(node);
             var isBusy       = _modbusService.GetSensorStatus(new Slave
             {
                 DeviceNumber = deviceNumber,
                 SlaveId      = 1
             });
             var response = isBusy ? "ZAJĘTY" : "WOLNY";
             uxConsole.Nodes.Add(String.Format("Czujnik nr {0} jest {1}", node, response));
         }
     }
     catch (Exception ex)
     {
         uxConsole.Nodes.Add(ex.Message).EnsureVisible();
     }
 }