Ejemplo n.º 1
0
 private void m_AddSerialButton_Click(object sender, EventArgs e)
 {
     try
     {
         int com_number = 0;
         if (m_SerialPortCombo.Text.Length >= 3)
         {
             int.TryParse(m_SerialPortCombo.Text.Substring(3), out com_number);
         }
         BacnetMstpProtocolTransport transport;
         if (com_number >= 1000)      //these are my special "pipe" com ports
         {
             transport = new BacnetMstpProtocolTransport(new BacnetPipeTransport(m_SerialPortCombo.Text), (short)m_SourceAddressValue.Value, (byte)m_MaxMasterValue.Value, (byte)m_MaxInfoFramesValue.Value);
         }
         else
         {
             transport = new BacnetMstpProtocolTransport(m_SerialPortCombo.Text, (int)m_BaudValue.Value, (short)m_SourceAddressValue.Value, (byte)m_MaxMasterValue.Value, (byte)m_MaxInfoFramesValue.Value);
         }
         transport.StateLogging = Properties.Settings.Default.MSTP_LogStateMachine;
         m_result          = new BacnetClient(transport, (int)m_TimeoutValue.Value, (int)m_RetriesValue.Value);
         this.DialogResult = System.Windows.Forms.DialogResult.OK;
         this.Close();
     }
     catch { }
 }
        // Serial Transport Listener start
        private void buttonGo_Click(object sender, EventArgs e)
        {
            try
            {
                int com_number = 0;
                if (comboPort.Text.Length >= 3)
                {
                    int.TryParse(comboPort.Text.Substring(3), out com_number);
                }
                if (com_number >= 1000)      // these are Morten's special "pipe" com ports
                {
                    Serial = new BacnetMstpProtocolTransport(new BacnetPipeTransport(comboPort.Text), -1);
                }
                else
                {
                    Serial = new BacnetMstpProtocolTransport(comboPort.Text, Convert.ToInt32(comboSpeed.Text), -1);
                }

                Serial.RawMessageRecieved += new BacnetMstpProtocolTransport.RawMessageReceivedHandler(Serial_RawMessageRecieved);

                Serial.Start_SpyMode();

                buttonGo.Enabled = false;
            }
            catch { }
        }