Beispiel #1
0
        public CStation_HA(string UUID,
                           JBC_API_Remote APIreference,
                           ref JBCStationControllerServiceClient hostService)
        {
            myAPI         = APIreference;
            myUUID        = UUID;
            remoteAddress = hostService.Endpoint.Address;

            //myServiceProtocol = _ServiceProtocol
            //_ServiceProtocol
            if (EnumProtocol.Protocol_01 == EnumProtocol.Protocol_01)
            {
                stack = new Remote_StackHA_01(ref hostService, UUID);
                stack.ConnectError          += stack_ConnectError;
                stack.ReceivedInfoContiMode += stack_ReceivedInfoContiMode;
                ((Remote_StackHA_01)stack).StartStack();  // 26/11/2015
            }
            else
            {
                stack = new Remote_StackHA_01(ref hostService, UUID);
                stack.ConnectError          += stack_ConnectError;
                stack.ReceivedInfoContiMode += stack_ReceivedInfoContiMode;
                ((Remote_StackHA_01)stack).StartStack();  // 26/11/2015
            }
        }
Beispiel #2
0
        public CStation_SF(string UUID, JBC_API_Remote APIreference, ref JBCStationControllerServiceClient hostService)
        {
            myAPI         = APIreference;
            myUUID        = UUID;
            remoteAddress = hostService.Endpoint.Address;

            stack = new Remote_StackSF(ref hostService, UUID);
            stack.ConnectError += stack_ConnectError;
            stack.StartStack();
        }
Beispiel #3
0
    public void butConnect_Click(object sender, EventArgs e)
    {
        //clear station list
        cbxStations.Items.Clear();
        cbxStations.SelectedIndex = -1;
        _stationID = -1;

        //disable pannels
        gbxStationData.Enabled   = false;
        gbxStationParams.Enabled = false;
        gbxPort1.Enabled         = false;
        gbxPort2.Enabled         = false;
        gbxPort3.Enabled         = false;
        gbxPort4.Enabled         = false;

        //connect to service
        if (ReferenceEquals(_JBC_StationControllerService, null))
        {
            try
            {
                BasicHttpBinding binding  = new BasicHttpBinding(BasicHttpSecurityMode.None);
                EndpointAddress  endpoint = new EndpointAddress(txtStationControllerURL.Text);
                _JBC_StationControllerService = new JBCStationControllerServiceClient(binding, endpoint);

                //update station controller status
                lblConnectStatus.Text = "Connected";
                butConnect.Text       = "Disconnect";

                //update station list
                foreach (long stationID in _JBC_StationControllerService.GetStationList())
                {
                    cbxStations.Items.Add(stationID);
                }
            }
            catch (Exception)
            {
                _JBC_StationControllerService = null;

                //update station controller status
                lblConnectStatus.Text = "Error connecting";
                butConnect.Text       = "Connect";
            }

            //disconnect from service
        }
        else
        {
            _JBC_StationControllerService.Close();
            _JBC_StationControllerService = null;

            //update station controller status
            lblConnectStatus.Text = "Disconnected";
            butConnect.Text       = "Connect";
        }
    }
Beispiel #4
0
        /// <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();
            }
        }
        internal object ServiceStackJBC01_Lock = new object(); // Variable compartida para bloquear funciones e impedir reentradas


        #region METODOS PUBLICOS

        public Remote_StackSold_01(ref JBCStationControllerServiceClient hostService, string hostStnUUID)
        {
            ServiceProtocol          = CStation.EnumProtocol.Protocol_01;
            TimerManagement          = new System.Timers.Timer();
            TimerManagement.Elapsed += TimerStatus_Tick;
            TimerManagement.Elapsed += TimerStatus_Tick;

            // Se paran los timer por si acaso hasta que se optenga la conexión correcta
            TimerManagement.Interval  = TIMER_STATUS_TIME;
            TimerManagement.AutoReset = false; // se debe activar de nuevo al salir del evento Elapsed
            TimerManagement.Stop();
            // Se crea la instancia de la clase Station
            Info_Station = new CStationData_SOLD();

            // Se guarda el servicio y el ID de estación del host
            SaveHostService(hostService, hostStnUUID);

            //Await LoadInitStationInfoAsync()
            //Ejecutar sin Async porque no puedo especificar Await
            LoadInitStationInfo();
        }
Beispiel #6
0
 /// <summary>
 /// Guarda el servicio y el ID de la estación del host
 /// </summary>
 /// <remarks></remarks>
 internal new void SaveHostService(JBCStationControllerServiceClient hostService, string hostStnUUID)
 {
     // Guarda el número de dispositivo dentro del protocolo
     m_hostStnUUID = hostStnUUID;
     m_hostService = hostService;
 }