public bool Connect(string comPortName) { if (client == null) { client = new CommunicationProtocolClient(); client.Open(); } return(client.Connect(comPortName)); }
//close Com port connection public void Disconnect() { if (client == null) { client = new CommunicationProtocolClient(); client.Open(); } //close Com port connection client.Disconnect(); }
private void button2_Click(object sender, EventArgs e) { client = new TeslaCommunication.CommunicationProtocolClient(); client.Open(); updateView(); timerAlive = new Timer(); timerAlive.Interval = 100; timerAlive.Tick += TimerAlive_Tick; timerAlive.Start(); button2.Enabled = false; freqChanger1.setEnvoirnment("#1 Несущая", 1, client); }
public Main() { string assemblyLoc = GetType().Assembly.Location; string configName = assemblyLoc + ".config"; AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", configName); try { if (client == null) { client = new CommunicationProtocolClient(); client.Open(); } } catch (Exception ex) { } }
private void buttonService_Click(object sender, RibbonControlEventArgs e) { try { if (client.State == System.ServiceModel.CommunicationState.Faulted) { client = new CommunicationProtocolClient(); } client.Open(); timerAlive = new Timer(); timerAlive.Interval = 500; timerAlive.Tick += TimerAlive_Tick; timerAlive.Start(); } catch (Exception ex) { showMessage(ex.ToString()); } updateView(); }