Esempio n. 1
0
        private bool X10ON(bool ON, string address)
        {
            ActiveHomeScriptLib.ActiveHomeClass act = new ActiveHomeScriptLib.ActiveHomeClass();
            // access the X10 device to enable change

            if (X10Address(address))
            {
                try
                {
                    object act2 = act.SendAction("queryplc", address + " on", null, null);
                    bool isON = act2.Equals(1);

                    if(!ON && isON) // if not supposed to be ON but is
                      act.SendAction("sendplc", address + " off", null, null);
                    else if(ON && !isON) // if is ON but should not be
                      act.SendAction("sendplc", address + " on", null, null);

                    errorcount = 0;
                    return true;
                }
                catch (Exception ex)
                {
                    AppendToFile("Error accessing X10 device: " + address);
                    ++errorcount;
                    if (errorcount > ERRORMAX)
                    {
                        //   MessageBox.Show("Error accessing X10 device: " + address + "    " + ex);
                    }
                    return false;
                }
            }
            else
                return true;
        }
Esempio n. 2
0
        private bool X10check(bool state, string address)
        {
            // check the current state of an X10 device

            ActiveHomeScriptLib.ActiveHomeClass act = new ActiveHomeScriptLib.ActiveHomeClass();
            bool rtn;
            if (X10Address(address))
            {
                try
                {
                    if (act.SendAction("queryplc", address + " on", null, null).Equals(1))
                       rtn = true;
                    else
                        rtn = false;
                    errorcount = 0;
                    return rtn;
                }
                catch (Exception ex)
                {
                    AppendToFile("Error accessing X10 device: " + address);
                    ++errorcount;
                    if (errorcount > ERRORMAX)
                    {
                        MessageBox.Show("Error accessing X10 device: " + address + "    " + ex);
                    }
                    return state;
                }

            }
            else
                return state;
        }