Exemplo n.º 1
0
        override public bool SetNewValue(string newName)
        {
            newName = newName.Trim();

            if (newName == string.Empty)
            {
                Clear();
                return(true);
            }

            Match strMatch = Regex.Match(newName,
                                         Device.DeviceManager.DESCRIPTION_PATTERN_MULTYLINE,
                                         RegexOptions.IgnoreCase);

            if (!strMatch.Success)
            {
                return(false);
            }

            IList <int> allowedDevicesId =
                actionProcessorStrategy.ProcessDevices(newName, deviceManager);

            DeviceIndex.Clear();
            deviceIndex.AddRange(allowedDevicesId);

            return(true);
        }
        public static void Put(DeviceIndex deviceIndex, int status)
        {
            //Set only the updated devices
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (deviceIndex)
            {
            //Update server by 0 = off or 100 = on
            case DeviceIndex.IndoorLamp:
            case DeviceIndex.OutdoorLamp:
                status = status == 0 ? 100 : 0;
                //TODO Update on server
                break;

            //Update server by between 0=off &  255= on (high speed)
            case DeviceIndex.Radiator:
            case DeviceIndex.Fan:
                status = status + 51 <= 255 ? status + 51 : 0;
                //TODO Update on server

                break;

            //Update On Local Machine
            case DeviceIndex.Timer1:
            case DeviceIndex.Timer2:
            case DeviceIndex.Music:
            case DeviceIndex.Call112:
            case DeviceIndex.Call1177:
            case DeviceIndex.UnderContraction:
                //Do nothing
                break;
            }
        }
Exemplo n.º 3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (DeviceType.Length != 0)
            {
                hash ^= DeviceType.GetHashCode();
            }
            if (ContentType.Length != 0)
            {
                hash ^= ContentType.GetHashCode();
            }
            if (DeviceIndex != 0)
            {
                hash ^= DeviceIndex.GetHashCode();
            }
            if (ReplaceDevice != false)
            {
                hash ^= ReplaceDevice.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 4
0
        public void SaveTo(XmlTextWriter xw)
        {
            xw.WriteAttributeString("type", MappedType.ToString());
            xw.WriteAttributeString("source", Source.ToString());
            xw.WriteAttributeString("uuid", UUID.ToString());

            if (Source == SourceType.RawInput)
            {
                xw.WriteAttributeString("vid", VendorID.ToString("X"));
                xw.WriteAttributeString("pid", ProductID.ToString("X"));
                xw.WriteAttributeString("rpt_hash", ReportHash.ToString());
                xw.WriteAttributeString("idx", DeviceIndex.ToString());
            }
            else if (Source == SourceType.XInput)
            {
                xw.WriteAttributeString("idx", DeviceIndex.ToString());
            }
            else if (Source == SourceType.MUNIA)
            {
                xw.WriteAttributeString("devicepath", DevicePath);
            }
            else if (Source == SourceType.Arduino)
            {
                xw.WriteAttributeString("arduino_port", ArduinoPort.Name);
                xw.WriteAttributeString("arduino_type", ArduinoSource.ToString());
            }

            xw.WriteStartElement("buttons");
            foreach (var btn in ButtonMaps)
            {
                btn.SaveTo(xw);
            }
            xw.WriteEndElement();

            xw.WriteStartElement("axes");
            foreach (var axis in AxisMaps)
            {
                axis.SaveTo(xw);
            }
            xw.WriteEndElement();

            xw.WriteStartElement("buttons_to_axis");
            foreach (var btn in ButtonToAxisMaps)
            {
                btn.SaveTo(xw);
            }
            xw.WriteEndElement();

            xw.WriteStartElement("axis_to_buttons");
            foreach (var axis in AxisToButtonMaps)
            {
                axis.SaveTo(xw);
            }
            xw.WriteEndElement();
        }
Exemplo n.º 5
0
 public static extern bool EnableKeyInterrupt([MarshalAs(UnmanagedType.I1)] bool bEnable, DeviceIndex devIndex = DeviceIndex.DevDefault);
Exemplo n.º 6
0
 public static extern bool SetAllLedColor(ColorMatrix colorMatrix, DeviceIndex devIndex = DeviceIndex.DevDefault);
Exemplo n.º 7
0
 public static extern bool RefreshLed([MarshalAs(UnmanagedType.I1)] bool bAuto, DeviceIndex devIndex = DeviceIndex.DevDefault);
Exemplo n.º 8
0
 public static extern bool EnableLedControl([MarshalAs(UnmanagedType.I1)] bool bEnable, DeviceIndex devIndex = DeviceIndex.DevDefault);
Exemplo n.º 9
0
 internal static extern bool RefreshLed([MarshalAs(UnmanagedType.I1)] bool bAuto = false, DeviceIndex devIndex = DeviceIndex.DEV_DEFAULT);
Exemplo n.º 10
0
 public static extern bool SetLedColor(int iRow, int iColumn, byte r, byte g, byte b, DeviceIndex devIndex);
Exemplo n.º 11
0
 public static extern bool IsDevicePlug(DeviceIndex devIndex);
Exemplo n.º 12
0
 internal static extern void SetKeyCallBack(KeyCallback callback, DeviceIndex devINdex = DeviceIndex.DEV_DEFAULT);
Exemplo n.º 13
0
 internal static extern bool EnableKeyInterrupt(bool bEnable, DeviceIndex devIndex = DeviceIndex.DEV_DEFAULT);
Exemplo n.º 14
0
 internal static extern bool SetLedColor(int iRow, int iColumn, byte r, byte g, byte b, DeviceIndex devIndex = DeviceIndex.DEV_DEFAULT);
Exemplo n.º 15
0
 internal static extern bool SetAllLedColor(ColorMatrix colorMatrix, DeviceIndex devIndex = DeviceIndex.DEV_DEFAULT);
Exemplo n.º 16
0
 internal static extern bool SetFullLedColor(byte r, byte g, byte b, DeviceIndex devIndex = DeviceIndex.DEV_DEFAULT);
Exemplo n.º 17
0
 public static extern void SetKeyCallBack(KeyCallback callback, DeviceIndex devIndex = DeviceIndex.DevDefault);
Exemplo n.º 18
0
 public Device(DeviceIndex deviceIndex)
 {
     this.DeviceIndex = deviceIndex;
 }
Exemplo n.º 19
0
        public static string GetText(this DeviceIndex deviceIndex)
        {
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (deviceIndex)
            {
            case DeviceIndex.Relax:
                return("Relax");

            case DeviceIndex.IndoorLamp:
                return("Indoor Lamp");

            case DeviceIndex.OutdoorLamp:
                return("Outdoor Lamp");

            case DeviceIndex.IndoorTemp:
                return("Indoor Temp");

            case DeviceIndex.OutdoorTemp:
                return("Outdoor Temp");

            case DeviceIndex.Radiator:
                return("Radiator");

            case DeviceIndex.Power:
                return("Power");

            case DeviceIndex.FireAlarm:
                return("Fire Alarm");

            case DeviceIndex.DoorAlarm:
                return("Door Alarm");

            case DeviceIndex.Fan:
                return("Fan");

            case DeviceIndex.WaterLeakage:
                return("Water Leakage");

            case DeviceIndex.Stove:
                return("Stove");;

            case DeviceIndex.Window:
                return("Window");;

            case DeviceIndex.Timer1:
                return("Timer 1");;

            case DeviceIndex.Timer2:
                return("Timer 2");;

            case DeviceIndex.LightSensor:
                return("Light Sensor");

            case DeviceIndex.Music:
                return("Play Music");

            case DeviceIndex.Call112:
                return("Call 112");

            case DeviceIndex.Call1177:
                return("Call 1177");
            }
            return(null);
        }
Exemplo n.º 20
0
 public static extern bool SetAllLedColor(ColorMatrix colorMatrix, DeviceIndex devIndex);
Exemplo n.º 21
0
 internal static extern LayoutKeyboard GetDeviceLayout(DeviceIndex devIndex = DeviceIndex.DEV_DEFAULT);
Exemplo n.º 22
0
 public static extern bool IsDevicePlug(DeviceIndex devIndex = DeviceIndex.DevDefault);
Exemplo n.º 23
0
 internal static extern bool EnableLedControl([MarshalAs(UnmanagedType.I1)] bool bEnable, DeviceIndex devIndex = DeviceIndex.DEV_DEFAULT);
Exemplo n.º 24
0
 public static extern void SetControlDevice(DeviceIndex devIndex);
Exemplo n.º 25
0
 internal static extern bool IsDevicePlug(DeviceIndex devIndex = DeviceIndex.DEV_DEFAULT);