Ejemplo n.º 1
0
        //Private functions
        private bool updatePorts()
        {
            try
            {
                jbc.UpdateContinuousModeNextDataChunk((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);
            }
        }
Ejemplo n.º 2
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;
                        }
                    }
                }
            }
        }