Esempio n. 1
0
        public void GetContinuousModeNextData_HA()
        {
            uint queue_id = jbc_api.StartContinuousMode(station_id);

            int count = jbc_api.GetContinuousModeDataCount(station_id, queue_id);

            stContinuousModeData_HA data = jbc_api.GetContinuousModeNextData_HA(station_id, queue_id);

            Debug.WriteLine("STATION ID:" + station_id + " DATA: " + data.data);

            jbc_api.StopContinuousMode(station_id, queue_id);
        }
Esempio n. 2
0
 public stContinuousModeData_HA GetContinuousModeNextData(uint queueID)
 {
     // get local data
     if (GetContinuousModeDataCount(queueID) > 0)
     {
         //Dim data As JBC_API_Remote.tContinuousModeData_HA = dataList(0)
         //dataList.RemoveAt(0)
         stContinuousModeData_HA data = traceList.Queue(queueID).GetData();
         return(data);
     }
     else
     {
         return(new stContinuousModeData_HA());
     }
 }
Esempio n. 3
0
        //Private functions
        private async System.Threading.Tasks.Task <bool> updatePortsAsync()
        {
            try
            {
                await jbc.UpdateContinuousModeNextDataChunkAsync((long)ID, uiContModeQueueID, 50);

                // Initializing the ports magnitudes to 0 to calculate the median
                //Debug.Print("DATA: " & JBC.GetContinuousModeDataCount(ID))
                if (jbc.GetContinuousModeDataCount((long)ID, uiContModeQueueID) > 0)
                {
                    for (int cnt = 0; cnt <= MAX_PORTS - 1; cnt++)
                    {
                        portList[cnt].P = 0;
                        portList[cnt].F = 0;

                        // Displacement of the temperature values in the filter
                        for (int i = 0; i <= TEMP_FILTER_SIZE - 1 - 1; i++)
                        {
                            portList[cnt].T[i] = portList[cnt].T[i + 1];
                        }
                        portList[cnt].T[TEMP_FILTER_SIZE - 1] = 0;
                        //portList(cnt).nTrans = 0
                    }
                }

                // Getting all the transmisions from the station and calculating the median temperature and power. Power units are in per thousand and
                // is necessary to pass them into per hundred
                int transmisionCounter = 0;

                stContinuousModeData_SOLD ports    = new stContinuousModeData_SOLD();
                stContinuousModeData_HA   ports_HA = new stContinuousModeData_HA(); // hadesold
                while (jbc.GetContinuousModeDataCount((long)ID, uiContModeQueueID) > 0)
                {
                    // sold
                    if (StationType == eStationType.SOLD)
                    {
                        ports = jbc.GetContinuousModeNextData((long)ID, uiContModeQueueID);
                        if (ports.data != null)
                        {
                            foreach (stContinuousModePort_SOLD dt in ports.data)
                            {
                                // portList(dt.port).T(TEMP_FILTER_SIZE - 1) = portList(dt.port).T(TEMP_FILTER_SIZE - 1) + dt.temperature.ToCelsius
                                // get data in UTI
                                portList[(int)dt.port].T[TEMP_FILTER_SIZE - 1] = portList[(int)dt.port].T[TEMP_FILTER_SIZE - 1] + dt.temperature.UTI;
                                //If dt.temperature.ToCelsius <> 0 Then portList(dt.port).nTrans = portList(dt.port).nTrans + 1
                                portList[(int)dt.port].I = 0;
                                portList[(int)dt.port].P = System.Convert.ToInt32(portList[(int)dt.port].P + dt.power);
                            }
                            transmisionCounter++;
                        }
                    }
                    // hadesold
                    if (StationType == eStationType.HA)
                    {
                        ports_HA = jbc.GetContinuousModeNextData_HA((long)ID, uiContModeQueueID);
                        if (ports_HA.data != null)
                        {
                            foreach (stContinuousModePort_HA dt in ports_HA.data)
                            {
                                // portList(dt.port).T(TEMP_FILTER_SIZE - 1) = portList(dt.port).T(TEMP_FILTER_SIZE - 1) + dt.temperature.ToCelsius
                                // get data in UTI
                                portList[(int)dt.port].T[TEMP_FILTER_SIZE - 1] = portList[(int)dt.port].T[TEMP_FILTER_SIZE - 1] + dt.temperature.UTI;
                                //If dt.temperature.ToCelsius <> 0 Then portList(dt.port).nTrans = portList(dt.port).nTrans + 1
                                portList[(int)dt.port].I = 0;
                                portList[(int)dt.port].P = System.Convert.ToInt32(portList[(int)dt.port].P + dt.power);
                                portList[(int)dt.port].F = System.Convert.ToInt32(portList[(int)dt.port].F + dt.flow);
                            }
                            transmisionCounter++;
                        }
                    }
                }

                if (transmisionCounter > 0)
                {
                    if (StationType == eStationType.SOLD)
                    {
                        foreach (stContinuousModePort_SOLD dt in ports.data)
                        {
                            portList[(int)dt.port].number = dt.port + 1;
                            portList[(int)dt.port].status = dt.status;
                            //If portList(dt.port).nTrans <> 0 Then portList(dt.port).T(TEMP_FILTER_SIZE - 1) = portList(dt.port).T(TEMP_FILTER_SIZE - 1) / portList(dt.port).nTrans
                            portList[(int)dt.port].T[TEMP_FILTER_SIZE - 1] = portList[(int)dt.port].T[TEMP_FILTER_SIZE - 1] / transmisionCounter;
                            portList[(int)dt.port].P = System.Convert.ToInt32(((double)portList[(int)dt.port].P / 10) / transmisionCounter);
                            portList[(int)dt.port].I = 0;
                        }
                    }
                    if (StationType == eStationType.HA)
                    {
                        foreach (stContinuousModePort_HA dt in ports_HA.data)
                        {
                            portList[(int)dt.port].number = dt.port + 1;
                            portList[(int)dt.port].status = (ToolStatus)dt.status;
                            //If portList(dt.port).nTrans <> 0 Then portList(dt.port).T(TEMP_FILTER_SIZE - 1) = portList(dt.port).T(TEMP_FILTER_SIZE - 1) / portList(dt.port).nTrans
                            portList[(int)dt.port].T[TEMP_FILTER_SIZE - 1] = portList[(int)dt.port].T[TEMP_FILTER_SIZE - 1] / transmisionCounter;
                            portList[(int)dt.port].P = System.Convert.ToInt32(((double)portList[(int)dt.port].P / 10) / transmisionCounter);
                            portList[(int)dt.port].F = System.Convert.ToInt32(((double)portList[(int)dt.port].F / 10) / transmisionCounter); // hadesold
                            portList[(int)dt.port].I = 0;
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cstation::updatePorts . error:" + ex.Message);
                return(false);
            }
        }
Esempio n. 4
0
        private void TraceData()
        {
            ArrayList listStationsUUID = new ArrayList();
            stContinuousModeData_SOLD contData_SOLD   = default(stContinuousModeData_SOLD);  // solder data
            stContinuousModeData_HA   contData_HA     = new stContinuousModeData_HA();       // hot air data
            stContinuousModePort_SOLD contDataPort    = new stContinuousModePort_SOLD();     // solder data
            stContinuousModePort_HA   contDataPort_HA = new stContinuousModePort_HA();       // hot air data

            while (m_IsAliveThreadTraceData)
            {
                // update stations list
                listStationsUUID.Clear();
                listStationsUUID.AddRange(m_htStationUUID2QueueID.Keys);

                //Iteramos en todas las estaciones
                foreach (string stationUUID in listStationsUUID)
                {
                    uint queueID = (uint)(m_htStationUUID2QueueID[stationUUID]);

                    try
                    {
                        if (DLLConnection.jbc.StationExists(stationUUID))
                        {
                            eStationType stationType = DLLConnection.jbc.GetStationType(stationUUID);
                            int          dataLength  = DLLConnection.jbc.GetContinuousModeDataCount(stationUUID, queueID);

                            //Iteramos en todos los datos recogidos
                            for (int i = 0; i <= dataLength - 1; i++)
                            {
                                bool bDataExists = false;
                                switch (stationType)
                                {
                                case eStationType.SOLD:
                                    contData_SOLD = DLLConnection.jbc.GetContinuousModeNextData_SOLD(stationUUID, queueID);
                                    if (contData_SOLD.data != null)
                                    {
                                        bDataExists = true;
                                    }
                                    break;

                                case eStationType.HA:
                                    contData_HA = DLLConnection.jbc.GetContinuousModeNextData_HA(stationUUID, queueID);
                                    if (contData_HA.data != null)
                                    {
                                        bDataExists = true;
                                    }
                                    break;
                                }

                                if (bDataExists)
                                {
                                    Hashtable portJSONData = new Hashtable();

                                    foreach (Port port in m_mdhtStationUUID2PortData.RowKeys(stationUUID))
                                    {
                                        portJSONData[port] = "";

                                        //Cabecera de datos si secuencia es cero
                                        if (System.Convert.ToInt32(m_mdhtStationUUID2PortNumSequence.Item(stationUUID, port)) == 0)
                                        {
                                            // obtener la velocidad de la cola
                                            SpeedContinuousMode queueCaptureSpeed = DLLConnection.jbc.GetContinuousModeDeliverySpeed(stationUUID, queueID);
                                            CSpeedContMode      speedcm           = new CSpeedContMode();
                                            int frequency = speedcm.SpeedFromEnum(queueCaptureSpeed);

                                            portJSONData[port] = "{" + "\r\n" + "\"uuid\":\"" + stationUUID + "\"," +
                                                                 "\r\n" + "\"port\":" + System.Convert.ToString(port) + "," +
                                                                 "\r\n" + "\"time\":\"" + DateTime.Now.ToString(TRACE_TIME_FORMAT) + "\"," +
                                                                 "\r\n" + "\"name\":\"" + DLLConnection.jbc.GetStationName(stationUUID) + "\"," +
                                                                 "\r\n" + "\"type\":\"" + stationType.ToString() + "\"," +
                                                                 "\r\n" + "\"model\":\"" + DLLConnection.jbc.GetStationModel(stationUUID) + "\"," +
                                                                 "\r\n" + "\"modeltype\":\"" + DLLConnection.jbc.GetStationModelType(stationUUID) + "\"," +
                                                                 "\r\n" + "\"modelversion\":\"" + DLLConnection.jbc.GetStationModelVersion(stationUUID).ToString() + "\"," +
                                                                 "\r\n" + "\"software\":\"" + DLLConnection.jbc.GetStationSWversion(stationUUID) + "\"," +
                                                                 "\r\n" + "\"hardware\":\"" + DLLConnection.jbc.GetStationHWversion(stationUUID) + "\"," +
                                                                 "\r\n" + "\"interval\":" + System.Convert.ToString(frequency) + "," +
                                                                 "\r\n" + "\"data\":[";
                                        }
                                    }

                                    // cantidad de puertos
                                    int iDataPortCount = 0;
                                    switch (stationType)
                                    {
                                    case eStationType.SOLD:
                                        iDataPortCount = contData_SOLD.data.Length;
                                        break;

                                    case eStationType.HA:
                                        iDataPortCount = contData_HA.data.Length;
                                        break;
                                    }

                                    // datos de los puertos
                                    for (var x = 0; x <= iDataPortCount - 1; x++)
                                    {
                                        Port readingPort = Port.NO_PORT;

                                        switch (stationType)
                                        {
                                        case eStationType.SOLD:
                                            contDataPort = contData_SOLD.data[x];
                                            readingPort  = contDataPort.port;
                                            break;

                                        case eStationType.HA:
                                            contDataPort_HA = contData_HA.data[x];
                                            readingPort     = contDataPort_HA.port;
                                            break;
                                        }

                                        //Copiamos los datos del registro anterior para comparar al crear el json
                                        Hashtable antListPortData = new Hashtable();

                                        foreach (Port port in m_mdhtStationUUID2PortData.RowKeys(stationUUID))
                                        {
                                            antListPortData.Add(port, ((TracePortData)(m_mdhtStationUUID2PortData.Item(stationUUID, port))).Clone());
                                        }

                                        //Si el puerto lo estamos trazando
                                        if (m_mdhtStationUUID2PortData.Contains(stationUUID, readingPort))
                                        {
                                            TracePortData portData = default(TracePortData);

                                            switch (stationType)
                                            {
                                            case eStationType.SOLD:
                                                portData             = (TracePortData)(m_mdhtStationUUID2PortData.Item(stationUUID, readingPort));
                                                portData.port        = readingPort;
                                                portData.temperature = System.Convert.ToInt32(contDataPort.temperature.UTI);
                                                portData.power       = System.Convert.ToInt32(contDataPort.power);
                                                portData.status      = System.Convert.ToByte(contDataPort.status);
                                                portData.tool        = DLLConnection.jbc.GetPortToolID(stationUUID, portData.port);
                                                break;

                                            case eStationType.HA:
                                                portData             = (TracePortData)(m_mdhtStationUUID2PortData.Item(stationUUID, readingPort));
                                                portData.port        = readingPort;
                                                portData.temperature = contDataPort_HA.temperature.UTI;
                                                portData.power       = contDataPort_HA.power;
                                                portData.status      = System.Convert.ToByte(contDataPort_HA.status);
                                                portData.tool        = DLLConnection.jbc.GetPortToolID(stationUUID, portData.port);
                                                // HA
                                                portData.flow       = contDataPort_HA.flow;
                                                portData.tempTC1    = contDataPort_HA.externalTC1_Temp.UTI;
                                                portData.tempTC2    = contDataPort_HA.externalTC2_Temp.UTI;
                                                portData.timetostop = contDataPort_HA.timeToStop;
                                                break;
                                            }

                                            //Coma separador de entradas
                                            if (System.Convert.ToInt32(m_mdhtStationUUID2PortNumSequence.Item(stationUUID, readingPort)) != 0)
                                            {
                                                portJSONData[readingPort] = (portJSONData[readingPort]).ToString() + "," + "\r\n";
                                            }

                                            //Escribimos número de secuencia
                                            portJSONData[readingPort] = (portJSONData[readingPort]).ToString() + "{\"n\":" + System.Convert.ToString(m_mdhtStationUUID2PortNumSequence.Item(stationUUID, readingPort));

                                            //Notificar tool en la primera entrada de datos o cada vez que haya un cambio
                                            if (m_mdhtStationUUID2PortNumSequence.Item(stationUUID, readingPort) == 0 |
                                                portData.tool != ((TracePortData)(antListPortData[readingPort])).tool)
                                            {
                                                portJSONData[readingPort] = (portJSONData[readingPort]).ToString() + ", \"o\":" + System.Convert.ToString(portData.tool);
                                            }

                                            //Si no hay tool, no notificar el status, temperatura ni power
                                            if (portData.tool != GenericStationTools.NO_TOOL)
                                            {
                                                //Notificar status en la primera entrada de datos o cada vez que haya un cambio
                                                if (System.Convert.ToInt32(m_mdhtStationUUID2PortNumSequence.Item(stationUUID, readingPort)) == 0 |
                                                    portData.status != ((TracePortData)(antListPortData[readingPort])).status)
                                                {
                                                    portJSONData[readingPort] = (portJSONData[readingPort]).ToString() + ", \"s\":" + System.Convert.ToString(portData.status);
                                                }

                                                // temperature
                                                portJSONData[readingPort] = (portJSONData[readingPort]).ToString() + ", \"t\":" + System.Convert.ToString(portData.temperature);

                                                //Si status es extractor o hibernation no notificar el power
                                                if (portData.status != (byte)ToolStatus.EXTRACTOR &
                                                    portData.status != (byte)ToolStatus.HIBERNATION)
                                                {
                                                    portJSONData[readingPort] = (portJSONData[readingPort]).ToString() + ", \"w\":" + System.Convert.ToString(portData.power);
                                                }

                                                // HA
                                                if (stationType == eStationType.HA)
                                                {
                                                    // flow
                                                    portJSONData[readingPort] = (portJSONData[readingPort]).ToString() + ", \"f\":" + System.Convert.ToString(portData.flow);

                                                    // time to stop
                                                    portJSONData[readingPort] = (portJSONData[readingPort]).ToString() + ", \"ts\":" + System.Convert.ToString(portData.timetostop);

                                                    if (portData.tempTC1 > 0)
                                                    {
                                                        portJSONData[readingPort] = (portJSONData[readingPort]).ToString() + ", \"x1\":" + System.Convert.ToString(portData.tempTC1);
                                                    }

                                                    if (portData.tempTC2 > 0)
                                                    {
                                                        portJSONData[readingPort] = (portJSONData[readingPort]).ToString() + ", \"x2\":" + System.Convert.ToString(portData.tempTC2);
                                                    }
                                                }
                                            }

                                            portJSONData[readingPort] = (portJSONData[readingPort]).ToString() + "}";
                                            (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.WriteAllText(TempPathFilename(m_folderData, queueID, readingPort), (portJSONData[readingPort]).ToString(), true);
                                        }
                                    }

                                    //Incrementar numero de secuencia
                                    ArrayList listPorts = new ArrayList();
                                    listPorts.AddRange(m_mdhtStationUUID2PortNumSequence.RowKeys(stationUUID));

                                    foreach (Port port in listPorts)
                                    {
                                        m_mdhtStationUUID2PortNumSequence.Add(stationUUID, port, (System.Convert.ToInt32(m_mdhtStationUUID2PortNumSequence.Item(stationUUID, port))) + 1);

                                        //Final de fichero
                                        if (System.Convert.ToInt32(m_mdhtStationUUID2PortNumSequence.Item(stationUUID, port)) == FILE_MAX_SEQUENCE)
                                        {
                                            m_mdhtStationUUID2PortNumSequence.Add(stationUUID, port, 0);

                                            //Cierre y renombre del fichero con id único
                                            (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.WriteAllText(TempPathFilename(m_folderData, queueID, port), "]}", true);
                                            (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.MoveFile(TempPathFilename(m_folderData, queueID, port),
                                                                                                                     TracePathFilename(m_folderData, queueID, port, DateTime.Now));
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            // Stop trace data
                            m_htStationUUID2QueueID.Remove(stationUUID);
                            m_mdhtStationUUID2PortData.RemoveRow(stationUUID);
                            m_mdhtStationUUID2PortNumSequence.RemoveRow(stationUUID);

                            ArrayList listPorts = new ArrayList();
                            listPorts.AddRange(m_mdhtStationUUID2PortNumSequence.RowKeys(stationUUID));

                            foreach (Port port in listPorts)
                            {
                                //close and rename file with unique name
                                if (File.Exists(TempPathFilename(m_folderData, queueID, port)))
                                {
                                    (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.WriteAllText(TempPathFilename(m_folderData, queueID, port), "]}", true);
                                }
                                if (File.Exists(TempPathFilename(m_folderData, queueID, port)))
                                {
                                    (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.MoveFile(TempPathFilename(m_folderData, queueID, port),
                                                                                                             TracePathFilename(m_folderData, queueID, port, DateTime.Now));
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        // error
                        //Stop trace data
                        m_htStationUUID2QueueID.Remove(stationUUID);
                        m_mdhtStationUUID2PortData.RemoveRow(stationUUID);
                        m_mdhtStationUUID2PortNumSequence.RemoveRow(stationUUID);

                        ArrayList listPorts = new ArrayList();
                        listPorts.AddRange(m_mdhtStationUUID2PortNumSequence.RowKeys(stationUUID));

                        foreach (Port port in listPorts)
                        {
                            //close and rename file with unique name
                            if (File.Exists(TempPathFilename(m_folderData, queueID, port)))
                            {
                                (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.WriteAllText(TempPathFilename(m_folderData, queueID, port), "]}", true);
                                (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.MoveFile(TempPathFilename(m_folderData, queueID, port),
                                                                                                         TracePathFilename(m_folderData, queueID, port, DateTime.Now));
                            }
                        }
                    }
                }

                Thread.Sleep(THREAD_SLEEP_TRACE_DATA);
            }
        }
Esempio n. 5
0
        private void TraceData()
        {
            ArrayList listStationUID                  = new ArrayList();
            Hashtable listPortData                    = default(Hashtable);
            ArrayList listPortDataKey                 = new ArrayList();
            Hashtable antListPortData                 = new Hashtable();
            stContinuousModeData_SOLD contData        = new stContinuousModeData_SOLD(); // solder data
            stContinuousModeData_HA   contData_HA     = new stContinuousModeData_HA();   // hot air data
            stContinuousModePort_SOLD contDataPort    = new stContinuousModePort_SOLD(); // solder data
            stContinuousModePort_HA   contDataPort_HA = new stContinuousModePort_HA();   // hot air data

            do
            {
                // update stations
                listStationUID.Clear();
                listStationUID.AddRange(m_htStationQueue.Keys);

                //Iteramos en todas las estaciones
                foreach (string stationUID in listStationUID)
                {
                    long stationID = -1;
                    //Dim stationType As dc_EnumConstJBC.dc_StationType = dc_EnumConstJBC.dc_StationType.UNKNOWN
                    eStationType stationType = eStationType.UNKNOWN;

                    try
                    {
                        stationID   = DLLConnection.jbc.GetStationID(stationUID);
                        stationType = DLLConnection.jbc.GetStationType(stationID);

                        if (stationID >= 0)
                        {
                            string JSONData = "";

                            //Listado de puertos que estamos trazando para la estación
                            listPortData = (Hashtable)(m_htStationPortsData[stationUID]);
                            listPortDataKey.Clear();
                            listPortDataKey.AddRange(listPortData.Keys);

                            int dataLength = DLLConnection.jbc.GetContinuousModeDataCount(stationID, (uint)(m_htStationQueue[stationUID]));
                            evlogWrite("Data records to process:" + dataLength.ToString(), stationUID);
                            for (int i = 0; i <= dataLength - 1; i++)
                            {
                                bool bDataExists = false;
                                switch (stationType)
                                {
                                case eStationType.SOLD:
                                    contData = DLLConnection.jbc.GetContinuousModeNextData_SOLD(stationID, (uint)(m_htStationQueue[stationUID]));
                                    if (contData.data != null)
                                    {
                                        bDataExists = true;
                                    }
                                    break;

                                case eStationType.HA:
                                    contData_HA = DLLConnection.jbc.GetContinuousModeNextData_HA(stationID, (uint)(m_htStationQueue[stationUID]));
                                    if (contData_HA.data != null)
                                    {
                                        bDataExists = true;
                                    }
                                    break;
                                }

                                if (bDataExists)
                                {
                                    JSONData = "";

                                    //Cabecera de datos si secuencia es cero
                                    if (System.Convert.ToInt32(m_htStationNumSequence[stationUID]) == 0)
                                    {
                                        // obtener la velocidad de la cola
                                        SpeedContinuousMode queueCaptureSpeed = DLLConnection.jbc.GetContinuousModeDeliverySpeed(stationID, (uint)(m_htStationQueue[stationUID]));
                                        // convertirla a integer
                                        CSpeedContMode speedcm   = new CSpeedContMode();
                                        int            frequency = speedcm.SpeedFromEnum(queueCaptureSpeed);
                                        // obtener datos identificativos
                                        string stnName         = DLLConnection.jbc.GetStationName(stationID);
                                        string stnModel        = DLLConnection.jbc.GetStationModel(stationID);
                                        string stnModelType    = DLLConnection.jbc.GetStationModelType(stationID);
                                        string stnModelVersion = DLLConnection.jbc.GetStationModelVersion(stationID).ToString();
                                        string stnSW           = DLLConnection.jbc.GetStationSWversion(stationID);
                                        string stnHW           = DLLConnection.jbc.GetStationHWversion(stationID);

                                        JSONData = "{" + "\r\n" + "\"id\":\"" + stationUID + "\"," +
                                                   "\r\n" + "\"time\":\"" + DateTime.Now.ToString(TRACE_TIME_FORMAT) + "\"," +
                                                   "\r\n" + "\"name\":\"" + stnName + "\"," +
                                                   "\r\n" + "\"type\":\"" + stationType.ToString() + "\"," +
                                                   "\r\n" + "\"model\":\"" + stnModel + "\"," +
                                                   "\r\n" + "\"modeltype\":\"" + stnModelType + "\"," +
                                                   "\r\n" + "\"modelversion\":\"" + stnModelVersion + "\"," +
                                                   "\r\n" + "\"software\":\"" + stnSW + "\"," +
                                                   "\r\n" + "\"hardware\":\"" + stnHW + "\"," +
                                                   "\r\n" + "\"interval\":" + System.Convert.ToString(frequency);
                                    }

                                    //Por cada puerto del modo continuo
                                    bool bComma = false;

                                    //Escribimos número de secuencia y datos
                                    JSONData += "," + "\r\n" + "\"" + System.Convert.ToString(m_htStationNumSequence[stationUID]) + "\":[";

                                    // datos de los puertos

                                    // cantidad de puertos
                                    int iDataPortCount = 0;
                                    switch (stationType)
                                    {
                                    case eStationType.SOLD:
                                        iDataPortCount = contData.data.Length;
                                        break;

                                    case eStationType.HA:
                                        iDataPortCount = contData_HA.data.Length;
                                        break;
                                    }

                                    // datos de los puertos
                                    //For Each contDataPort As stContinuousModePort In contData.data
                                    for (var x = 0; x <= iDataPortCount - 1; x++)
                                    {
                                        Port readingPort = Port.NO_PORT;
                                        switch (stationType)
                                        {
                                        case eStationType.SOLD:
                                            contDataPort = contData.data[x];
                                            readingPort  = contDataPort.port;
                                            break;

                                        case eStationType.HA:
                                            contDataPort_HA = contData_HA.data[x];
                                            readingPort     = contDataPort_HA.port;
                                            break;
                                        }

                                        //Copiamos los datos del registro anterior para comparar al crear el json
                                        TracePortData portData = new TracePortData();
                                        antListPortData.Clear();
                                        foreach (Port portDataKey in listPortDataKey)
                                        {
                                            portData = (TracePortData)(listPortData[portDataKey]);
                                            antListPortData.Add(portDataKey, portData.Clone());
                                        }

                                        //Si el puerto lo estamos trazando
                                        if (listPortData.Contains(readingPort))
                                        {
                                            switch (stationType)
                                            {
                                            case eStationType.SOLD:
                                                portData             = (TracePortData)(((TracePortData)(listPortData[contDataPort.port])).Clone());
                                                portData.port        = contDataPort.port;
                                                portData.temperature = contDataPort.temperature.UTI;
                                                portData.power       = contDataPort.power;
                                                portData.status      = System.Convert.ToByte(contDataPort.status);
                                                portData.tool        = DLLConnection.jbc.GetPortToolID(stationID, portData.port);
                                                break;

                                            case eStationType.HA:
                                                portData             = (TracePortData)(((TracePortData)(listPortData[contDataPort_HA.port])).Clone());
                                                portData.port        = contDataPort_HA.port;
                                                portData.temperature = contDataPort_HA.temperature.UTI;
                                                portData.power       = contDataPort_HA.power;
                                                portData.status      = System.Convert.ToByte(contDataPort_HA.status);
                                                portData.tool        = DLLConnection.jbc.GetPortToolID(stationID, portData.port);
                                                // HA
                                                portData.flow       = contDataPort_HA.flow;
                                                portData.tempTC1    = contDataPort_HA.externalTC1_Temp.UTI;
                                                portData.tempTC2    = contDataPort_HA.externalTC2_Temp.UTI;
                                                portData.timetostop = contDataPort_HA.timeToStop;
                                                break;
                                            }

                                            if (bComma)
                                            {
                                                JSONData += ",";
                                            }
                                            bComma = true;

                                            JSONData += "\r\n" + "{\"p\":" + System.Convert.ToString(portData.port);

                                            //Notificar tool en la primera entrada de datos o cada vez que haya un cambio
                                            // LA TOOL en TEXTO
                                            if (System.Convert.ToInt32(m_htStationNumSequence[stationUID]) == 0 | portData.tool != ((TracePortData)(antListPortData[portData.port])).tool)
                                            {
                                                JSONData += ", \"o\":" + System.Convert.ToString(portData.tool) + "";
                                            }

                                            //Si no hay tool, no notificar de status, temperatura ni power
                                            if (portData.tool != GenericStationTools.NO_TOOL)
                                            {
                                                //Notificar status en la primera entrada de datos o cada vez que haya un cambio
                                                if (System.Convert.ToInt32(m_htStationNumSequence[stationUID]) == 0 | portData.status != ((TracePortData)(antListPortData[portData.port])).status)
                                                {
                                                    JSONData += ", \"s\":" + System.Convert.ToString(portData.status);
                                                }

                                                // temperature
                                                JSONData += ", \"t\":" + System.Convert.ToString(portData.temperature);

                                                //Si status es extractor o hibernation no notificar el power
                                                if (portData.status != (byte)ToolStatus.EXTRACTOR & portData.status != (byte)ToolStatus.HIBERNATION)
                                                {
                                                    JSONData += ", \"w\":" + System.Convert.ToString(portData.power);
                                                }

                                                // HA
                                                if (stationType == eStationType.HA)
                                                {
                                                    // flow
                                                    JSONData += ", \"f\":" + System.Convert.ToString(portData.flow);

                                                    // time to stop (en décimas de segundo)
                                                    JSONData += ", \"ts\":" + System.Convert.ToString(portData.timetostop);

                                                    // viene &HFF si no hay termopar externo
                                                    if (portData.tempTC1 > 0 & portData.tempTC1 < 0xFF)
                                                    {
                                                        JSONData += ", \"x1\":" + System.Convert.ToString(portData.tempTC1);
                                                    }

                                                    // viene &HFF si no hay termopar externo
                                                    if (portData.tempTC2 > 0 & portData.tempTC2 < 0xFF)
                                                    {
                                                        JSONData += ", \"x2\":" + System.Convert.ToString(portData.tempTC2);
                                                    }
                                                }
                                            }

                                            JSONData += "}";
                                        }
                                    } // For Each contDataPort As stContinuousModePort In contData.data

                                    JSONData += "\r\n" + "]";
                                    (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.WriteAllText(tempPathFilename(m_folderData, stationID), JSONData, true);

                                    //Incrementar numero de secuencia
                                    m_htStationNumSequence[stationUID] = (System.Convert.ToInt32(m_htStationNumSequence[stationUID])) + 1;

                                    //Final de fichero
                                    if (System.Convert.ToInt32(m_htStationNumSequence[stationUID]) == m_MaxNumSequence)
                                    {
                                        m_htStationNumSequence[stationUID] = 0;

                                        //Cierre y renombre del fichero con id único
                                        (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.WriteAllText(tempPathFilename(m_folderData, stationID), "}", true);
                                        (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.MoveFile(tempPathFilename(m_folderData, stationID), tracePathFilename(m_folderData, stationID, DateTime.Now));
                                    }
                                } // If contData.data IsNot Nothing Then
                            }     // For i As Integer = 0 To dataLength
                        }
                        else
                        {
                            // station ID not found (disconnected?)
                            // Stop trace data
                            m_htStationQueue.Remove(stationUID);
                            m_htStationID.Remove(stationUID);
                            m_htStationPortsData.Remove(stationUID);
                            m_htStationNumSequence.Remove(stationUID);
                            m_htStationSpeed.Remove(stationUID);

                            //close and rename file with unique name
                            if (File.Exists(tempPathFilename(m_folderData, stationID)))
                            {
                                (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.WriteAllText(tempPathFilename(m_folderData, stationID), "}", true);
                            }
                            if (File.Exists(tempPathFilename(m_folderData, stationID)))
                            {
                                (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.MoveFile(tempPathFilename(m_folderData, stationID), tracePathFilename(m_folderData, stationID, DateTime.Now));
                            }

                            evlogWrite("Station ID not found. Station disconnected?", stationUID);
                        }
                    }
                    catch (Exception ex)
                    {
                        // error
                        //Stop trace data
                        m_htStationQueue.Remove(stationUID);
                        m_htStationID.Remove(stationUID);
                        m_htStationPortsData.Remove(stationUID);
                        m_htStationNumSequence.Remove(stationUID);
                        m_htStationSpeed.Remove(stationUID);

                        //close and rename file with unique name
                        if (File.Exists(tempPathFilename(m_folderData, stationID)))
                        {
                            (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.WriteAllText(tempPathFilename(m_folderData, stationID), "}", true);
                            (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.MoveFile(tempPathFilename(m_folderData, stationID), tracePathFilename(m_folderData, stationID, DateTime.Now));
                        }

                        evlogWrite(System.Reflection.MethodBase.GetCurrentMethod().Name + ". Error: " + ex.Message, stationUID);
                    }
                }

                Thread.Sleep(frequencyTrace);
            } while (true);
        }
Esempio n. 6
0
 private void stack_ReceivedInfoContiMode(stContinuousModeData_HA Datos, uint queueID)
 {
     // añadir a buffer local
     traceList.AddData(Datos, queueID);
 }
Esempio n. 7
0
        private void Tick_PrintSeries(object sender, EventArgs e)
        {
            m_jbcConnect.UpdateContinuousModeNextDataChunkAsync(m_stationID, m_queueID, 50);

            //Mientras hayan datos para leer
            while (m_jbcConnect.GetContinuousModeDataCount(m_stationID, m_queueID) > 0)
            {
                stContinuousModeData_HA continuousModeData = m_jbcConnect.GetContinuousModeNextData_HA(m_stationID, m_queueID);

                if (continuousModeData.data != null)
                {
                    //Se está pintando el profile
                    if (continuousModeData.data[0].status == ToolStatus_HA.HEATER)
                    {
                        //Es la primera muestra. Borrar series
                        if (m_toolStatus != ToolStatus_HA.HEATER)
                        {
                            m_toolStatus = ToolStatus_HA.HEATER;
                            InitializeDataHotAirTemp();
                            InitializeDataExtTCTemp();
                            InitializeDataAirFlow();
                            InitializeDataVerticalMark();
                        }

                        if (m_tickCount < DataPoints)
                        {
                            //Pintamos en la gráfica - Hot air temp
                            DataSerie dataSerieHotAirTemp = new DataSerie();
                            dataSerieHotAirTemp.Value = System.Convert.ToDouble(continuousModeData.data[0].temperature.ToCelsius());
                            dataSerieHotAirTemp.Time  = m_tickCount;
                            DataHotAirTemp.RemoveAt(0);
                            DataHotAirTemp.Add(dataSerieHotAirTemp);

                            //Pintamos en la gráfica - External TC temp
                            DataSerie dataSerieExtTCTemp = new DataSerie();
                            dataSerieExtTCTemp.Value = System.Convert.ToDouble(continuousModeData.data[0].externalTC1_Temp.ToCelsius());
                            dataSerieExtTCTemp.Time  = m_tickCount;
                            DataExtTCTemp.RemoveAt(0);
                            DataExtTCTemp.Add(dataSerieExtTCTemp);

                            //Pintamos en la gráfica - Air flow
                            DataSerie dataSerieAirFlow = new DataSerie();
                            dataSerieAirFlow.Value = System.Convert.ToDouble(continuousModeData.data[0].flow / 10); //viene en x_mil y se representa en x_cien
                            dataSerieAirFlow.Time  = m_tickCount;
                            DataAirFlow.RemoveAt(0);
                            DataAirFlow.Add(dataSerieAirFlow);

                            //Pintamos en la gráfica - Vertical mark
                            DataSerie dataSerieVerticalMark = new DataSerie();
                            dataSerieVerticalMark.Value = -1;
                            dataSerieVerticalMark.Time  = m_tickCount;
                            DataVerticalMark.RemoveAt(0);
                            DataVerticalMark.Add(dataSerieVerticalMark);

                            //Refrescamos cada medio segundo
                            if (m_tickCount % 5 == 0)
                            {
                                //Pintamos los labels
                                m_labelHotAirTemp.Text = continuousModeData.data[0].temperature.ToRoundCelsius() + "ºC";
                                m_labelExtTCTemp.Text  = continuousModeData.data[0].externalTC1_Temp.ToRoundCelsius() + "ºC";
                                m_labelAirFlow.Text    = (continuousModeData.data[0].flow / 10) + "%";

                                //Calculates time remaining
                                int timeInSeconds = System.Convert.ToInt32((DataPoints - m_tickCount) / 10);
                                int seconds       = timeInSeconds % 60;
                                var timeInMinutes = timeInSeconds / 60;
                                int minutes       = timeInMinutes % 60;

                                string sTime = minutes + "m ";
                                if (seconds < 10)
                                {
                                    sTime += "0";
                                }
                                sTime += seconds + "s";

                                m_labelStatus.Text = sTime;
                            }

                            m_tickCount++;
                        }
                    }
                    else if (continuousModeData.data[0].status == ToolStatus_HA.COOLING)
                    {
                        //Se acaba de parar de pintar el profile - Flag de bajada
                        if (m_toolStatus != ToolStatus_HA.COOLING)
                        {
                            m_toolStatus       = ToolStatus_HA.COOLING;
                            m_labelStatus.Text = "Cooling";
                            m_tickCount        = 0;
                        }
                    }
                    else if (continuousModeData.data[0].status == ToolStatus_HA.NONE)
                    {
                        if (m_toolStatus != ToolStatus_HA.NONE)
                        {
                            m_toolStatus       = ToolStatus_HA.NONE;
                            m_labelStatus.Text = "Stop";
                            m_tickCount        = 0;
                        }
                    }
                }
            }
        }