Пример #1
0
        private void SendSwitchState(string ipAddress, int port, SwitchbankUpdate mySwitchbankUpdate)
        {
            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP = System.Net.IPAddress.Parse(ipAddress);

            myConnection.BravaPort = port;

            BravaSocket mySocket = new BravaSocket(mySwitchbankUpdate, myConnection);

            try
            {
                mySocket.DoTransaction();

                #region Todo: We possibly dont care. Validate and remove
                //if (mySwitchbankUpdate.State == BravaTransaction.TransactionState.Completed)
                //{
                //    mySwitchbankUpdate.State = BravaTransaction.TransactionState.Closed;
                //}

                //if (mySwitchbankUpdate.State == BravaTransaction.TransactionState.Failed)
                //{
                //    throw new System.Net.Sockets.SocketException(10004);
                //}
                #endregion
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP = System.Net.IPAddress.Parse(txtIPAddr.Text);

            myConnection.BravaPort = Int16.Parse(txtIPPort.Text);

            DisplayText myTextDisply = new DisplayText("\0", (byte)numericUpDown1.Value);

            BravaSocket mySocket = new BravaSocket(myTextDisply, myConnection);

            try
            {
                mySocket.OpenConnection();

                mySocket.DoTransaction();

                myConnection.rqStream.Close();
            }
            catch (Exception)
            {
                mySocket.SocketClient.Close();
                throw;
            }
        }
Пример #3
0
        private void SendBatchSwitchState(string ipAddress, int port, string swState, int status)
        {
            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP = System.Net.IPAddress.Parse(ipAddress);

            myConnection.BravaPort = port;

            BravaCodes.SwitchState[] mySwitchStates = new BravaCodes.SwitchState[8];

            SetSwitchStateBatch(swState, status, mySwitchStates);

            SwitchbankUpdate mySwitchbankUpdate = new SwitchbankUpdate(
                mySwitchStates[0],
                mySwitchStates[1],
                mySwitchStates[2],
                mySwitchStates[3],
                mySwitchStates[4],
                mySwitchStates[5],
                mySwitchStates[6],
                mySwitchStates[7]);


            BravaSocket mySocket = new BravaSocket(mySwitchbankUpdate, myConnection);

            try
            {
                mySocket.DoTransaction();
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #4
0
        private void btnSingleConnect_Click(object sender, EventArgs e)
        {
            if (cmbListOfIPAddress.Text != string.Empty)
            {
                BravaConnection myConnection = new BravaConnection();

                myConnection.BravaIP = System.Net.IPAddress.Parse(cmbListOfIPAddress.Text);

                myConnection.BravaPort = (Int16)numDeviceProtocolPortNum.Value;

                RequestType myRequest = new RequestType();

                BravaSocket mySocket = new BravaSocket(myRequest, myConnection);

                try
                {
                    mySocket.OpenConnection();

                    mySocket.DoTransaction();

                    myConnection.rqStream.Close();

                    myRequest.ParseResultStream();

                    MessageBox.Show(myRequest.ResultXML.OuterXml);
                }
                catch (Exception)
                {
                    mySocket.SocketClient.Close();
                    throw;
                }
            }
        }
Пример #5
0
        private void btnReadingRq_Click(object sender, EventArgs e)
        {
            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP = System.Net.IPAddress.Parse(txtIPAddr.Text);

            myConnection.BravaPort = Int16.Parse(txtIPPort.Text);

            RequestReadings myRequest = new RequestReadings();

            BravaSocket mySocket = new BravaSocket(myRequest, myConnection);

            try
            {
                mySocket.OpenConnection();

                mySocket.DoTransaction();

                myConnection.rqStream.Close();

                myRequest.ParseResultStream();

                MessageBox.Show(myRequest.ResultXML.OuterXml);
            }
            catch (Exception)
            {
                mySocket.SocketClient.Close();
                throw;
            }
        }
Пример #6
0
        private void button4_Click(object sender, EventArgs e)
        {
            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP = System.Net.IPAddress.Parse(txtIPAddr.Text);

            myConnection.BravaPort = Int16.Parse(txtIPPort.Text);

            System.Net.IPHostEntry myIPs = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());

            ConfigureAlertMessageRoute myConfigureAlertRouting = new ConfigureAlertMessageRoute((byte)numRouteRuleNum.Value, myIPs.AddressList[0], Int16.Parse(txtAlertPortNum.Text));

            BravaSocket mySocket = new BravaSocket(myConfigureAlertRouting, myConnection);

            try
            {
                mySocket.OpenConnection();

                mySocket.DoTransaction();

                myConnection.rqStream.Close();
            }
            catch (Exception)
            {
                mySocket.SocketClient.Close();
                throw;
            }
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // ポストバック時はリターン
            if (IsPostBack == true)
            {
                return;
            }

            CommonLogic bcom = new CommonLogic();

            try
            {
                Boolean bRet = false;

                ClientScriptManager csManager = Page.ClientScript;
                Type      csType       = this.GetType();
                ArrayList arrayMessage = new ArrayList();

                // Windowsログイン・ユーザマスタチェック
                bRet = bcom.CheckUser();
                if (bRet)
                {
                    arrayMessage.Add(Const.Def.DefMsg_USERERR);
                    bcom.ShowMessage(csType, csManager, arrayMessage);
                    return;
                }

                // ファイルパス取得
                string prm = Request.QueryString.Get(Const.Def.DefPDF_FileNo).Trim().Replace("<>", "\\");
                filePath = System.Web.Configuration.WebConfigurationManager.AppSettings["LinkForder"] + prm;
                string[] strTitle = filePath.Split('\\');
                title = strTitle[strTitle.Length - 1].Trim();

                // ファイル存在チェック
                if (!File.Exists(filePath))
                {
                    arrayMessage.Add(Const.Def.DefMsg_FILE_NOTFOUND);
                    bcom.ShowMessage(csType, csManager, arrayMessage);
                    return;
                }

                // Bravaセッション取得
                BravaConnection conn = Providers.Connection.Create("http://" + System.Web.Configuration.WebConfigurationManager.AppSettings["Brava"]);
                sessionId = conn.GetSessionID();
                Page.DataBind();
            }
            // システムエラー処理(ログ出力、エラー画面遷移)
            catch (Exception ex)
            {
                // システムエラー処理(ログ出力&エラーページ表示)
                bcom.ErrorProcess("frmDetail", "Page_Load", ex, this.Response);
            }
        }
Пример #8
0
        private System.Xml.XmlDocument readMeter(System.Net.IPAddress destIPAdr, Int16 destPortNum)
        {
            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP = destIPAdr;

            myConnection.BravaPort = destPortNum;

            RequestElectricityMeter myRequest = new RequestElectricityMeter();

            BravaSocket mySocket = new BravaSocket(myRequest, myConnection);

            try
            {
                mySocket.OpenConnection();

                mySocket.DoTransaction();


                myConnection.rqStream.Close();



                myRequest.ParseResultStream();


                MessageBox.Show(myRequest.ResultXML.OuterXml);

                return(myRequest.ResultXML);
            }
            catch (System.Net.Sockets.SocketException ex)
            {
                if ((ex.ErrorCode == 10061) || (ex.ErrorCode == 10060))
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                mySocket.SocketClient.Close();
            }

            return(null);
        }
Пример #9
0
        private void SendSwitchState(string ipAddress, int port, string swState, int status)
        {
            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP = System.Net.IPAddress.Parse(ipAddress);

            myConnection.BravaPort = port;

            BravaCodes.SwitchState[] mySwitchStates = new BravaCodes.SwitchState[8];

            SetSwitchState(swState, status, mySwitchStates, "");

            SwitchbankUpdate mySwitchbankUpdate = new SwitchbankUpdate(
                mySwitchStates[0],
                mySwitchStates[1],
                mySwitchStates[2],
                mySwitchStates[3],
                mySwitchStates[4],
                mySwitchStates[5],
                mySwitchStates[6],
                mySwitchStates[7]);

            BravaSocket mySocket = new BravaSocket(mySwitchbankUpdate, myConnection);

            try
            {
                //mySocket.OpenConnection();

                mySocket.DoTransaction();

                if (mySwitchbankUpdate.State == BravaTransaction.TransactionState.Completed)
                {
                    mySwitchbankUpdate.State = BravaTransaction.TransactionState.Closed;
                }

                if (mySwitchbankUpdate.State == BravaTransaction.TransactionState.Failed)
                {
                    throw new System.Net.Sockets.SocketException(10004);
                }
            }
            catch (System.Net.Sockets.SocketException)
            {
                mySocket.SocketClient.Close();

                throw;
            }
            finally
            {
                mySocket.SocketClient.Close();
            }
        }
Пример #10
0
        private System.Xml.XmlDocument readSwitchStateXML(System.Net.IPAddress destIPAdr, Int16 destPortNum)
        {
            RequestStateBlock myRequest    = new RequestStateBlock((byte)BravaCodes.StateBlockRecords.SwitchBankLS8);
            BravaConnection   myConnection = new BravaConnection();
            BravaSocket       mySocket     = new BravaSocket(myRequest, myConnection);

            try
            {
                // Prepare Connection Parameters.
                myConnection.BravaIP   = destIPAdr;
                myConnection.BravaPort = destPortNum;

                // Enact / Transmit the Request.
                mySocket.DoTransaction();

                if (myRequest.State == BravaTransaction.TransactionState.Completed)
                {
                    myRequest.ParseResultStream();
                }

                if (myRequest.State == BravaTransaction.TransactionState.Failed)
                {
                    MessageBox.Show("Transaction Failed.");
                }

                //MessageBox.Show(myRequest.ResultXML.OuterXml);

                return(myRequest.ResultXML);
            }
            catch (System.Net.Sockets.SocketException ex)
            {
                if ((ex.ErrorCode == 10061) || (ex.ErrorCode == 10060) || (ex.ErrorCode == 10065))
                {
                    return(null);
                }
                else
                {
                    throw ex;
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                mySocket.SocketClient.Close();
            }
        }
Пример #11
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP = System.Net.IPAddress.Parse(txtIPAddr.Text);

            myConnection.BravaPort = Int16.Parse(txtIPPort.Text);

            RequestType myRequest = new RequestType();

            BravaSocket mySocket = new BravaSocket(myRequest, myConnection);

            try
            {
                mySocket.DoTransaction();

                if (myRequest.State == BravaTransaction.TransactionState.Completed)
                {
                    myRequest.ParseResultStream();
                }

                if (myRequest.State == BravaTransaction.TransactionState.Failed)
                {
                    MessageBox.Show("Transaction Failed.");
                }
                else
                {
                    // Transaction Result is now valid.
                    MessageBox.Show(myRequest.ResultXML.OuterXml);
                }

                //mySocket.OpenConnection();

                //mySocket.DoTransaction();

                //myConnection.rqStream.Close();

                //myRequest.ParseResultStream();

                //MessageBox.Show(myRequest.ResultXML.OuterXml);
            }
            catch (Exception)
            {
                mySocket.SocketClient.Close();
                throw;
            }
        }
Пример #12
0
        private void btnDisconnectSw_Click(object sender, EventArgs e)
        {
            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP = System.Net.IPAddress.Parse(txtIPAddr.Text);

            myConnection.BravaPort = Int16.Parse(txtIPPort.Text);

            DisconnectSwitch myDisconnectSwitch = new DisconnectSwitch(0, 0, 0);

            if (radioButton1.Checked)
            {
                myDisconnectSwitch = new DisconnectSwitch((byte)BravaCodes.LoadSwitchCircuits.Circuit1, 0, 0);
            }

            if (radioButton2.Checked)
            {
                myDisconnectSwitch = new DisconnectSwitch((byte)BravaCodes.LoadSwitchCircuits.Circuit2, 0, 0);
            }

            if (radioButton3.Checked)
            {
                myDisconnectSwitch = new DisconnectSwitch((byte)BravaCodes.LoadSwitchCircuits.Circuit3, 0, 0);
            }

            if (radioButton4.Checked)
            {
                myDisconnectSwitch = new DisconnectSwitch((byte)BravaCodes.LoadSwitchCircuits.Circuit4, 0, 0);
            }

            BravaSocket mySocket = new BravaSocket(myDisconnectSwitch, myConnection);

            try
            {
                mySocket.OpenConnection();

                mySocket.DoTransaction();

                myConnection.rqStream.Close();
            }
            catch (Exception)
            {
                mySocket.SocketClient.Close();
                throw;
            }
        }
Пример #13
0
        private void SendSwitchState(string ipAddress, int port, SwitchbankUpdate mySwitchbankUpdate)
        {
            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP = System.Net.IPAddress.Parse(ipAddress);

            myConnection.BravaPort = port;


            BravaSocket mySocket = new BravaSocket(mySwitchbankUpdate, myConnection);

            try
            {
                mySocket.DoTransaction();

                if (mySwitchbankUpdate.State == BravaTransaction.TransactionState.Completed)
                {
                    mySwitchbankUpdate.State = BravaTransaction.TransactionState.Closed;
                }

                if (mySwitchbankUpdate.State == BravaTransaction.TransactionState.Failed)
                {
                    throw new System.Net.Sockets.SocketException(10004);
                }
            }
            catch (System.Net.Sockets.SocketException)
            {
                mySocket.SocketClient.Close();

                throw;
            }
            finally
            {
                mySocket.SocketClient.Close();
            }
        }
Пример #14
0
        private void sendSwitchStateCommand(System.Net.IPAddress destIPAdr, Int16 destPortNum,
                                            bool swState1, bool swState2, bool swState3, bool swState4,
                                            bool swState5, bool swState6, bool swState7, bool swState8)
        {
            BravaCodes.SwitchState[] mySwitchStates = new BravaCodes.SwitchState[8];

            for (int x = 0; x <= 7; x++)
            {
                mySwitchStates[x] = BravaCodes.SwitchState.SwitchOff;
            }

            if (swState1)
            {
                mySwitchStates[0] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState2)
            {
                mySwitchStates[1] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState3) // cbSingleSw3.Checked)
            {
                mySwitchStates[2] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState4) // cbSingleSw4.Checked)
            {
                mySwitchStates[3] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState5) // cbSingleSw5.Checked)
            {
                mySwitchStates[4] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState6) // cbSingleSw6.Checked)
            {
                mySwitchStates[5] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState7) // cbSingleSw7.Checked)
            {
                mySwitchStates[6] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState8) // cbSingleSw8.Checked)
            {
                mySwitchStates[7] = BravaCodes.SwitchState.SwitchOn;
            }

            SwitchbankUpdate mySwitchbankUpdate = new SwitchbankUpdate(
                mySwitchStates[0],
                mySwitchStates[1],
                mySwitchStates[2],
                mySwitchStates[3],
                mySwitchStates[4],
                mySwitchStates[5],
                mySwitchStates[6],
                mySwitchStates[7]);

            // RequestStateBlock myReadBackVerify = new RequestStateBlock((byte)BravaCodes.StateBlockRecords.SwitchBankLS8);

            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP   = destIPAdr;
            myConnection.BravaPort = destPortNum;

            BravaSocket mySocket = new BravaSocket(mySwitchbankUpdate, myConnection);

            try
            {
                mySocket.DoTransaction();

                if (mySwitchbankUpdate.State == BravaTransaction.TransactionState.Completed)
                {
                    mySwitchbankUpdate.State = BravaTransaction.TransactionState.Closed;

                    //mySocket.Transaction = myReadBackVerify;

                    //mySocket.DoTransaction();

                    //if (myReadBackVerify.State == BravaTransaction.TransactionState.Completed)
                    //{
                    //    BravaCodes.SwitchState[] readbackStates = new BravaCodes.SwitchState[8];
                    //    readbackStates = myReadBackVerify.ParseSwitchStates(8);
                    //    // TODO: Utility function to extract the switch state from the StateBlock
                    //    if (myReadBackVerify.State == BravaTransaction.TransactionState.Closed)
                    //    {
                    //        if (mySwitchStates == readbackStates)
                    //        {
                    //            MessageBox.Show("ReadBack value differs from Set Value");

                    //        }
                    //    }

                    //}
                    //else
                    //{
                    //    MessageBox.Show("ReadBackVerify Failed.");
                    //}
                }
                else
                {
                    MessageBox.Show("SwitchBankUpdate Failed.");
                }
            }
            catch (Exception)
            {
                mySocket.SocketClient.Close();
                throw;
            }
        }
Пример #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // ポストバック時はリターン
            if (IsPostBack == true)
            {
                return;
            }

            CommonLogic bcom = new CommonLogic();

            try
            {
                Boolean bRet = false;
                // パラメータ取得
                // HelpSerch:過去トラ検索用Helpファイル
                var fileKbn = "";
                fileKbn = Request.QueryString.Get("VIEWFILE_KBN").Trim();

                if (filePath == "" || filePath == null)
                {
                    bRet = true;
                }

                ClientScriptManager csManager = Page.ClientScript;
                Type      csType       = this.GetType();
                ArrayList arrayMessage = new ArrayList();

                // Windowsログイン・ユーザマスタチェック
                bRet = bcom.CheckUser();
                if (bRet)
                {
                    arrayMessage.Add(Def.DefMsg_USERERR);
                    bcom.ShowMessage(csType, csManager, arrayMessage);
                    return;
                }

                // ファイルパス取得
                switch (fileKbn)
                {
                case "HelpSerch":
                    filePath = System.Web.Configuration.WebConfigurationManager.AppSettings["HelpSerch"];
                    break;

                case "HelpFollow":
                    filePath = System.Web.Configuration.WebConfigurationManager.AppSettings["HelpFollow"];
                    break;

                // 2017.04.03 ta_kanda 追加 Start
                case "HelpTop":
                    filePath = System.Web.Configuration.WebConfigurationManager.AppSettings["HelpTop"];
                    break;

                case "QaTop":
                    filePath = System.Web.Configuration.WebConfigurationManager.AppSettings["QaTop"];
                    break;

                // 2017.04.03 ta_kanda 追加 End
                // 2017.04.04 ta_kanda 追加 Start
                case "QaSerch":
                    filePath = System.Web.Configuration.WebConfigurationManager.AppSettings["QaSerch"];
                    break;

                case "QaFollow":
                    filePath = System.Web.Configuration.WebConfigurationManager.AppSettings["QaFollow"];
                    break;
                    // 2017.04.04 ta_kanda 追加 End
                }

                string[] strTitle = filePath.Split('/');
                title = strTitle[strTitle.Length - 1].Trim();

                // ファイル存在チェック
                if (!File.Exists(filePath))
                {
                    arrayMessage.Add(Def.DefMsg_FILE_NOTFOUND);
                    bcom.ShowMessage(csType, csManager, arrayMessage);
                    return;
                }

                // Bravaセッション取得
                BravaConnection conn = Providers.Connection.Create("http://" + System.Web.Configuration.WebConfigurationManager.AppSettings["Brava"]);
                sessionId = conn.GetSessionID();
                Page.DataBind();
            }
            // システムエラー処理(ログ出力、エラー画面遷移)
            catch (Exception ex)
            {
                // システムエラー処理(ログ出力&エラーページ表示)
                bcom.ErrorProcess("frmClientView", "Page_Load", ex, this.Response);
            }
        }
Пример #16
0
        private void SendSwitchState(string ipAddress, string unitName, int port, BravaCodes.SwitchState[] mySwitchStates)
        {
            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP = System.Net.IPAddress.Parse(ipAddress);

            myConnection.BravaPort = port;

            SwitchbankUpdate mySwitchbankUpdate = new SwitchbankUpdate(
                mySwitchStates[0],
                mySwitchStates[1],
                mySwitchStates[2],
                mySwitchStates[3],
                mySwitchStates[4],
                mySwitchStates[5],
                mySwitchStates[6],
                mySwitchStates[7]);

            BravaSocket mySocket = new BravaSocket(mySwitchbankUpdate, myConnection);

            try
            {
                mySocket.DoTransaction();

                if (mySwitchbankUpdate.State == BravaTransaction.TransactionState.Completed)
                {
                    mySwitchbankUpdate.State = BravaTransaction.TransactionState.Closed;

                    lfa.pmgmt.data.DAO.Logging.CurrentStatus currentStatusDAO = new data.DAO.Logging.CurrentStatus();
                    currentStatusDAO.ConnectionString = _connectionString;
                    currentStatusDAO.Insert(unitName, "OK");
                }

                if (mySwitchbankUpdate.State == BravaTransaction.TransactionState.Failed)
                {
                    lfa.pmgmt.data.DAO.Logging.Log logDAO = new data.DAO.Logging.Log();
                    logDAO.ConnectionString = _connectionString;
                    logDAO.Insert(1, "Unit: " + unitName, "TCP/IP Communications Error due to: BRAVA API or Connection error.", DateTime.Now);

                    lfa.pmgmt.data.DAO.Logging.CurrentStatus currentStatusDAO = new data.DAO.Logging.CurrentStatus();
                    currentStatusDAO.ConnectionString = _connectionString;
                    currentStatusDAO.Insert(unitName, "ERR");
                }
            }
            catch (System.Net.Sockets.SocketException ex)
            {
                lfa.pmgmt.data.DAO.Logging.Log logDAO = new data.DAO.Logging.Log();
                logDAO.ConnectionString = _connectionString;
                logDAO.Insert(1, "Unit: " + unitName, "TCP/IP Communications Error due to: " + ex.ToString(), DateTime.Now);

                lfa.pmgmt.data.DAO.Logging.CurrentStatus currentStatusDAO = new data.DAO.Logging.CurrentStatus();
                currentStatusDAO.ConnectionString = _connectionString;
                currentStatusDAO.Insert(unitName, "ERR");
            }
            catch (Exception nex)
            {
                HandleException(nex);
            }
            finally
            {
                mySocket.SocketClient.Close();
            }
        }
Пример #17
0
        private void sendSwitchStateCommand(System.Net.IPAddress destIPAdr, Int16 destPortNum,
                                            bool swState1, bool swState2, bool swState3, bool swState4,
                                            bool swState5, bool swState6, bool swState7, bool swState8)
        {
            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP = destIPAdr;

            myConnection.BravaPort = destPortNum;

            BravaCodes.SwitchState[] mySwitchStates = new BravaCodes.SwitchState[8];

            for (int x = 0; x <= 7; x++)
            {
                mySwitchStates[x] = BravaCodes.SwitchState.SwitchOff;
            }

            if (swState1)
            {
                mySwitchStates[0] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState2)
            {
                mySwitchStates[1] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState3) // cbSingleSw3.Checked)
            {
                mySwitchStates[2] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState4) // cbSingleSw4.Checked)
            {
                mySwitchStates[3] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState5) // cbSingleSw5.Checked)
            {
                mySwitchStates[4] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState6) // cbSingleSw6.Checked)
            {
                mySwitchStates[5] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState7) // cbSingleSw7.Checked)
            {
                mySwitchStates[6] = BravaCodes.SwitchState.SwitchOn;
            }
            if (swState8) // cbSingleSw8.Checked)
            {
                mySwitchStates[7] = BravaCodes.SwitchState.SwitchOn;
            }

            SwitchbankUpdate mySwitchbankUpdate = new SwitchbankUpdate(
                mySwitchStates[0],
                mySwitchStates[1],
                mySwitchStates[2],
                mySwitchStates[3],
                mySwitchStates[4],
                mySwitchStates[5],
                mySwitchStates[6],
                mySwitchStates[7]);

            BravaSocket mySocket = new BravaSocket(mySwitchbankUpdate, myConnection);

            try
            {
                mySocket.OpenConnection();

                mySocket.DoTransaction();

                myConnection.rqStream.Close();
            }
            catch (Exception)
            {
                mySocket.SocketClient.Close();
                throw;
            }
        }
Пример #18
0
        private void button3_Click(object sender, EventArgs e)
        {
            BravaConnection myConnection = new BravaConnection();

            myConnection.BravaIP = System.Net.IPAddress.Parse(txtIPAddr.Text);

            myConnection.BravaPort = Int16.Parse(txtIPPort.Text);

            BravaCodes.SwitchState[] mySwitchStates = new BravaCodes.SwitchState[8];

            for (int x = 0; x <= 7; x++)
            {
                mySwitchStates[x] = BravaCodes.SwitchState.SwitchOff;
            }

            if (checkBox1.Checked)
            {
                mySwitchStates[0] = BravaCodes.SwitchState.SwitchOn;
            }
            if (checkBox2.Checked)
            {
                mySwitchStates[1] = BravaCodes.SwitchState.SwitchOn;
            }
            if (checkBox3.Checked)
            {
                mySwitchStates[2] = BravaCodes.SwitchState.SwitchOn;
            }
            if (checkBox4.Checked)
            {
                mySwitchStates[3] = BravaCodes.SwitchState.SwitchOn;
            }
            if (checkBox5.Checked)
            {
                mySwitchStates[4] = BravaCodes.SwitchState.SwitchOn;
            }
            if (checkBox6.Checked)
            {
                mySwitchStates[5] = BravaCodes.SwitchState.SwitchOn;
            }
            if (checkBox7.Checked)
            {
                mySwitchStates[6] = BravaCodes.SwitchState.SwitchOn;
            }
            if (checkBox8.Checked)
            {
                mySwitchStates[7] = BravaCodes.SwitchState.SwitchOn;
            }

            SwitchbankUpdate mySwitchbankUpdate = new SwitchbankUpdate(
                mySwitchStates[0],
                mySwitchStates[1],
                mySwitchStates[2],
                mySwitchStates[3],
                mySwitchStates[4],
                mySwitchStates[5],
                mySwitchStates[6],
                mySwitchStates[7]);

            BravaSocket mySocket = new BravaSocket(mySwitchbankUpdate, myConnection);

            try
            {
                mySocket.OpenConnection();

                mySocket.DoTransaction();

                myConnection.rqStream.Close();
            }
            catch (Exception)
            {
                mySocket.SocketClient.Close();
                throw;
            }
        }