Example #1
0
 private void RaiseReceivedX10(X10EventArgs e)
 {
     //do not confuse our consumer by calling out to it using multiple threads at the same time
     lock (syncEventOut)
         if (ReceivedX10 != null)
         {
             try
             {
                 ReceivedX10(this, e);
             }
             catch { }
         }
 }
Example #2
0
 private void RaiseSendX10Result(X10EventArgs e)
 {
     //do not confuse our consumer by calling out to it using multiple threads at the same time
     lock (syncEventOut)
         if (SendX10Result != null)
         {
             try
             {
                 SendX10Result(this, e);
             }
             catch { }
         }
 }
Example #3
0
        private void x10_SendX10Result(object sender, X10EventArgs e)
        {
            if (e.ResultCode == 0)              //OK
            {
                X10Event2XPLMsg(e, true);
            }
            else             //error
            {
                XplMsg x = xL.GetPreparedXplMessage(XplMsg.xPLMsgType.trig, true);
                x.Class = "log";
                x.Type  = "basic";
                x.AddKeyValuePair("type", "err");
                x.AddKeyValuePair("code", "x10");
                x.AddKeyValuePair("text", "error " + e.Devices + " " + X10Enum2String(e.X10Command));
                x.Send();
//				string xplMsg = "type=err" + '\n' + "code=x10" + '\n' + "text=error " + e.Devices + " " + X10Enum2String(e.X10Command) + '\n';
//				xL.SendMessage("xpl-cmnd", "*", "log.basic", xplMsg);
            }
        }
Example #4
0
        private void x10_SendX10Result(object sender, X10EventArgs e)
        {
            if (e.ResultCode == 0)              //OK
            {
                X10Event2XPLMsg(e, true);
            }
            else             //error
            {
                xPLMessage x = new xPLMessage();
                x.Source  = xL.Address;
                x.MsgType = xPL_Base.xPLMessageTypeEnum.Trigger;
                x.Target  = "*";
                x.Schema  = "log.basic";
                x.KeyValueList.Add("type", "err");
                x.KeyValueList.Add("code", "x10");
                x.KeyValueList.Add("text", "error " + e.Devices + " " + X10Enum2String(e.X10Command));
                x.Send(xL);
//				string xplMsg = "type=err" + '\n' + "code=x10" + '\n' + "text=error " + e.Devices + " " + X10Enum2String(e.X10Command) + '\n';
//				xL.SendMessage("xpl-cmnd", "*", "log.basic", xplMsg);
            }
        }
Example #5
0
 private void RaiseSendX10Result(X10EventArgs e)
 {
     //do not confuse our consumer by calling out to it using multiple threads at the same time
     lock(syncEventOut)
         if (SendX10Result != null)
             try
             {
                 SendX10Result(this, e);
             }
             catch { }
 }
Example #6
0
 private void RaiseReceivedX10(X10EventArgs e)
 {
     //do not confuse our consumer by calling out to it using multiple threads at the same time
     lock(syncEventOut)
         if (ReceivedX10 != null)
             try
             {
                 ReceivedX10(this, e);
             }
             catch { }
 }
Example #7
0
        private void X10Event2XPLMsg(X10EventArgs e, bool confirmation)
        {
            //string xplMsg = string.Empty;
            xPLMessage x = new xPLMessage();

            x.MsgType = xPL_Base.xPLMessageTypeEnum.Trigger;
            x.Target  = "*";

            if (e.Devices.Length == 1)            //housecode, no devices
            {
                //xplMsg = "command=" + X10Enum2String(e.X10Command) + '\n' + "house=" + e.Devices + '\n';
                x.KeyValueList.Add("command", X10Enum2String(e.X10Command));
                x.KeyValueList.Add("house", e.Devices);

                if (e.X10Command == X10_COMMANDS.BRIGHT || e.X10Command == X10_COMMANDS.DIM || e.X10Command == X10_COMMANDS.PRESET_DIM1 || e.X10Command == X10_COMMANDS.PRESET_DIM2)
                {
                    //xplMsg += "level=" + e.Brightness.ToString() + '\n';
                    x.KeyValueList.Add("level", e.Brightness.ToString());
                }
                else if (e.X10Command == X10_COMMANDS.EXTENDED)
                {
                    //xplMsg += "data1=" + e.Data1.ToString() + '\n' + "data2=" + e.Data2.ToString() + '\n';
                    x.KeyValueList.Add("data1", e.Data1.ToString());
                    x.KeyValueList.Add("data2", e.Data2.ToString());
                }
                if (confirmation)
                {
                    //xL.SendMessage("xpl-trig", "*", "x10.confirm", xplMsg);
                    x.Schema = "x10.confirm";
                }
                else
                {
                    //xL.SendMessage("xpl-trig", "*", "x10.basic", xplMsg);
                    x.Schema = "x10.basic";
                }

                xL.Send(x);
            }
            else             //devices, send an xpl msg per device
            {
                string[] ardev = e.Devices.Split(',');
                for (int i = 0; i < ardev.Length; i++)
                {
                    //xplMsg = "command=" + X10Enum2String(e.X10Command) + '\n' + "device=" + (i>0?ardev[0].Substring(0,1):"") + ardev[i] + '\n';
                    x.KeyValueList.Add("command", X10Enum2String(e.X10Command));
                    x.KeyValueList.Add("device", (i > 0 ? ardev[0].Substring(0, 1) : "") + ardev[i]);

                    if (e.X10Command == X10_COMMANDS.BRIGHT || e.X10Command == X10_COMMANDS.DIM || e.X10Command == X10_COMMANDS.PRESET_DIM1 || e.X10Command == X10_COMMANDS.PRESET_DIM2)
                    {
                        //xplMsg += "level=" + e.Brightness.ToString() + '\n';
                        x.KeyValueList.Add("level", e.Brightness.ToString());
                    }

                    else if (e.X10Command == X10_COMMANDS.EXTENDED)
                    {
                        //xplMsg += "data1=" + e.Data1.ToString() + '\n' + "data2=" + e.Data2.ToString() + '\n';
                        x.KeyValueList.Add("data1", e.Data1.ToString());
                        x.KeyValueList.Add("data2", e.Data2.ToString());
                    }
                    if (confirmation)
                    {
                        //xL.SendMessage("xpl-trig", "*", "x10.confirm", xplMsg);
                        x.Schema = "x10.confirm";
                    }
                    else
                    {
                        //xL.SendMessage("xpl-trig", "*", "x10.basic", xplMsg);
                        x.Schema = "x10.basic";
                    }

                    xL.Send(x);
                }
            }
        }
Example #8
0
 private void x10_ReceivedX10(object sender, X10EventArgs e)
 {
     X10Event2XPLMsg(e, false);
 }
Example #9
0
        private void X10Event2XPLMsg(X10EventArgs e, bool confirmation)
        {
            //string xplMsg = string.Empty;
            XplMsg x = xL.GetPreparedXplMessage(XplMsg.xPLMsgType.trig, true);

            x.Class = "x10";

            if (e.Devices.Length == 1)            //housecode, no devices
            {
                //xplMsg = "command=" + X10Enum2String(e.X10Command) + '\n' + "house=" + e.Devices + '\n';
                x.AddKeyValuePair("command", X10Enum2String(e.X10Command));
                x.AddKeyValuePair("house", e.Devices);

                if (e.X10Command == (byte)X10_COMMANDS.BRIGHT || e.X10Command == (byte)X10_COMMANDS.DIM || e.X10Command == (byte)X10_COMMANDS.PRESET_DIM1 || e.X10Command == (byte)X10_COMMANDS.PRESET_DIM2)
                {
                    //xplMsg += "level=" + e.Brightness.ToString() + '\n';
                    x.AddKeyValuePair("level", e.Brightness.ToString());
                }
                else if (e.X10Command == (byte)X10_COMMANDS.EXTENDED)
                {
                    //xplMsg += "data1=" + e.Data1.ToString() + '\n' + "data2=" + e.Data2.ToString() + '\n';
                    x.AddKeyValuePair("data1", e.Data1.ToString());
                    x.AddKeyValuePair("data2", e.Data2.ToString());
                }
                if (confirmation)
                {
                    //xL.SendMessage("xpl-trig", "*", "x10.confirm", xplMsg);
                    x.Type = "confirm";
                }
                else
                {
                    //xL.SendMessage("xpl-trig", "*", "x10.basic", xplMsg);
                    x.Type = "basic";
                }

                x.Send();
            }
            else             //devices, send an xpl msg per device
            {
                string[] ardev = e.Devices.Split(',');
                for (int i = 0; i < ardev.Length; i++)
                {
                    //xplMsg = "command=" + X10Enum2String(e.X10Command) + '\n' + "device=" + (i>0?ardev[0].Substring(0,1):"") + ardev[i] + '\n';
                    x.AddKeyValuePair("command", X10Enum2String(e.X10Command));
                    x.AddKeyValuePair("device", (i > 0 ? ardev[0].Substring(0, 1) : "") + ardev[i]);

                    if (e.X10Command == (byte)X10_COMMANDS.BRIGHT || e.X10Command == (byte)X10_COMMANDS.DIM || e.X10Command == (byte)X10_COMMANDS.PRESET_DIM1 || e.X10Command == (byte)X10_COMMANDS.PRESET_DIM2)
                    {
                        //xplMsg += "level=" + e.Brightness.ToString() + '\n';
                        x.AddKeyValuePair("level", e.Brightness.ToString());
                    }

                    else if (e.X10Command == (byte)X10_COMMANDS.EXTENDED)
                    {
                        //xplMsg += "data1=" + e.Data1.ToString() + '\n' + "data2=" + e.Data2.ToString() + '\n';
                        x.AddKeyValuePair("data1", e.Data1.ToString());
                        x.AddKeyValuePair("data2", e.Data2.ToString());
                    }
                    if (confirmation)
                    {
                        //xL.SendMessage("xpl-trig", "*", "x10.confirm", xplMsg);
                        x.Type = "confirm";
                    }
                    else
                    {
                        //xL.SendMessage("xpl-trig", "*", "x10.basic", xplMsg);
                        x.Type = "basic";
                    }

                    x.Send();
                }
            }
        }