コード例 #1
0
ファイル: set_state_actuator.cs プロジェクト: pereritob/hacs
        public String SetStateActuatorPreset(String XS1_URL, String Username, String Password, String actorname, String preset, XS1Configuration XS1_Configuration)
        {
            String Output = "";
            // get the XS1 Actuator List to find the ID and the Preset ID
            XS1ActuatorList actuatorlist = XS1_Configuration.getXS1ActuatorList(hacs.Properties.Settings.Default.XS1, hacs.Properties.Settings.Default.Username, hacs.Properties.Settings.Default.Password);

            //bool foundatleastoneactuator = false;

            Int32 foundActorID = 0;
            Int32 foundPresetID = 0;

            foreach (XS1Actuator _actuator in actuatorlist.actuator)
            {
                foundActorID++;
                if (_actuator.name.ToUpper() == actorname.ToUpper())
                {
                    //foundActorID = _actuator.id;

                    bool foundpreset = false;

                    foreach (actuator_function actorfunction in _actuator.function)
                    {
                        foundPresetID++;

                        if (actorfunction.type.ToUpper() == preset.ToUpper())
                        {
                            foundpreset = true;
                            break;
                        }
                    }

                    #region doing real stuff
                    if (foundpreset)
                    {
                        if (foundActorID != 0)
                        {
                            // so we obviously got the actor and the preset id... now lets do the call
                            set_state_actuator ssa = new set_state_actuator();
                            Output = ssa.SetStateActuatorPreset(hacs.Properties.Settings.Default.XS1, hacs.Properties.Settings.Default.Username, hacs.Properties.Settings.Default.Password, foundActorID, foundPresetID);
                            //foundatleastoneactuator = true;
                            break;
                        }
                    }
                    #endregion
                }
            }

            return Output;
        }