예제 #1
0
        public static APCIType GetAPCIType(this CommonExternalMessageInterface cemi)
        {
            int value = ((cemi.ServiceInformation[7] & 0x03) << 2) +
                        ((cemi.ServiceInformation[8] & 0xC0) >> 6);

            return((APCIType)value);
        }
예제 #2
0
        public static byte[] GetData(this CommonExternalMessageInterface cemi)
        {
            int dataLength = cemi.ServiceInformation[6] & 0x0F;

            byte[] data;

            switch (dataLength)
            {
            case 1:                      // 4 bit max
                data = new[] { (byte)(cemi.ServiceInformation[8] & 0x0F) };
                break;

            case 2:                     // 8 bit
                data = new[] { cemi.ServiceInformation[9] };
                break;

            case 3:                     // 2 bytes
                data = new[] { cemi.ServiceInformation[9], cemi.ServiceInformation[10] };
                break;

            default:
                data = new byte[1];
                break;
            }

            return(data);
        }
예제 #3
0
 public static KnxGroupAddress GetDestinationAddress(this CommonExternalMessageInterface cemi)
 {
     return(new KnxGroupAddress()
     {
         Value = new[] { cemi.ServiceInformation[4], cemi.ServiceInformation[5] }
     });
 }
예제 #4
0
 public static KnxAddress GetSourceAddress(this CommonExternalMessageInterface cemi)
 {
     return(new KnxAddress()
     {
         Value = new[] { cemi.ServiceInformation[2], cemi.ServiceInformation[3] }
     });
 }
예제 #5
0
 private void SendCEMI(CommonExternalMessageInterface message)
 {
     lock (_connection.SequenceNumberLock)
     {
         TunnelingRequest request = new TunnelingRequest()
         {
             ConnectionHeader = new KnxNetBodyConnectionHeader()
             {
                 ChannelId       = _connection.ChannelId,
                 SequenceCounter = _connection.GetNextSequenceNumber()
             },
             Message = message
         };
         UdpClient.SendAsync(request.GetBytes(), _connection.RemoteEndPoint);
     }
 }
예제 #6
0
        public static TunnelingRequest Parse(byte[] buffer, int index)
        {
            TunnelingRequest request = new TunnelingRequest
            {
                Header           = KnxNetIPHeader.Parse(buffer, index),
                ConnectionHeader = KnxNetBodyConnectionHeader.Parse(buffer, index + 6)
            };

            int cemiFrameSize = request.Header.Size - request.ConnectionHeader.StructureLength -
                                request.Header.HeaderSize;

            if (cemiFrameSize == 0)
            {
                return(request);
            }

            CommonExternalMessageInterface msg;

            CommonExternalMessageInterface.TryParse(buffer, index + 10, cemiFrameSize, out msg);
            request.Message = msg;

            return(request);
        }
예제 #7
0
 public static void SetAPCIType(this CommonExternalMessageInterface cemi)
 {
 }