Пример #1
0
 /// <summary>
 /// Binary message has been received.
 /// </summary>
 private void onBinaryMessageReceived(BinaryMessage msg)
 {
     if (msg.IsActual && msg.Sender != sender)
     {
         var sensor = RailwayState.SensorStates.FirstOrDefault(x => (x.Address.Value == msg.Address) && (x.Address.Network.Type == AddressType.BinkyNet));
         if (sensor != null)
         {
             sensor.Active.Actual = msg.Value;
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Send the on/off value of a binary output.
        /// </summary>
        protected override void OnSendBinaryOutput(Address address, bool value)
        {
            Log.Trace("OnSendBinaryOutput: {0}, {1}", address, value);

            var msg = new BinaryMessage()
            {
                Sender  = sender,
                Mode    = MessageBase.ModeRequest,
                Address = address.Value,
                Value   = value
            };

            publishMessage(msg.Topic, msg, null);
        }
Пример #3
0
        /// <summary>
        /// Send the on/off value of a binary output.
        /// </summary>
        protected override void OnSendBinaryOutput(IBinaryOutputState output)
        {
            Log.Trace("OnSendBinaryOutput: {0}", output);

            var msg = new BinaryMessage()
            {
                Sender  = sender,
                Mode    = MessageBase.ModeRequest,
                Address = output.Address.Value,
                Value   = output.Active.Requested
            };

            publishMessage(msg.Topic, msg, (e) =>
            {
                if (e.IsPublished)
                {
                    output.Active.Actual = output.Active.Actual;
                }
            });
        }