示例#1
0
        public override bool ProcessPacket(EnOceanPacket packet)
        {
            Console.WriteLine("Specific handler for packet, dta1={0}", packet.GetData()[1]);
            int  button = 0xff;
            byte cmd    = packet.GetData()[1];

            // FIXME: 0x10 is spring up/down and rest is button down map
            // Adjust button detection to handle correctly.
            // This will allow us to register that 2 buttons are down at the same time
            // Above is probably incorrect still .. check docs!!!
            switch (cmd)
            {
            case 0x10:
                button = 2;
                break;

            case 0x30:
                button = 1;
                break;

            case 0x50:
                button = 4;
                break;

            case 0x70:
                button = 3;
                break;

            //
            default:
                Console.WriteLine("Unknown button, releasing: {0}", cmd);
                button = 0;     // Released
                for (int bc = 1; bc < 5; bc++)
                {
                    if (buttonState.ContainsKey(bc) && buttonState[bc])
                    {
                        SetButtonState(bc, false);
                    }
                }
                return(true);

            case 0x0:
                Console.WriteLine("Buttons released!");
                button = 0;     // Released
                for (int bc = 1; bc < 5; bc++)
                {
                    if (buttonState.ContainsKey(bc) && buttonState[bc])
                    {
                        SetButtonState(bc, false);
                    }
                }
                return(true);
            }
            Console.WriteLine("Button {0} pressed", button);
            SetButtonState(button, true);
            return(true);
        }
示例#2
0
        void controller_PacketEvent(EnOceanPacket pkt)
        {
//            Console.WriteLine("Got packet: {0}, opt type {1}", pkt, pkt.Get_OptionalData().getType());
            Console.WriteLine("Got telegram of type: {0}", pkt.getTelegramType());
            if (pkt.Get_OptionalData() != null && pkt.Get_OptionalData().getSize() > 0)
            {
                var odata = pkt.Get_OptionalData();
//                Console.WriteLine(" - destination was {0:X8}", odata.getDestination());
                String childDevId = ControllerId + ":" + pkt.getSource().ToString("x8");
                //                var devInst = RegisteredDevices[ControllerId + ":" + odata.getDestination().ToString("x8")];
                if (RegisteredDevices.ContainsKey(childDevId))
                {
                    var devInst = RegisteredDevices[childDevId];
                    //                  Console.WriteLine("Located hsDev : {0}", devInst.DeviceId);
                    devInst.ProcessPacket(pkt);
                }
                else
                {
                    if (pkt.getTelegramType() == TelegramType.TT_4BS && ((pkt.GetData()[4]) & 0x08) == 0x08)
                    {
                        Console.WriteLine("4BS - but no teach in bit, ignoring");
                    }
                    else
                    {
                        Console.WriteLine("Add to AddSeenDevices");
                        AddSeenDevice(childDevId);
                    }
                    Console.WriteLine("Did not locate {0:x8}", childDevId);
                }
            }
        }
示例#3
0
        public override bool ProcessPacket(EnOceanPacket packet)
        {
            Console.WriteLine("Specific handler for packet, dta1={0}", packet.GetData()[1]);
            // Check correct type
//            if (packet.getType() == PacketType.)
            byte cmd = packet.GetData()[1];

            switch (cmd)
            {
            case 0x08:
                HS.SetDeviceValueByRef(hsDevice.get_Ref(null), 0x1, true);
                break;

            case 0x09:
                HS.SetDeviceValueByRef(hsDevice.get_Ref(null), 0x0, true);
                break;

            //
            default:
                Console.WriteLine("Unknown state, fixme: {0}", cmd);
                return(true);
            }
            return(true);
        }
示例#4
0
        public override bool ProcessPacket(EnOceanPacket packet)
        {
            Double dta = packet.GetData()[3];

            Console.WriteLine("Specific handler for packet, dta1={0}", dta);

            Double tempBase       = 0;
            Double tempRange      = 40;
            Double tempResolution = 256;

            Double temperature = tempRange - (tempBase + ((tempRange / tempResolution) * dta));

            HS.SetDeviceValueByRef(hsDevice.get_Ref(null), temperature, true);

            return(true);
        }
 void controller_PacketEvent(EnOceanPacket pkt)
 {
     //            Console.WriteLine("Got packet: {0}, opt type {1}", pkt, pkt.Get_OptionalData().getType());
     Console.WriteLine("Got telegram of type: {0}", pkt.getTelegramType());
     if (pkt.Get_OptionalData() != null && pkt.Get_OptionalData().getSize() > 0)
     {
         var odata = pkt.Get_OptionalData();
     //                Console.WriteLine(" - destination was {0:X8}", odata.getDestination());
         String childDevId = ControllerId + ":" + pkt.getSource().ToString("x8");
         //                var devInst = RegisteredDevices[ControllerId + ":" + odata.getDestination().ToString("x8")];
         if (RegisteredDevices.ContainsKey(childDevId))
         {
             var devInst = RegisteredDevices[childDevId];
       //                  Console.WriteLine("Located hsDev : {0}", devInst.DeviceId);
             devInst.ProcessPacket(pkt);
         }
         else
         {
             if (pkt.getTelegramType() == TelegramType.TT_4BS && ((pkt.GetData()[4]) & 0x08) == 0x08)
             {
                 Console.WriteLine("4BS - but no teach in bit, ignoring");
             }
             else
             {
                 Console.WriteLine("Add to AddSeenDevices");
                 AddSeenDevice(childDevId);
             }
             Console.WriteLine("Did not locate {0:x8}", childDevId);
         }
     }
 }
        public override bool ProcessPacket(EnOceanPacket packet)
        {
            Double dta = packet.GetData()[3];
            Console.WriteLine("Specific handler for packet, dta1={0}", dta);

            Double tempBase = 0;
            Double tempRange = 40;
            Double tempResolution = 256;

            Double temperature = tempRange - (tempBase + ( (tempRange / tempResolution) * dta));
            HS.SetDeviceValueByRef(hsDevice.get_Ref(null), temperature, true);

            return true;
        }
 public override bool ProcessPacket(EnOceanPacket packet)
 {
     Console.WriteLine("Specific handler for packet, dta1={0}", packet.GetData()[1]);
     // Check correct type
     //            if (packet.getType() == PacketType.)
     byte cmd = packet.GetData()[1];
     switch (cmd)
     {
         case 0x08:
             HS.SetDeviceValueByRef(hsDevice.get_Ref(null), 0x1, true);
             break;
         case 0x09:
             HS.SetDeviceValueByRef(hsDevice.get_Ref(null), 0x0, true);
             break;
         //
         default:
             Console.WriteLine("Unknown state, fixme: {0}", cmd);
             return true;
     }
     return true;
 }
 public override bool ProcessPacket(EnOceanPacket packet)
 {
     Console.WriteLine("Specific handler for packet, dta1={0}", packet.GetData()[1]);
     int button = 0xff;
     byte cmd = packet.GetData()[1];
     // FIXME: 0x10 is spring up/down and rest is button down map
     // Adjust button detection to handle correctly.
     // This will allow us to register that 2 buttons are down at the same time
     // Above is probably incorrect still .. check docs!!!
     switch (cmd)
     {
         case 0x10:
             button = 2;
             break;
         case 0x30:
             button = 1;
             break;
         case 0x50:
             button = 4;
             break;
         case 0x70:
             button = 3;
             break;
         //
         default:
             Console.WriteLine("Unknown button, releasing: {0}", cmd);
             button = 0; // Released
             for (int bc = 1; bc < 5; bc++)
             {
                 if (buttonState.ContainsKey(bc) && buttonState[bc])
                     SetButtonState(bc, false);
             }
             return true;
         case 0x0:
             Console.WriteLine("Buttons released!");
             button = 0; // Released
             for (int bc = 1; bc < 5; bc++)
             {
                 if (buttonState.ContainsKey(bc) && buttonState[bc])
                     SetButtonState(bc, false);
             }
             return true;
     }
     Console.WriteLine("Button {0} pressed", button);
     SetButtonState(button, true);
     return true;
 }