示例#1
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            ZigBeeEndPoint endPoint = value as ZigBeeEndPoint;

            if (value == null)
            {
                return("Unknown");
            }
            else if (!endPoint.IsActivated)
            {
                return("Inactive");
            }
            else
            {
                foreach (ZigBeeInCluster zigBeeInCluster in endPoint.ZigBeeInClusters.Where(z => z.ClusterId == 6))
                {
                    foreach (ZigBeeInClusterAttribute zigBeeInClusterAttribute in zigBeeInCluster.ZigBeeInClusterAttributes)
                    {
                        if ((string)parameter == "Plug")
                        {
                            return((bool)zigBeeInClusterAttribute.RealValue ? " On" : " Off");
                        }
                        else
                        {
                            return((bool)zigBeeInClusterAttribute.RealValue ? " On" : " Off");
                        }
                    }
                }
                return("Unknown");
            }
        }
示例#2
0
        private bool SetBitronHomeDevice()
        {
            m_testedDevice   = null;
            m_testedEndPoint = null;
            int nb_trial = 100;

            while (nb_trial > 0)
            {
                if (m_zigBeeAdapter.DeviceList.TryGetValue(BITRON_HOME_DOOR_SENSOR_MAC_ADDRESS, out m_testedDevice) &&
                    m_testedDevice.EndPointList.TryGetValue(BITRON_HOME_DOOR_SENSOR_END_POINT, out m_testedEndPoint))
                {
                    Debug.WriteLine("End point: {0} - {1} - Mac address: 0x{2:X}, Id: 0x{3:X2}, ZigBee profile 0x{4:X4}",
                                    m_testedEndPoint.Vendor, m_testedEndPoint.Model, m_testedDevice.MacAddress, m_testedEndPoint.Id, m_testedEndPoint.CommandProfileId);
                    break;
                }
                else
                {
                    Debug.WriteLine("Wait for BitronDevice - {0}", nb_trial);
                    System.Threading.Tasks.Task.Delay(1000).Wait();
                    nb_trial--;
                }
            }

            if (m_testedDevice != null &&
                m_testedEndPoint != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
 private void DimUp(ZigBeeEndPoint endPoint)
 {
     Debug.WriteLine("DimUp !!!");
     foreach (var EndDevice in LightDeviceListSources)
     {
         foreach (var l in EndDevice.EndPoints.Where(w => w.Id == endPoint.Id))
         {
             LightDeviceSelectedItem = EndDevice;
         }
     }
 }
示例#4
0
 private bool SetDresdenElektronikDevice()
 {
     m_testedDevice   = null;
     m_testedEndPoint = null;
     if (m_zigBeeAdapter.DeviceList.TryGetValue(DRESDEN_ELEKTRONIK_BALLAST_MAC_ADDRESS, out m_testedDevice) &&
         m_testedDevice.EndPointList.TryGetValue(DRESDEN_ELEKTRONIK_BALLAST_END_POINT, out m_testedEndPoint))
     {
         Debug.WriteLine("End point: {0} - {1} - Mac address: 0x{2:X}, Id: 0x{3:X2}, ZigBee profile 0x{4:X4}",
                         m_testedEndPoint.Vendor, m_testedEndPoint.Model, m_testedDevice.MacAddress, m_testedEndPoint.Id, m_testedEndPoint.CommandProfileId);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        private void CustomName_GotFocus(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine("CustomName_GotFocus!!");
            foreach (TextBlock tb in UIElementUtil.FindChildArray <TextBlock>(SettingDeviceListView, "CircleIcon"))
            {
                tb.Foreground = new SolidColorBrush(Windows.UI.Colors.DimGray);
            }

            TextBox        textBox             = sender as TextBox;
            ZigBeeEndPoint endpoint            = textBox.DataContext as ZigBeeEndPoint;
            ListView       SettingPlugListView = UIElementUtil.FindParent <ListView>((TextBox)sender);

            var PlugItem = (ListViewItem)SettingPlugListView.ContainerFromItem(endpoint);

            foreach (TextBlock tb in UIElementUtil.FindChildArray <TextBlock>(PlugItem, "CircleIcon"))
            {
                tb.Foreground = ConverHexToColor.GetSolidColorBrush("#ffcb00");
            }
        }
        private void LampToggle(ZigBeeEndPoint endPoint)
        {
            Debug.WriteLine("Call LampToggle !! " + endPoint.MacAddress + " # " + endPoint.Id);
            if (endPoint == null)
            {
                return;
            }

            try
            {
                var message = new ValueSet();

                message.Add("Type", "ZWave");
                message.Add("Command", "OnOffToggle");
                message.Add("endPoint", JsonConvert.SerializeObject(endPoint));

                IOTOI.Common.CommonService.GetReturnData(message);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message, "LampToggle Exception : ");
            }
        }
        private void PlugPowerOff(ZigBeeEndPoint endPoint)
        {
            Debug.WriteLine("Call PlugPowerOff !! " + endPoint.MacAddress + " # " + endPoint.Id);

            if (endPoint == null || false == endPoint.IsActivated)
            {
                return;
            }

            try
            {
                var message = new ValueSet();

                message.Add("Type", "ZWave");
                message.Add("Command", "PlugPowerOff");
                message.Add("endPoint", JsonConvert.SerializeObject(endPoint));

                IOTOI.Common.CommonService.GetReturnData(message);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message, "ZWave Plug Power Off Exception : ");
            }
        }