public void LoadProfile() { //Si el modo de regulación del perfil está en Air temp, el valor de ext TC se obtiene del seleccionado en la estación //Si el modo de regulación del perfil está en Ext TC temp, el valor de Air temp no se tiene que mostrar byte[] profileDataByte = m_jbcConnect.GetProfile(m_stationID, m_jbcConnect.GetSelectedProfile(m_stationID)); if (ReferenceEquals(profileDataByte, null)) { return; } string profileData = System.Text.Encoding.ASCII.GetString(profileDataByte); JObject jsonParse = (JObject)(JObject.Parse(profileData)); JToken points = jsonParse["_"]["Points"]; ProfileRegulationMode profileRegulationMode = (ProfileRegulationMode)(System.Convert.ToInt32(jsonParse["_"]["Mode"])); m_windowDivisions = 0; m_windowTime = 0; foreach (var point in points) { m_windowDivisions++; m_windowTime += System.Convert.ToInt32(point["Time"]); } double[] pointsProfileHotAirTemp = new double[m_windowTime + 1]; double[] pointsProfileExtTCTemp = new double[m_windowTime + 1]; double[] pointsProfileAirFlow = new double[m_windowTime + 1]; int tick = 0; double iniHotAirTemp = 0; double endHotAirTemp = 0; double iniExtTCTemp = 0; double endExtTCTemp = 0; double iniAirFlow = 0; double endAirFlow = 0; foreach (var point in points) { //Valores del inicio del step if (tick == 0) { if (profileRegulationMode == ProfileRegulationMode.AIR_TEMP) { iniHotAirTemp = System.Convert.ToDouble(point["ATemp"]); iniExtTCTemp = m_jbcConnect.GetPortToolSelectedExtTemp(m_stationID, m_port).UTI; } else { iniHotAirTemp = -1; iniExtTCTemp = System.Convert.ToDouble(point["ETemp1"]); } iniAirFlow = System.Convert.ToDouble(point["AFlow"]); //Punto inicial pointsProfileHotAirTemp[tick] = iniHotAirTemp; pointsProfileExtTCTemp[tick] = iniExtTCTemp; pointsProfileAirFlow[tick] = iniAirFlow; tick = 1; } else { iniHotAirTemp = endHotAirTemp; iniExtTCTemp = endExtTCTemp; iniAirFlow = endAirFlow; } //Valores del final del step if (profileRegulationMode == ProfileRegulationMode.AIR_TEMP) { endHotAirTemp = System.Convert.ToDouble(point["ATemp"]); endExtTCTemp = m_jbcConnect.GetPortToolSelectedExtTemp(m_stationID, m_port).UTI; } else { endHotAirTemp = -1; endExtTCTemp = System.Convert.ToDouble(point["ETemp1"]); } endAirFlow = System.Convert.ToDouble(point["AFlow"]); //Duración del step int stepTime = System.Convert.ToInt32(point["Time"]); //Calcular el incremento para cada punto del actual step double slopeHotAirTemp = (endHotAirTemp - iniHotAirTemp) / stepTime; double slopeExtTCTemp = (endExtTCTemp - iniExtTCTemp) / stepTime; double slopeAirFlow = (endAirFlow - iniAirFlow) / stepTime; //Valores temporales para los puntos double tmpHotAirTemp = iniHotAirTemp; double tmpExtTCTemp = iniExtTCTemp; double tmpAirFlow = iniAirFlow; for (int i = 1; i <= System.Convert.ToInt32(point["Time"]); i++) { //Incrementar los valores para cada tick tmpHotAirTemp += slopeHotAirTemp; tmpExtTCTemp += slopeExtTCTemp; tmpAirFlow += slopeAirFlow; //Guardar los puntos calculados de la recta pointsProfileHotAirTemp[tick] = tmpHotAirTemp; pointsProfileExtTCTemp[tick] = tmpExtTCTemp; pointsProfileAirFlow[tick] = tmpAirFlow; tick++; } } //Horizontal axis - Time m_timeAxis.MajorTickInterval = m_windowTime / m_windowDivisions; //Data points m_liveData.DataPoints = m_windowTime + 1; //Fill Data m_liveData.InitializeDataProfileHotAirTemp(pointsProfileHotAirTemp); m_liveData.InitializeDataProfileExtTCTemp(pointsProfileExtTCTemp); m_liveData.InitializeDataProfileAirFlow(pointsProfileAirFlow); }