public DataCollector(SenderIOT S_Iot ) { DP = new DataProcessor(S_Iot); }
public DataProcessor(SenderIOT S_Iot) { this.S_Iot = S_Iot; }
private void button3_Click(object sender, EventArgs e) { bool CheckedIpandPort = false; if (CheckIPValid(tb_IPAddress.Text.ToString())) { try { int port = Convert.ToInt32(this.tb_PortAddress.Text); if (port > 65535) { MessageBox.Show(" Entered port address is not valid "); } else { CheckedIpandPort = true; } } catch (Exception) { MessageBox.Show(" Please fill port address text box "); } if( CheckedIpandPort) { //this is where the correct ip and port is entered //data collector initialized with the SenderIOT S_Iot = new SenderIOT(tb_IPAddress.Text.ToString(), Convert.ToInt32(this.tb_PortAddress.Text)); //subscribe to the event data sent S_Iot.Data_Sent += new SenderIOT.DataSent(S_IoT_Data_Sent); S_Iot.Connection_Fail += new SenderIOT.ConnectionFail(S_Iot_Connection_Fail); if (S_Iot.IsConnected()) { rtb_DataLog.AppendText(TimeStamp() + "Uploading data successfully enabled IP ADDRESS : " + tb_IPAddress.Text.ToString() + " with PORT : " + tb_PortAddress.Text.ToString() + "\n"); DC = new DataCollector(S_Iot); DC.Init(1000); bt_Stop.Enabled = true; bt_Run.Enabled = false; tb_IPAddress.Enabled = false; tb_PortAddress.Enabled = false; sendDataEnable = true; } else { MessageBox.Show("Connection to the MQTT is not established please try again "); } } } else { MessageBox.Show(" Entered ip address is not valid "); } }