public void cbxStations_SelectedIndexChanged(System.Object sender, System.EventArgs e) { //updating the selected station variable if (cbxStations.SelectedIndex >= 0) { _stationID = Convert.ToInt32(cbxStations.SelectedItem); dc_Station_Sold_Info stationInfo = _JBC_StationControllerService.GetStationInfo(_stationID); if (stationInfo.StationType != dc_EnumConstJBCdc_StationType.SOLD) { cbxStations.SelectedIndex = -1; _stationID = -1; MessageBox.Show(string.Format("Station ID {0} model '{1}' is not a soldering station.", _stationID, stationInfo.Model)); return; } //enable pannels gbxStationData.Enabled = true; gbxStationParams.Enabled = true; //it is necessary to take the control mode to modify the parameters of the station _JBC_StationControllerService.SetControlMode(_stationID, dc_EnumConstJBCdc_ControlModeConnection.CONTROL, Environment.MachineName); } }
/// <summary> /// Search timer handler. Discover stations /// </summary> /// <param name="sender">Objeto que lanza el evento</param> /// <param name="e">Parámetros asociados al evento</param> private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { //buscar stations controllers List <EndpointAddress> endpointsList = m_searcherServices.GetDiscoveredServices(); foreach (EndpointAddress endpoint in endpointsList) { BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); try { JBCStationControllerServiceClient JBC_StationControllerService = new JBCStationControllerServiceClient(binding, endpoint); JBC_StationControllerService.Open(); //notificar de un station controller encontrado if (DiscoveredStationControllerEvent != null) { DiscoveredStationControllerEvent(ref JBC_StationControllerService); } string[] lista = JBC_StationControllerService.GetStationList(); for (var i = 0; i <= lista.Length - 1; i++) { //notificar de una estación encontrada dc_Station_Sold_Info stationInfo = JBC_StationControllerService.GetStationInfo(lista[(int)i]); eStationType stationType = (eStationType)((eStationType)stationInfo.StationType); if (DiscoveredStationEvent != null) { DiscoveredStationEvent(ref JBC_StationControllerService, lista[(int)i], stationType); } } } catch (Exception ex) { //Este error sucede al desconectar un Station Controller ya que se intenta acceder a un Endpoint donde nadie escucha Debug.WriteLine(System.Reflection.MethodInfo.GetCurrentMethod().Name + ". Error: " + ex.Message); } } if (m_isSearching) { m_Timer.Start(); } }