Exemplo n.º 1
0
        private void EdtSetName_Click(object sender, EventArgs e)
        {
            byte           lengthOfStr = (byte)EdtSplashBaseName.Text.Length;
            SplashBaseComs coms        = new SplashBaseComs();

            if (lengthOfStr > 23)
            {
                lengthOfStr = 23;
            }

            string tempStr = "\0\0" + EdtSplashBaseName.Text;

            byte[] byteString = System.Text.Encoding.ASCII.GetBytes(tempStr);
            int    nameLen    = byteString.Length;

            byteString[0] = (byte)CommandNo.SSC_SET_UNIT_NAME;
            byteString[1] = lengthOfStr;
            try
            {
                // todo : dont use the listview selection?
                coms.Command(byteString, byteString.Length, IPAddress.Parse(SelectedSplashBaseIp));
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            SplashBaseComs coms = new SplashBaseComs();

            cmbColourMode.SelectedIndex = 0;
            coms.Ping(IPAddress.Parse(textBox1.Text));
        }
Exemplo n.º 3
0
        private void listView1_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            byte[] data = new byte[3];

            if (BroadcastUpdatingFlag == false)
            {
                //if (listView1.SelectedItems.Count > 0)
                //{
                data[0] = 10;

                if (e.NewValue == CheckState.Checked)
                {
                    data[1] = Convert.ToByte(listRelays.Items[e.Index].Tag);
                }
                else
                {
                    data[1] = Convert.ToByte(0);
                }

                data[2] = Convert.ToByte(listRelays.Items[e.Index].Tag);

                SplashBaseComs coms = new SplashBaseComs();
                coms.Command(data, data.Length, IPAddress.Parse(textBox1.Text));
                //}
            }
        }
Exemplo n.º 4
0
        private void ButApplyInitChange_Click(object sender, EventArgs e)
        {
            UInt16 tempShort = 0;

            byte[]         command = new byte[12];
            SplashBaseComs coms    = new SplashBaseComs();

            try
            {
                command[0] = (byte)CommandNo.SSC_INIT_GPIO_CONF;
                command[1] = Convert.ToByte(EdtSelectedPort.Text);

                command[2] = 0;
                command[3] = 0;

                tempShort = Convert.ToUInt16(EdtInitDir.Text, 16);
                Buffer.BlockCopy(BitConverter.GetBytes(tempShort), 0, command, 4, 2);

                tempShort = Convert.ToUInt16(EdtInitPortPins.Text, 16);
                Buffer.BlockCopy(BitConverter.GetBytes(tempShort), 0, command, 6, 2);

                coms.Command(command, command.Length, IPAddress.Parse(textBox1.Text));
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 5
0
        private void ButFindSplashBases_Click(object sender, EventArgs e)
        {
            SplashBaseComs coms = new SplashBaseComs();

            GrpSplashBase.Enabled = false;
            //coms.BroadcastPing();
            SendBroadCastPing();
        }
Exemplo n.º 6
0
        private void defaultConfigToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SplashBaseComs coms = new SplashBaseComs();

            byte[] byteString = System.Text.Encoding.ASCII.GetBytes("\0default");
            byteString[0] = (byte)CommandNo.SSC_RESET;

            coms.Command(byteString, byteString.Length, IPAddress.Parse(SelectedSplashBaseIp));
        }
Exemplo n.º 7
0
        private void ButRefresh_Click(object sender, EventArgs e)
        {
            byte[]         command = new byte[1];
            SplashBaseComs coms    = new SplashBaseComs();

            command[0] = (byte)CommandNo.SSC_GET_ALL_GPIO;

            coms.Command(command, command.Length, IPAddress.Parse(textBox1.Text));
        }
Exemplo n.º 8
0
        private void ButGpioInitNow_Click(object sender, EventArgs e)
        {
            byte[]         command = new byte[1];
            SplashBaseComs coms    = new SplashBaseComs();

            command[0] = (byte)CommandNo.SSC_INIT_GPIO_RUN;

            coms.Command(command, command.Length, IPAddress.Parse(textBox1.Text));
        }
Exemplo n.º 9
0
        private void ButSaveConfig_Click(object sender, EventArgs e)
        {
            SplashBaseComs coms = new SplashBaseComs();

            byte[] dataBytes = new byte[1];

            dataBytes[0] = (byte)CommandNo.SSC_SAVE_CONFIG;

            coms.Command(dataBytes, dataBytes.Length, IPAddress.Parse(SelectedSplashBaseIp));
        }
Exemplo n.º 10
0
        private void SplashBaseControl_Shown(object sender, EventArgs e)
        {
            SplashBaseComs coms = new SplashBaseComs();

            myDelegate          = new ProcessMessageDelegate(ProcessMessage);
            thread              = new Thread(new ThreadStart(ReceiveMessage));
            thread.IsBackground = true;
            thread.Start();

            coms.BroadcastPing();
        }
Exemplo n.º 11
0
        private void ButRescanBridges_Click(object sender, EventArgs e)
        {
            SplashBaseComs coms = new SplashBaseComs();

            byte[] dataBytes = new byte[2];

            dataBytes[0] = (byte)CommandNo.SSC_BRIDGE_SCAN;
            dataBytes[1] = 0xFF;

            coms.Command(dataBytes, dataBytes.Length, IPAddress.Parse(SelectedSplashBaseIp));
        }
Exemplo n.º 12
0
        private void ButRefreshExtendedInfo_Click(object sender, EventArgs e)
        {
            if (listRemotesFound.SelectedItems.Count > 0)
            {
                UpdateSplashBaseInfo(IPAddress.Parse(SelectedSplashBaseIp));

                //remove debug cmd..
                SplashBaseComs coms      = new SplashBaseComs();
                byte[]         testarray = new byte[1400];

                coms.TestUDPMEssage(testarray, 1400, IPAddress.Parse("224.0.0.251"), 1900);
            }
        }
Exemplo n.º 13
0
        private void readAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SplashBaseComs coms = new SplashBaseComs();

            byte[] dataBytes = new byte[1];

            try
            {
                dataBytes[0] = (byte)CommandNo.SSC_LOGIC_READ;
                coms.Command(dataBytes, dataBytes.Length, IPAddress.Parse(textBox1.Text));
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 14
0
        private void button13_Click(object sender, EventArgs e)
        {
            byte[] data = new byte[3];

            System.Windows.Forms.Button buttonpressed = (Button)sender;

            //IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(textBox1.Text), REMOTE_PORT_NO);
            //Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            data[0] = 10;

            data[1] = Convert.ToByte(buttonpressed.Tag);
            data[2] = Convert.ToByte(buttonpressed.Tag);

            //server.SendTo(data, data.Length, SocketFlags.None, ipep);

            SplashBaseComs coms = new SplashBaseComs();

            coms.Command(data, data.Length, IPAddress.Parse(textBox1.Text));
        }
Exemplo n.º 15
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            SplashBaseComs coms = new SplashBaseComs();

            coms.Ping(IPAddress.Parse(textBox1.Text));

            //coms.BroadcastPing();

            //byte[] data = new byte[6];
            //IPEndPoint ipep = new IPEndPoint(IPAddress.Broadcast, 11028);
            //UdpClient BcastClient = new UdpClient(AddressFamily.InterNetwork);

            //data[0] = 1;
            //data[1] = Convert.ToByte('H');
            //data[2] = Convert.ToByte('e');
            //data[3] = Convert.ToByte('l');
            //data[4] = Convert.ToByte('l');
            //data[5] = Convert.ToByte('o');

            //BcastClient.EnableBroadcast = true;
            //BcastClient.Send(data, data.Length, ipep);
        }
Exemplo n.º 16
0
        private void ButUpdateCondition_Click(object sender, EventArgs e)
        {
            SplashBaseComs coms = new SplashBaseComs();

            byte[] dataBytes = new byte[11];

            // First take the user input from the correct tab
            // and put it into the value box ready to be used

            switch ((LOGIC_CONDITION_TYPE)CmbConditionList.SelectedIndex)
            {
            case LOGIC_CONDITION_TYPE.L_EVENT_GPIO_RAISING:
            case LOGIC_CONDITION_TYPE.L_EVENT_GPIO_FALLING:
            case LOGIC_CONDITION_TYPE.L_EVENT_GPIO_HIGH:
            case LOGIC_CONDITION_TYPE.L_EVENT_GPIO_LOW:
                UpDownCondParam2.Value = CondGpioMask.Value;
                UpDownCondParam1.Value = CondGpioPort.SelectedIndex;
                break;

            case LOGIC_CONDITION_TYPE.L_EVENT_DATE_AFTER:
            case LOGIC_CONDITION_TYPE.L_EVENT_DATE_BEFORE:
                DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime();
                TimeSpan span  = (CondDate.Value - epoch);
                UpDownCondParam1.Value = (decimal)((int)span.TotalSeconds);
                break;

            case LOGIC_CONDITION_TYPE.L_EVENT_DATE_BETWEEN:

                break;

            case LOGIC_CONDITION_TYPE.L_EVENT_TIME_AFTER:
            case LOGIC_CONDITION_TYPE.L_EVENT_TIME_BEFORE:
                UpDownCondParam1.Value = EncodePrimaryTime(CondTime.Value);
                UpDownCondParam2.Value = 0;
                break;

            case LOGIC_CONDITION_TYPE.L_EVENT_TIME_BETWEEN:
                UpDownCondParam1.Value = EncodePrimaryTime(CondTime.Value);
                // Todo : need second set of controls
                UpDownCondParam2.Value = EncodePrimaryTime(CondTime.Value);
                break;

            case LOGIC_CONDITION_TYPE.L_EVENT_ADC_ABOVE:
            case LOGIC_CONDITION_TYPE.L_EVENT_ADC_BELOW:
                UpDownCondParam1.Value = CondAdcPort.SelectedIndex;
                UpDownCondParam2.Value = CondAdcMask.Value;
                break;

            case LOGIC_CONDITION_TYPE.L_EVENT_REG_ABOVE:
            case LOGIC_CONDITION_TYPE.L_EVENT_REG_EQUAL:
            case LOGIC_CONDITION_TYPE.L_EVENT_REG_BELOW:
                UpDownCondParam1.Value = CondRegNo.Value;
                UpDownCondParam2.Value = CondRegVal.Value;
                break;

            default:
                UpDownCondParam1.Value = 0;
                UpDownCondParam2.Value = 0;
                break;
            }

            try
            {
                dataBytes[0] = (byte)CommandNo.SSC_LOGIC_EDT_COND;

                // Indx and Command No
                dataBytes[1] = (byte)Convert.ToByte(LblCondIdx.Text, 10);
                dataBytes[2] = (byte)Convert.ToByte(LblCondNo.Text, 10);

                // 2 Parameters ui32
                Buffer.BlockCopy(BitConverter.GetBytes((UInt32)UpDownCondParam1.Value), 0, dataBytes, 3, 4);
                Buffer.BlockCopy(BitConverter.GetBytes((UInt32)UpDownCondParam2.Value), 0, dataBytes, 7, 4);

                coms.Command(dataBytes, dataBytes.Length, IPAddress.Parse(textBox1.Text));

                ConditionListView.Items[Convert.ToInt32(LblCondIdx.Text)].SubItems[1].Text = LOGIC_CONDITION_NAMES[Convert.ToInt32(LblCondNo.Text)];
                ConditionListView.Items[Convert.ToInt32(LblCondIdx.Text)].SubItems[2].Text = UpDownCondParam1.Value.ToString();
                ConditionListView.Items[Convert.ToInt32(LblCondIdx.Text)].SubItems[3].Text = UpDownCondParam2.Value.ToString();
                ConditionListView.Items[Convert.ToInt32(LblCondIdx.Text)].SubItems[4].Text = LblCondNo.Text;
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 17
0
        private void ButUpdateAction_Click(object sender, EventArgs e)
        {
            SplashBaseComs coms = new SplashBaseComs();

            byte[] dataBytes = new byte[11];

            switch ((LOGIC_ACTION_TYPE)CmbAction.SelectedIndex)
            {
            case LOGIC_ACTION_TYPE.L_ACTION_GPIO_SET:
                UpDownActParam1.Value = ActionGpioPort.SelectedIndex;
                UpDownActParam2.Value = ((UInt32)ActionGpioMask.Value << 16) | (UInt32)ActionGpioValue.Value;
                break;

            case LOGIC_ACTION_TYPE.L_ACTION_DECREMENT_REG:
            case LOGIC_ACTION_TYPE.L_ACTION_INCREMENT_REG:
            case LOGIC_ACTION_TYPE.L_ACTION_CLEAR_REG:
            case LOGIC_ACTION_TYPE.L_ACTION_SET_REG:
                UpDownActParam1.Value = ActionRegNo.Value;
                UpDownActParam2.Value = ActionRegVal.Value;
                break;

            case LOGIC_ACTION_TYPE.L_ACTION_NET_MSG:
                UpDownActParam1.Value = 0xFFFFFFFF;
                UpDownActParam2.Value = 0;
                break;

            case LOGIC_ACTION_TYPE.L_ACTION_CONTROL_RELAY:
                UpDownActParam2.Value = 0;
                if (ActionRelayMask1.Checked)
                {
                    UpDownActParam2.Value += 1;
                }
                if (ActionRelayMask2.Checked)
                {
                    UpDownActParam2.Value += 2;
                }
                if (ActionRelayMask3.Checked)
                {
                    UpDownActParam2.Value += 4;
                }
                if (ActionRelayMask4.Checked)
                {
                    UpDownActParam2.Value += 8;
                }

                UpDownActParam1.Value = 0;
                if (ActionRelay1.Checked)
                {
                    UpDownActParam1.Value += 1;
                }
                if (ActionRelay2.Checked)
                {
                    UpDownActParam1.Value += 2;
                }
                if (ActionRelay3.Checked)
                {
                    UpDownActParam1.Value += 4;
                }
                if (ActionRelay4.Checked)
                {
                    UpDownActParam1.Value += 8;
                }
                break;
            }

            try
            {
                dataBytes[0] = (byte)CommandNo.SSC_LOGIC_EDT_ACT;

                // Indx and Command No
                dataBytes[1] = (byte)Convert.ToByte(LblActionIdx.Text, 10);
                dataBytes[2] = (byte)Convert.ToByte(LblActionNo.Text, 10);

                // 2 Parameters ui32
                Buffer.BlockCopy(BitConverter.GetBytes((UInt32)UpDownActParam1.Value), 0, dataBytes, 3, 4);
                Buffer.BlockCopy(BitConverter.GetBytes((UInt32)UpDownActParam2.Value), 0, dataBytes, 7, 4);

                coms.Command(dataBytes, dataBytes.Length, IPAddress.Parse(textBox1.Text));

                ActionListView.Items[Convert.ToInt32(LblActionIdx.Text)].SubItems[1].Text = LOGIC_ACTION_NAMES[Convert.ToInt32(LblActionNo.Text)];
                ActionListView.Items[Convert.ToInt32(LblActionIdx.Text)].SubItems[2].Text = UpDownActParam1.Value.ToString();
                ActionListView.Items[Convert.ToInt32(LblActionIdx.Text)].SubItems[3].Text = UpDownActParam2.Value.ToString();
                ActionListView.Items[Convert.ToInt32(LblActionIdx.Text)].SubItems[4].Text = LblActionNo.Text;
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 18
0
        private void ButUpdateLogic_Click(object sender, EventArgs e)
        {
            int    logicIndx  = 0;
            int    checkedCnt = 0;
            UInt32 ActionMask = 0;

            byte[]         dataBytes = new byte[9];
            SplashBaseComs coms      = new SplashBaseComs();

            if (ListEvents.SelectedItems.Count > 0)
            {
                try
                {
                    logicIndx = Convert.ToInt32(LblLogicIndx.Text);
                }
                catch (Exception)
                {
                    // Find the next free logic statement
                }

                dataBytes[3] = 0xff;
                dataBytes[4] = 0xff;
                ListEvents.SelectedItems[0].SubItems[1].Text = "None";
                ListEvents.SelectedItems[0].SubItems[4].Text = "255";
                ListEvents.SelectedItems[0].SubItems[2].Text = "None";
                ListEvents.SelectedItems[0].SubItems[5].Text = "255";

                for (int i = 0; i < ConditionListView.Items.Count; i++)
                {
                    if (ConditionListView.Items[i].Checked)
                    {
                        if (checkedCnt == 0)
                        {
                            ListEvents.SelectedItems[0].SubItems[1].Text = ConditionListView.Items[i].SubItems[1].Text;
                            ListEvents.SelectedItems[0].SubItems[4].Text = i.ToString();
                            dataBytes[3] = (byte)i;
                        }
                        else if (checkedCnt == 1)
                        {
                            ListEvents.SelectedItems[0].SubItems[2].Text = ConditionListView.Items[i].SubItems[1].Text;
                            ListEvents.SelectedItems[0].SubItems[5].Text = i.ToString();
                            dataBytes[4] = (byte)i;
                        }
                        checkedCnt++;
                    }
                }

                ActionMask = 0;

                for (int i = 0; i < ConditionListView.Items.Count; i++)
                {
                    if (ActionListView.Items[i].Checked)
                    {
                        ActionMask |= (UInt32)1 << i;
                    }
                }

                // Update Action Mask
                ListEvents.SelectedItems[0].SubItems[3].Text = ActionMask.ToString();

                TabConditionList.SelectedIndex = 0;

                try
                {
                    dataBytes[0] = (byte)CommandNo.SSC_LOGIC_EDT_EVENT;

                    // To follow
                    dataBytes[1] = 1;

                    // Indx
                    dataBytes[2] = (byte)logicIndx;

                    // Condition No's are already set

                    // Action Mask
                    Buffer.BlockCopy(BitConverter.GetBytes(ActionMask), 0, dataBytes, 5, 4);

                    coms.Command(dataBytes, dataBytes.Length, IPAddress.Parse(textBox1.Text));
                }
                catch (Exception)
                {
                }
            }
        }
Exemplo n.º 19
0
        private void ButApply_Click(object sender, EventArgs e)
        {
            byte[]         comsBytes          = new byte[53];
            SplashBaseComs coms               = new SplashBaseComs();
            int            ntpServerStringLen = EdNtpServerAddr.Text.Length;

            byte[]    ntpByteString = System.Text.Encoding.ASCII.GetBytes(EdNtpServerAddr.Text);
            UInt16    ntpOffset;
            IPAddress address;

            comsBytes[0] = (byte)CommandNo.SSC_SET_CONFIG;

            comsBytes[1] = packConfigByte();
            comsBytes[2] = 0;
            comsBytes[3] = 0;

            address = IPAddress.Parse(EdtIpAddr.Text);
            byte[] hostIp = address.GetAddressBytes();
            Buffer.BlockCopy(hostIp, 0, comsBytes, 4, 4);

            /*
             * comsBytes[4] = 0;   // IpAddress
             * comsBytes[5] = 0;   // IpAddress
             * comsBytes[6] = 0;   // IpAddress
             * comsBytes[7] = 0;   // IpAddress
             */

            address = IPAddress.Parse(EdtSubNetAddr.Text);
            byte[] subNetIp = address.GetAddressBytes();
            Buffer.BlockCopy(subNetIp, 0, comsBytes, 8, 4);

            /*
             * comsBytes[8] = 0;   // Subnet
             * comsBytes[9] = 0;   // Subnet
             * comsBytes[10] = 0;  // Subnet
             * comsBytes[11] = 0;  // Subnet
             */

            address = IPAddress.Parse(EdtGatewayAddr.Text);
            byte[] gatewayIp = address.GetAddressBytes();
            Buffer.BlockCopy(gatewayIp, 0, comsBytes, 12, 4);

            /*
             * comsBytes[12] = 0;  // Gateway
             * comsBytes[13] = 0;  // Gateway
             * comsBytes[14] = 0;  // Gateway
             * comsBytes[15] = 0;  // Gateway
             */

            address = IPAddress.Parse(EdtDnsAddr.Text);
            byte[] dnsIp = address.GetAddressBytes();
            Buffer.BlockCopy(dnsIp, 0, comsBytes, 16, 4);

            /*
             * comsBytes[16] = 0;  // Spare
             * comsBytes[17] = 0;  // Spare
             * comsBytes[18] = 0;  // Spare
             * comsBytes[19] = 0;  // Spare
             */

            // Limit String length
            if (ntpServerStringLen > 31)
            {
                ntpServerStringLen = 31;
            }
            Buffer.BlockCopy(ntpByteString, 0, comsBytes, 20, ntpServerStringLen);

            ntpOffset = (UInt16)(EdtNtpOffset.Value * 60);
            Buffer.BlockCopy(BitConverter.GetBytes(ntpOffset), 0, comsBytes, 51, 2);

            try
            {
                // todo : dont use the listview selection?
                coms.Command(comsBytes, comsBytes.Length, IPAddress.Parse(listRemotesFound.SelectedItems[0].SubItems[1].Text));
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Send off a request for SolderBridges connected & IP Address info
        /// </summary>
        private void UpdateSplashBaseInfo(IPAddress ipAddr)
        {
            SplashBaseComs coms = new SplashBaseComs();

            coms.ExtendedPing(ipAddr);
        }