Exemple #1
0
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="targetDeviceId"></param>
 /// <param name="sourceDeviceId"></param>
 /// <param name="messageType"></param>
 protected RnetMessage(RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId, RnetMessageType messageType)
     : this()
 {
     MessageTimestamp = DateTime.UtcNow;
     TargetDeviceId = targetDeviceId;
     SourceDeviceId = sourceDeviceId;
     MessageType = messageType;
 }
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="targetDeviceId"></param>
 /// <param name="sourceDeviceId"></param>
 /// <param name="targetPath"></param>
 /// <param name="sourcePath"></param>
 /// <param name="packetNumber"></param>
 /// <param name="packetCount"></param>
 /// <param name="data"></param>
 public RnetRequestDataMessage(RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId, RnetPath targetPath,
     RnetPath sourcePath, RnetRequestMessageType type)
     : base(targetDeviceId, sourceDeviceId, RnetMessageType.RequestData)
 {
     TargetPath = targetPath;
     SourcePath = sourcePath;
     Type = type;
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="targetDeviceId"></param>
 /// <param name="sourceDeviceId"></param>
 /// <param name="targetPath"></param>
 /// <param name="sourcePath"></param>
 public RnetNumberSixMessage(RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId, byte b1, byte b2, byte b3, byte b4, byte b5)
     : base(targetDeviceId, sourceDeviceId, RnetMessageType.Number6)
 {
     Byte1 = b1;
     Byte2 = b2;
     Byte3 = b3;
     Byte4 = b4;
     Byte5 = b5;
 }
Exemple #4
0
        /// <summary>
        /// Reads an event message from the reader.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="targetDeviceId"></param>
        /// <param name="sourceDeviceId"></param>
        /// <returns></returns>
        internal static RnetHandshakeMessage Read(RnetMessageBodyReader reader, RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId)
        {
            Contract.Requires<ArgumentNullException>(reader != null);

            var handshakeType = (RnetHandshakeType)reader.ReadByte();
            
            return new RnetHandshakeMessage(
                targetDeviceId, sourceDeviceId,
                handshakeType);
        }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="targetDeviceId"></param>
 /// <param name="sourceDeviceId"></param>
 /// <param name="targetPath"></param>
 /// <param name="sourcePath"></param>
 /// <param name="packetNumber"></param>
 /// <param name="packetCount"></param>
 /// <param name="data"></param>
 public RnetSetDataMessage(RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId, RnetPath targetPath,
     RnetPath sourcePath, ushort packetNumber, ushort packetCount, RnetData data)
     : base(targetDeviceId, sourceDeviceId, RnetMessageType.SetData)
 {
     TargetPath = targetPath;
     SourcePath = sourcePath;
     PacketNumber = packetNumber;
     PacketCount = packetCount;
     Data = data;
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="targetDeviceId"></param>
 /// <param name="sourceDeviceId"></param>
 /// <param name="targetPath"></param>
 /// <param name="sourcePath"></param>
 public RnetEventMessage(RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId, RnetPath targetPath,
     RnetPath sourcePath, RnetEvent evt, ushort timestamp, ushort data, RnetPriority priority)
     : base(targetDeviceId, sourceDeviceId, RnetMessageType.Event)
 {
     TargetPath = targetPath;
     SourcePath = sourcePath;
     Event = evt;
     Timestamp = timestamp;
     Data = data;
     Priority = priority;
 }
Exemple #7
0
        /// <summary>
        /// Reads an event message from the reader.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="targetDeviceId"></param>
        /// <param name="sourceDeviceId"></param>
        /// <returns></returns>
        internal static RnetNumberSixMessage Read(RnetMessageBodyReader reader, RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId)
        {
            Contract.Requires<ArgumentNullException>(reader != null);

            return new RnetNumberSixMessage(
                targetDeviceId, sourceDeviceId,
                reader.ReadByte(),
                reader.ReadByte(),
                reader.ReadByte(),
                reader.ReadByte(),
                reader.ReadByte());
        }
Exemple #8
0
        /// <summary>
        /// Begins a new message.
        /// </summary>
        internal void BeginMessage(RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId, RnetMessageType messageType)
        {
            if (len != -1 || sum != -1)
                throw new InvalidOperationException("A message is already in progress.");

            stm = new MemoryStream();
            len = 0;
            sum = 0;

            WriteStart();
            targetDeviceId.Write(this);
            sourceDeviceId.Write(this);
            WriteByte((byte)messageType);
        }
        /// <summary>
        /// Reads an event message from the reader.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="targetDeviceId"></param>
        /// <param name="sourceDeviceId"></param>
        /// <returns></returns>
        internal static RnetRequestDataMessage Read(RnetMessageBodyReader reader, RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId)
        {
            Contract.Requires<ArgumentNullException>(reader != null);

            var targetPath = RnetPath.Read(reader);
            var sourcePath = RnetPath.Read(reader);
            var type = (RnetRequestMessageType)reader.ReadByte();

            return new RnetRequestDataMessage(
                targetDeviceId, sourceDeviceId,
                targetPath,
                sourcePath,
                type);
        }
Exemple #10
0
        /// <summary>
        /// Gets or creates a handle to the device given the specified device id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        RnetDevice GetOrCreateDevice(RnetDeviceId id)
        {
            Contract.Requires(controllers != null);

            // get controller
            var c = controllers[id.ControllerId];
            if (c == null)
                return null;

            // we are a controller
            if (id.ZoneId == 0 &&
                id.KeypadId == RnetKeypadId.Controller)
                return c;

            // get zone
            var z = c.Zones[id.ZoneId];
            if (z == null)
                return null;

            // get device
            var d = z.Devices[id.KeypadId];
            if (d == null)
                return null;

            return d;
        }
Exemple #11
0
 /// <summary>
 /// Gets a handle to the device given the specified device id.
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public RnetDevice this[RnetDeviceId id]
 {
     get { return GetOrCreateDevice(id); }
 }
Exemple #12
0
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="targetDeviceId"></param>
 /// <param name="sourceDeviceId"></param>
 /// <param name="handshakeType"></param>
 public RnetHandshakeMessage(RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId, RnetHandshakeType handshakeType)
     : base(targetDeviceId, sourceDeviceId, RnetMessageType.Handshake)
 {
     HandshakeType = handshakeType;
 }
Exemple #13
0
        /// <summary>
        /// Reads an event message from the reader.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="targetDeviceId"></param>
        /// <param name="sourceDeviceId"></param>
        /// <returns></returns>
        internal static RnetSetDataMessage Read(RnetMessageBodyReader reader, RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId)
        {
            Contract.Requires<ArgumentNullException>(reader != null);

            var targetPath = RnetPath.Read(reader);
            var sourcePath = RnetPath.Read(reader);
            var packetNumber = reader.ReadUInt16();
            var packetCount = reader.ReadUInt16();
            var data = RnetData.Read(reader);

            return new RnetSetDataMessage(
                targetDeviceId, sourceDeviceId,
                targetPath,
                sourcePath,
                packetNumber,
                packetCount,
                data);
        }
Exemple #14
0
        /// <summary>
        /// Reads an event message from the reader.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="targetDeviceId"></param>
        /// <param name="sourceDeviceId"></param>
        /// <returns></returns>
        internal static RnetEventMessage Read(RnetMessageBodyReader reader, RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId)
        {
            Contract.Requires<ArgumentNullException>(reader != null);

            return new RnetEventMessage(
                targetDeviceId, sourceDeviceId,
                RnetPath.Read(reader),
                RnetPath.Read(reader),
                (RnetEvent)reader.ReadUInt16(),
                reader.ReadUInt16(),
                reader.ReadUInt16(),
                (RnetPriority)reader.ReadByte());
        }
Exemple #15
0
 /// <summary>
 /// Reads an event message from the reader.
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="targetDeviceId"></param>
 /// <param name="sourceDeviceId"></param>
 /// <returns></returns>
 internal static RnetUnknownMessage Read(RnetMessageBodyReader reader, RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId, RnetMessageType messageType)
 {
     return new RnetUnknownMessage(
         targetDeviceId, sourceDeviceId,
         messageType);
 }
Exemple #16
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="targetDeviceId"></param>
        /// <param name="sourceDeviceId"></param>
        /// <param name="messageType"></param>
        public RnetUnknownMessage(RnetDeviceId targetDeviceId, RnetDeviceId sourceDeviceId, RnetMessageType messageType)
            : base(targetDeviceId, sourceDeviceId, messageType)
        {

        }