public Demo2Model() { mVariables["A000"] = new VariableModel("A000", "Temperatura spalin przed odemglaczem", "°C"); mVariables["A004"] = new VariableModel("A004", "Temperatura kwasu siarkowego", "°C"); mVariables["A008"] = new VariableModel("A008", "Temperatura wody ciepłej", "°C"); mVariables["A082"] = new VariableModel("A082", "Przepływ kwasu siarkowego", "m³/h"); mVariables["A084"] = new VariableModel("A084", "Poziom w zb. cyrkulacyjnym kwasu", "%"); mVariables["A086"] = new VariableModel("A086", "Przepływ wody chłodzącej", "m³/h"); mVariables["Nieznana"] = new VariableModel("Nieznana", "Nieznana zmienna", ""); }
void ReadVariableValue(VariableModel aVariableModel) { try { AsixRestClient asixRestClient = new AsixRestClient(); VariableState variableState = asixRestClient.ReadVariableState(aVariableModel.mName); if (!variableState.readSucceeded) { aVariableModel.mReadError = variableState.readStatusString; return; } aVariableModel.mDateTime = variableState.timeStamp; switch (variableState.quality & 0xC0) { case 0xC0: { double value = (double)variableState.value; aVariableModel.mValueFormatted = value.ToString("F0"); break; } case 0x40: { double value = (double)variableState.value; aVariableModel.mValueFormatted = value.ToString("F0") + "?"; break; } default: { aVariableModel.mValueFormatted = "?"; break; } } } catch (Exception e) { aVariableModel.mReadError = e.Message; } }