#include "ChillerClient.h" #include "Modbus.h" //#include "../SystemInfo.h" #include "../external/imgui/imgui_custom.h" //#include "../Toast.h" ChillerClient::ChillerClient(CommunicationCfg* pconfig,int* tp) :TcpClient(pconfig) { m_Freq = 150; m_Type = tp; } ChillerClient::~ChillerClient() { Shutdown(); } void ChillerClient::InitCommand() { if ((*m_Type) == ExtCfg::DOLUYO) { Command* pCommand = new ReadModbus(m_Config->m_Addr, 0x2D, 38); pCommand->m_Fun = &ChillerClient::ProcDoluyoInfo; pCommand->m_Ref = this; pCommand->isNeedDel = false; Command* pReadTarge = new ReadModbus(m_Config->m_Addr, 0x8E, 1); pReadTarge->m_Fun = &ChillerClient::ProcDoluyoReadTargeValue; pReadTarge->m_Ref = this; pReadTarge->isNeedDel = false; m_CycleCommands.push_back(pCommand); m_CycleCommands.push_back(pReadTarge); } else if((*m_Type)==ExtCfg::HANS) { Command* pCommand = new ReadModbus(m_Config->m_Addr, 0x100, 16); pCommand->m_Fun = &ChillerClient::ProcHansInfo; pCommand->m_Ref = this; pCommand->isNeedDel = false; m_CycleCommands.push_back(pCommand); } else if ((*m_Type) == ExtCfg::TONGFEI) { Command* alarmInput = new ReadCoilModbus(m_Config->m_Addr, 0x01, 20); alarmInput->m_Fun = &ChillerClient::ProcTongfeiAlarmInputInfo; alarmInput->m_Ref = this; alarmInput->isNeedDel = false; Command* alarmState = new ReadModbus(m_Config->m_Addr, 57, 1); alarmState->m_Fun = &ChillerClient::ProcTongfeiAlarmStateInfo; alarmState->m_Ref = this; alarmState->isNeedDel = false; Command* userParams = new ReadModbus(m_Config->m_Addr, 0x02, 5); userParams->m_Fun = &ChillerClient::ProcTongfeiUserParamsInfo; userParams->m_Ref = this; userParams->isNeedDel = false; Command* anaShow = new ReadModbus(m_Config->m_Addr, 150, 9); anaShow->m_Fun = &ChillerClient::ProcTongfeiAnaShowInfo; anaShow->m_Ref = this; anaShow->isNeedDel = false; Command* anaShow2 = new ReadModbus(m_Config->m_Addr, 720, 4); anaShow2->m_Fun = &ChillerClient::ProcTongfeiAnaShowInfo2; anaShow2->m_Ref = this; anaShow2->isNeedDel = false; Command* anaShow3 = new ReadModbus(m_Config->m_Addr, 741, 5); anaShow3->m_Fun = &ChillerClient::ProcTongfeianaShowInfo3; anaShow3->m_Ref = this; anaShow3->isNeedDel = false; m_CycleCommands.push_back(alarmInput); m_CycleCommands.push_back(alarmState); m_CycleCommands.push_back(userParams); m_CycleCommands.push_back(anaShow); m_CycleCommands.push_back(anaShow2); m_CycleCommands.push_back(anaShow3); } } void ChillerClient::SetDoluyoTargetTempValue(float value) { short realvalue = (short)(value * 10); WriteModbus* pSet = new WriteModbus(m_Config->m_Addr, 0x8E); pSet->AddShort(realvalue); pSet->m_Fun = &ChillerClient::ProcDoluyoSettingValue; pSet->m_Ref = this; EnterCriticalSection(&m_RtcCS); m_RTCommands.push(pSet); LeaveCriticalSection(&m_RtcCS); } void ChillerClient::ProcDoluyoInfo(void* pobject, Command* pcommand) { if (pobject == NULL)return; ChillerClient* pDlc = (ChillerClient*)pobject; unsigned char* rseq = pcommand->m_RespSeq; unsigned char addr = rseq[0]; short watertempValue = (((rseq[3] & 0xff) << 8) + (rseq[4] & 0xff)); unsigned short runinfo = (((rseq[63] & 0xff) << 8) + (rseq[64] & 0xff)); unsigned short runs = (((rseq[65] & 0xff) << 8) + (rseq[66] & 0xff)); unsigned short alarminfo = (((rseq[67] & 0xff) << 8) + (rseq[68] & 0xff)); unsigned short levelalarm = (((rseq[77] & 0xff) << 8) + (rseq[78] & 0xff)); //short tempSetValue = (((rseq[197] & 0xff) << 8) + (rseq[198] & 0xff)); //pDlc->m_ValueMutex.lock(); EnterCriticalSection(&pDlc->m_ValueCS); pDlc->m_DoluyoChillerStat.tempRealtimeValue = (float)watertempValue / 10.0f; pDlc->m_DoluyoChillerStat.runInfo = runinfo; switch (runs) { case 0:pDlc->m_DoluyoChillerStat.isRun = false; break; case 1:pDlc->m_DoluyoChillerStat.isRun = true; break; case 2:pDlc->m_DoluyoChillerStat.isRun = false; break; } pDlc->m_DoluyoChillerStat.alarmInfo = alarminfo; pDlc->m_DoluyoChillerStat.isLevelAlarm= ((levelalarm == 0) ? false : true); //stat->tempSettingValue = (float)tempSetValue / 10.0f; LeaveCriticalSection(&pDlc->m_ValueCS); } void ChillerClient::ProcDoluyoReadTargeValue(void* pobject, Command* pcommand) { if (pobject == NULL)return; ChillerClient* pDlc = (ChillerClient*)pobject; unsigned char* rseq = pcommand->m_RespSeq; unsigned char addr = rseq[0]; //unsigned char* rseq = pcommand->m_RespSeq; short tempValue = (((rseq[3] & 0xff) << 8) + (rseq[4] & 0xff)); EnterCriticalSection(&pDlc->m_ValueCS); pDlc->m_DoluyoChillerStat.tempSettingValue = (float)tempValue / 10.0f; LeaveCriticalSection(&pDlc->m_ValueCS); } void ChillerClient::ProcDoluyoSettingValue(void* pobject, Command* pcommand) { ChillerClient* pDlc = (ChillerClient*)pobject; WriteModbus* setCommand =(WriteModbus*) pcommand; WriteModbus* pSave = new WriteModbus(setCommand->m_addr, 0x19); pSave->AddShort(0x0500); pSave->m_Ref = pDlc; EnterCriticalSection(&pDlc->m_RtcCS); pDlc->m_RTCommands.push(pSave); LeaveCriticalSection(&pDlc->m_RtcCS); } void ChillerClient::GetDoluyoStat(DoluyoChillerstat& stat1) { EnterCriticalSection(&m_ValueCS); stat1.baseStat = m_BaseStat; stat1.alarmInfo = m_DoluyoChillerStat.alarmInfo; stat1.isRun = m_DoluyoChillerStat.isRun; stat1.runInfo = m_DoluyoChillerStat.runInfo; stat1.tempRealtimeValue = m_DoluyoChillerStat.tempRealtimeValue; stat1.tempSettingValue = m_DoluyoChillerStat.tempSettingValue; stat1.isLevelAlarm = m_DoluyoChillerStat.isLevelAlarm; LeaveCriticalSection(&m_ValueCS); } void ChillerClient::GetHansStat(HansChillerstat& stat) { EnterCriticalSection(&m_ValueCS); /*stat.baseStat = m_BaseStat; stat.alarmInfo = m_Stat.alarmInfo; stat.isRun = m_Stat.isRun; stat.runInfo = m_Stat.runInfo; stat.tempRealtimeValue = m_Stat.tempRealtimeValue; stat.tempSettingValue = m_Stat.tempSettingValue; stat.isLevelAlarm = m_Stat.isLevelAlarm;*/ stat.baseStat = m_BaseStat; stat.m_WaterOutTemp = m_HansChillerstat.m_WaterOutTemp; stat.m_Flow = m_HansChillerstat.m_Flow; stat.m_SettingTemp = m_HansChillerstat.m_SettingTemp; stat.m_RunIndicate = m_HansChillerstat.m_RunIndicate; stat.m_WorkIndicate = m_HansChillerstat.m_WorkIndicate; stat.m_CompressorIndicate = m_HansChillerstat.m_CompressorIndicate; stat.m_WaterPumpIndicate = m_HansChillerstat.m_WaterPumpIndicate; stat.m_HeaterIndicate = m_HansChillerstat.m_HeaterIndicate; stat.m_FanIndicate = m_HansChillerstat.m_FanIndicate; stat.m_SolenoidValveIndicate = m_HansChillerstat.m_SolenoidValveIndicate; stat.m_LowTempErrorIndicate = m_HansChillerstat.m_LowTempErrorIndicate; stat.m_TempUndulateIndicate = m_HansChillerstat.m_TempUndulateIndicate; stat.m_HeaterExceptionIndicate = m_HansChillerstat.m_HeaterExceptionIndicate; stat.m_IOSignalIndicate = m_HansChillerstat.m_IOSignalIndicate; stat.m_IsAlarm = m_HansChillerstat.m_IsAlarm; stat.m_FlowAlarm = m_HansChillerstat.m_FlowAlarm; stat.m_TempAlarm = m_HansChillerstat.m_TempAlarm; stat.m_PressureAlarm = m_HansChillerstat.m_PressureAlarm; stat.m_WaterLevelAlarm = m_HansChillerstat.m_WaterLevelAlarm; stat.m_TempSensorAlarm = m_HansChillerstat.m_TempSensorAlarm; stat.m_SolenoidValveAlarm = m_HansChillerstat.m_SolenoidValveAlarm; stat.m_PhaseSeqAlarm = m_HansChillerstat.m_PhaseSeqAlarm; stat.m_CompressorStartFreqAlarm = m_HansChillerstat.m_CompressorStartFreqAlarm; stat.m_IO0Alarm = m_HansChillerstat.m_IO0Alarm; stat.m_IO1Alarm = m_HansChillerstat.m_IO1Alarm; stat.m_IO2Alarm = m_HansChillerstat.m_IO2Alarm; stat.m_IO3Alarm = m_HansChillerstat.m_IO3Alarm; stat.m_IO4Alarm = m_HansChillerstat.m_IO4Alarm; LeaveCriticalSection(&m_ValueCS); } void ChillerClient::GetTongFeiStat(TongFeiStat& stat) { EnterCriticalSection(&m_ValueCS); stat.m_BaseStat = m_BaseStat; stat.m_IsLowVoltageAlarm = m_TongFeiStat.m_IsLowVoltageAlarm; stat.m_IsHydraulicFailure = m_TongFeiStat.m_IsHydraulicFailure; stat.m_IsLevelFailure = m_TongFeiStat.m_IsLevelFailure; stat.m_IsLiquidPumpAlarm = m_TongFeiStat.m_IsLiquidPumpAlarm; stat.m_IsPressAlarm = m_TongFeiStat.m_IsPressAlarm; stat.m_IsElectricHeatingFailure = m_TongFeiStat.m_IsElectricHeatingFailure; stat.m_IsAntifreezeAlarm = m_TongFeiStat.m_IsAntifreezeAlarm; stat.m_IsLiquidTempTooHigh = m_TongFeiStat.m_IsLiquidTempTooHigh; stat.m_IsLiquidTempProbeFailure = m_TongFeiStat.m_IsLiquidTempProbeFailure; stat.m_IsEffluentTempProbeFailure = m_TongFeiStat.m_IsEffluentTempProbeFailure; stat.m_IsAmbientTempProbeFailure = m_TongFeiStat.m_IsAmbientTempProbeFailure; stat.m_IsCondensationTempProbeFailure = m_TongFeiStat.m_IsCondensationTempProbeFailure; stat.m_IsEvaporationInletTempProbeFailure = m_TongFeiStat.m_IsEvaporationInletTempProbeFailure; stat.m_IsEvaporationOutletTempProbeFailure = m_TongFeiStat.m_IsEvaporationOutletTempProbeFailure; stat.m_IsCondensationTempTooHigh = m_TongFeiStat.m_IsCondensationTempTooHigh; stat.m_IsPhaseOrderError = m_TongFeiStat.m_IsPhaseOrderError; stat.m_IsPowerFailure = m_TongFeiStat.m_IsPowerFailure; stat.m_IsCompressorFailure = m_TongFeiStat.m_IsCompressorFailure; stat.m_IsAmbientTempTooHigh = m_TongFeiStat.m_IsAmbientTempTooHigh; stat.m_IsAmbientTempException = m_TongFeiStat.m_IsAmbientTempException; stat.m_AlarmState = m_TongFeiStat.m_AlarmState; stat.m_RoomTempSettingValue = m_TongFeiStat.m_RoomTempSettingValue; stat.m_ConstantTempSettingValue = m_TongFeiStat.m_ConstantTempSettingValue; stat.m_WorkMode = m_TongFeiStat.m_WorkMode; stat.m_RefrigerationMethod = m_TongFeiStat.m_RefrigerationMethod; stat.m_LiquidAlarmTemp = m_TongFeiStat.m_LiquidAlarmTemp; stat.m_UnitStatus = m_TongFeiStat.m_UnitStatus; stat.m_LiquidTempProbe = m_TongFeiStat.m_LiquidTempProbe; stat.m_EffluentTempProbe = m_TongFeiStat.m_EffluentTempProbe; stat.m_AmbientTempProbe = m_TongFeiStat.m_AmbientTempProbe; stat.m_CondensationTempProbe = m_TongFeiStat.m_CondensationTempProbe; stat.m_EvaporationInletTempProbe = m_TongFeiStat.m_EvaporationInletTempProbe; stat.m_EvaporationOutletTempProbe = m_TongFeiStat.m_EvaporationOutletTempProbe; stat.m_WorkingFrequency = m_TongFeiStat.m_WorkingFrequency; stat.m_OverHeatingValue = m_TongFeiStat.m_OverHeatingValue; stat.m_EEV1 = m_TongFeiStat.m_EEV1; stat.m_EEV2 = m_TongFeiStat.m_EEV2; stat.m_CondensingFanRatio = m_TongFeiStat.m_CondensingFanRatio; stat.m_ElectricHeatingRatio = m_TongFeiStat.m_ElectricHeatingRatio; stat.m_FlowRate = m_TongFeiStat.m_FlowRate; LeaveCriticalSection(&m_ValueCS); } void ChillerClient::ProcHansInfo(void* pobject, Command* pcommand) { if (pobject == NULL)return; ChillerClient* pDlc = (ChillerClient*)pobject; unsigned char* rseq = pcommand->m_RespSeq; short state1 = (((rseq[3] & 0xff) << 8) + (rseq[4] & 0xff)); short state2 = (((rseq[5] & 0xff) << 8) + (rseq[6] & 0xff)); float waterOutTemp = (float)(((rseq[9] & 0xff) << 8) + (rseq[10] & 0xff)) / 10.0f; float flow = (float)(((rseq[23] & 0xff) << 8) + (rseq[24] & 0xff)) / 10.0f; float settingTemp = (float)(((rseq[33] & 0xff) << 8) + (rseq[34] & 0xff)) / 10.0f; EnterCriticalSection(&pDlc->m_ValueCS); pDlc->m_HansChillerstat.m_WaterOutTemp = waterOutTemp; pDlc->m_HansChillerstat.m_Flow = flow; pDlc->m_HansChillerstat.m_SettingTemp = settingTemp; pDlc->m_HansChillerstat.m_RunIndicate = (state1 & 0x01) ? true : false; //运行指示 pDlc->m_HansChillerstat.m_WorkIndicate = (state1 & 0x02) ? true : false; //工作正常指示 pDlc->m_HansChillerstat.m_IsAlarm = (state1 & 0x04) ? true : false; //报警 pDlc->m_HansChillerstat.m_CompressorIndicate = (state1 & 0x08) ? true : false; //压缩机指示 pDlc->m_HansChillerstat.m_WaterPumpIndicate = (state1 & 0x10) ? true : false; //水泵指示 pDlc->m_HansChillerstat.m_HeaterIndicate = (state1 & 0x20) ? true : false; //加热器指示 pDlc->m_HansChillerstat.m_FanIndicate = (state1 & 0x40) ? true : false; //风机指示 pDlc->m_HansChillerstat.m_SolenoidValveIndicate = (state1 & 0x80) ? true : false; //电磁阀指示 pDlc->m_HansChillerstat.m_FlowAlarm = (state1 & 0x100) ? true : false; //流量报警 pDlc->m_HansChillerstat.m_TempAlarm = (state1 & 0x200) ? true : false; //温度报警 pDlc->m_HansChillerstat.m_PressureAlarm = (state1 & 0x400) ? true : false; //压力报警 pDlc->m_HansChillerstat.m_WaterLevelAlarm = (state1 & 0x800) ? true : false; //液位报警 pDlc->m_HansChillerstat.m_LowTempErrorIndicate = (state1 & 0x1000) ? true : false; //低温错误指示 pDlc->m_HansChillerstat.m_TempUndulateIndicate = (state1 & 0x2000) ? true : false; //温度波动指示 pDlc->m_HansChillerstat.m_TempSensorAlarm = (state2 & 0x01) ? true : false; //温度传感器故障报警 pDlc->m_HansChillerstat.m_SolenoidValveAlarm = (state2 & 0x02) ? true : false; //电磁阀故障报警 pDlc->m_HansChillerstat.m_HeaterExceptionIndicate = (state2 & 0x04) ? true : false; //加热器异常指示 pDlc->m_HansChillerstat.m_IOSignalIndicate = (state2 & 0x08) ? true : false; //IO信号指示 pDlc->m_HansChillerstat.m_PhaseSeqAlarm = (state2 & 0x10) ? true : false; //相序报警 pDlc->m_HansChillerstat.m_CompressorStartFreqAlarm = (state2 & 0x20) ? true : false; //压缩机起动频繁报警 pDlc->m_HansChillerstat.m_IO0Alarm = (state2 & 0x100) ? true : false; //IO0错误报警 pDlc->m_HansChillerstat.m_IO1Alarm = (state2 & 0x200) ? true : false; //IO0错误报警 pDlc->m_HansChillerstat.m_IO2Alarm = (state2 & 0x400) ? true : false; //IO0错误报警 pDlc->m_HansChillerstat.m_IO3Alarm = (state2 & 0x800) ? true : false; //IO0错误报警 pDlc->m_HansChillerstat.m_IO4Alarm = (state2 & 0x1000) ? true : false; //IO0错误报警 LeaveCriticalSection(&pDlc->m_ValueCS); //g_SystemInfo->LockInfo(); //g_SystemInfo->m_WaterTemp = waterOutTemp; //g_SystemInfo->UnlockInfo(); } void ChillerClient::SetHansTargetTempValue(float value) { short realvalue = (short)(value * 10); WriteModbus* pSet = new WriteModbus(m_Config->m_Addr, 271); pSet->AddShort(realvalue); pSet->m_Ref = this; EnterCriticalSection(&m_RtcCS); m_RTCommands.push(pSet); LeaveCriticalSection(&m_RtcCS); } //void ChillerClient::DrawUI() //{ // if (!m_IsShowUI) return; // if(m_Config->m_ClientCode=="LASER_CHILLER")ImGui::Begin(_(u8"激光器冷水机").c_str(), &m_IsShowUI, ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoNav); // else if(m_Config->m_ClientCode == "PURIFIER_CHILLER")ImGui::Begin(_(u8"净化器冷水机").c_str(), &m_IsShowUI, ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoNav); // else ImGui::Begin(_(u8"冷水机").c_str(), &m_IsShowUI, ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoNav); // if ((*m_Type) == ExtCfg::DOLUYO) // { // DoluyoChillerstat stat; // GetDoluyoStat(stat); // if (stat.baseStat.isConnected)ImGui::TextColored(ImVec4(0.0, 1.0, 0.0, 1.0), _(u8"冷水机通讯连接:正常").c_str()); // else ImGui::TextColored(ImVec4(1.0, 0.0, 0.0, 1.0), _(u8"冷水机通讯连接:断开").c_str()); // ImGui::Text(_(u8"冷水机水温:%.1f ℃").c_str(), stat.tempRealtimeValue); // ImGui::Text(_(u8"冷水机设定水温:%.1f ℃").c_str(), stat.tempSettingValue); // ImGui::Text(_(u8"冷水机运行状态:%s").c_str(), stat.GetRunInfo().c_str()); // ImGui::Text(_(u8"冷水机故障信息:%s").c_str(), stat.GetAlarmInfo().c_str()); // if (!stat.isLevelAlarm) ImGui::TextColored(ImVec4(0.0, 1.0, 0.0, 1.0), _(u8"冷水机液位:正常").c_str()); // else ImGui::TextColored(ImVec4(1.0, 0.0, 0.0, 1.0), _(u8"冷水机液位:报警").c_str()); // } // else if ((*m_Type) == ExtCfg::HANS) { // // HansChillerstat cs; // GetHansStat(cs); // // ImGui::BeginGroup(); // if (IsServerConnected()) { // ImGui::TextColored(ImVec4(0.0, 1.0, 0.0, 1.0), _(u8"端口连接:正常").c_str()); // } // else { // ImGui::TextColored(ImVec4(1.0, 0.0, 0.0, 1.0), _(u8"端口连接:断开").c_str()); // } // if (IsComConnected()) { // ImGui::TextColored(ImVec4(0.0, 1.0, 0.0, 1.0), _(u8"通讯连接:正常").c_str()); // } // else { // ImGui::TextColored(ImVec4(1.0, 0.0, 0.0, 1.0), _(u8"通讯连接:断开").c_str()); // } // // ImGui::Dummy(ImVec2(0, 10)); // ImGui::Text(_(u8"冷水机水温:%.1f ℃").c_str(), cs.m_WaterOutTemp); // ImGui::Text(_(u8"流量:%.1f L/min").c_str(), cs.m_Flow); // ImGui::Text(_(u8"设置温度:%.1f ℃").c_str(), cs.m_SettingTemp); // // ImGui::EndGroup(); // // ImGui::SameLine(); // ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); // ImGui::SameLine(); // // ImGui::BeginGroup(); // ImGui::Text(_(u8"运行指示:%s").c_str(), cs.m_RunIndicate ? _(u8"是").c_str() : _(u8"否").c_str()); // ImGui::Text(_(u8"工作正常指示:%s").c_str(), cs.m_WorkIndicate ? _(u8"是").c_str() : _(u8"否").c_str()); // ImGui::Text(_(u8"压缩机指示:%s").c_str(), cs.m_CompressorIndicate ? _(u8"是").c_str() : _(u8"否").c_str()); // ImGui::Text(_(u8"水泵指示:%s").c_str(), cs.m_WaterPumpIndicate ? _(u8"是").c_str() : _(u8"否").c_str()); // ImGui::Text(_(u8"加热器指示:%s").c_str(), cs.m_HeaterIndicate ? _(u8"是").c_str() : _(u8"否").c_str()); // ImGui::Text(_(u8"风机指示:%s").c_str(), cs.m_FanIndicate ? _(u8"是").c_str() : _(u8"否").c_str()); // ImGui::Text(_(u8"电磁阀指示:%s").c_str(), cs.m_SolenoidValveIndicate ? _(u8"是").c_str() : _(u8"否").c_str()); // ImGui::Text(_(u8"低温错误指示:%s").c_str(), cs.m_LowTempErrorIndicate ? _(u8"是").c_str() : _(u8"否").c_str()); // ImGui::Text(_(u8"温度波动指示:%s").c_str(), cs.m_TempUndulateIndicate ? _(u8"是").c_str() : _(u8"否").c_str()); // ImGui::Text(_(u8"加热器异常指示:%s").c_str(), cs.m_HeaterExceptionIndicate ? _(u8"是").c_str() : _(u8"否").c_str()); // ImGui::Text(_(u8"IO信号指示:%s").c_str(), cs.m_IOSignalIndicate ? _(u8"是").c_str() : _(u8"否").c_str()); // ImGui::EndGroup(); // // ImGui::SameLine(); // ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); // ImGui::SameLine(); // // ImGui::BeginGroup(); // // if (cs.m_IsAlarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"报警:%s").c_str(), _(u8"否").c_str()); // // if (cs.m_FlowAlarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"流量报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"流量报警:%s").c_str(), _(u8"否").c_str()); // // if (cs.m_TempAlarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"温度报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"温度报警:%s").c_str(), _(u8"否").c_str()); // // if (cs.m_PressureAlarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"压力报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"压力报警:%s").c_str(), _(u8"否").c_str()); // // if (cs.m_WaterLevelAlarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"液位报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"液位报警:%s").c_str(), _(u8"否").c_str()); // // if (cs.m_TempSensorAlarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"温度传感器故障报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"温度传感器故障报警:%s").c_str(), _(u8"否").c_str()); // // if (cs.m_SolenoidValveAlarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"电磁阀故障报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"电磁阀故障报警:%s").c_str(), _(u8"否").c_str()); // // if (cs.m_PhaseSeqAlarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"相序报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"相序报警:%s").c_str(), _(u8"否").c_str()); // // if (cs.m_CompressorStartFreqAlarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"压缩机起动频繁报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"压缩机起动频繁报警:%s").c_str(), _(u8"否").c_str()); // // if (cs.m_IO0Alarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"IO0错误报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"IO0错误报警:%s").c_str(), _(u8"否").c_str()); // // if (cs.m_IO1Alarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"IO1错误报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"IO1错误报警:%s").c_str(), _(u8"否").c_str()); // // if (cs.m_IO2Alarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"IO2错误报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"IO2错误报警:%s").c_str(), _(u8"否").c_str()); // // if (cs.m_IO3Alarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"IO3错误报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"IO3错误报警:%s").c_str(), _(u8"否").c_str()); // // if (cs.m_IO4Alarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"IO4错误报警:%s").c_str(), _(u8"是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"IO4错误报警:%s").c_str(), _(u8"否").c_str()); // ImGui::EndGroup(); // } // else if ((*m_Type) == ExtCfg::TONGFEI) { // TongFeiStat tfs; // GetTongFeiStat(tfs); // // ImGui::BeginGroup(); // if (IsServerConnected()) { // ImGui::TextColored(ImVec4(0.0, 1.0, 0.0, 1.0), _(u8"端口连接:正常").c_str()); // } // else { // ImGui::TextColored(ImVec4(1.0, 0.0, 0.0, 1.0), _(u8"端口连接:断开").c_str()); // } // if (IsComConnected()) { // ImGui::TextColored(ImVec4(0.0, 1.0, 0.0, 1.0), _(u8"通讯连接:正常").c_str()); // } // else { // ImGui::TextColored(ImVec4(1.0, 0.0, 0.0, 1.0), _(u8"通讯连接:断开").c_str()); // } // // ImGui::Dummy(ImVec2(0, 10)); // ImGui::Text(_(u8"室温同调预设温度:%.1f ℃").c_str(), tfs.m_RoomTempSettingValue); // ImGui::Text(_(u8"恒温预设温度:%.1f ℃").c_str(), tfs.m_ConstantTempSettingValue); // string workModeStr = _(u8"未知").c_str(); // if (tfs.m_WorkMode==0) { // workModeStr = _(u8"手动").c_str(); // } // else if (tfs.m_WorkMode == 1) { // workModeStr = _(u8"自动").c_str(); // } // else if (tfs.m_WorkMode == 2) { // workModeStr = _(u8"机外").c_str(); // } // // ImGui::Text(_(u8"工作模式:%s").c_str(), workModeStr.c_str()); // string refrigerationMethod = _(u8"未知").c_str(); // if (tfs.m_RefrigerationMethod == 0) { // refrigerationMethod = _(u8"室温同调").c_str(); // } // else if (tfs.m_RefrigerationMethod == 1) { // refrigerationMethod = _(u8"恒温控制").c_str(); // } // ImGui::Text(_(u8"制冷方式:%s").c_str(), refrigerationMethod.c_str()); // ImGui::Text(_(u8"出液报警温度:%.1f ℃").c_str(), tfs.m_LiquidAlarmTemp); // // string unitStatus = _(u8"未知").c_str(); // if (tfs.m_UnitStatus == 0) { // unitStatus = _(u8"停止").c_str(); // } // else if (tfs.m_UnitStatus == 1) { // unitStatus = _(u8"运行").c_str(); // } // else if (tfs.m_UnitStatus == 2) { // unitStatus = _(u8"停机中").c_str(); // } // else if (tfs.m_UnitStatus == 3) { // unitStatus = _(u8"防冻中").c_str(); // } // else if (tfs.m_UnitStatus == 4) { // unitStatus = _(u8"无流量").c_str(); // } // ImGui::Text(_(u8"机组状态:%s").c_str(), unitStatus.c_str()); // // ImGui::Text(_(u8"液温温度探头:%.2f ℃").c_str(), tfs.m_LiquidTempProbe); // ImGui::Text(_(u8"出液温度探头:%.1f ℃").c_str(), tfs.m_EffluentTempProbe); // ImGui::Text(_(u8"环境温度探头:%.1f ℃").c_str(), tfs.m_AmbientTempProbe); // ImGui::Text(_(u8"冷凝温度探头:%.1f ℃").c_str(), tfs.m_CondensationTempProbe); // ImGui::Text(_(u8"蒸发进口温度探头:%.1f ℃").c_str(), tfs.m_EvaporationInletTempProbe); // ImGui::Text(_(u8"蒸发出口温度探头:%.1f ℃").c_str(), tfs.m_EvaporationOutletTempProbe); // // ImGui::Text(_(u8"运行频率:%.1f Hz").c_str(), tfs.m_WorkingFrequency); // ImGui::Text(_(u8"过热度:%.1f ℃").c_str(), tfs.m_OverHeatingValue); // ImGui::Text(_(u8"戴流EEV:%.1f").c_str(), tfs.m_EEV1); // ImGui::Text(_(u8"旁通EEV:%.1f").c_str(), tfs.m_EEV2); // ImGui::Text(_(u8"冷凝风机比例:%.1f").c_str(), tfs.m_CondensingFanRatio); // ImGui::Text(_(u8"电加热比例:%.1f").c_str(), tfs.m_ElectricHeatingRatio); // ImGui::Text(_(u8"流量:%.1f").c_str(), tfs.m_FlowRate); // // ImGui::EndGroup(); // // ImGui::SameLine(); // ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); // ImGui::SameLine(); // // ImGui::BeginGroup(); // string alarmStateStr = _(u8"未知").c_str(); // if (tfs.m_AlarmState == 0) { // alarmStateStr = _(u8"正常").c_str(); // } // else if (tfs.m_AlarmState == 1) { // alarmStateStr = _(u8"故障").c_str(); // } // else if (tfs.m_AlarmState == 2) { // alarmStateStr = _(u8"信号等待").c_str(); // } // ImGui::Text(_(u8"故障状态:%s").c_str(), alarmStateStr.c_str()); // // if (tfs.m_IsLowVoltageAlarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"低压报警:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"低压报警:否").c_str()); // // if (tfs.m_IsHydraulicFailure)ImGui::TextColored(Toast::COLOR_RED, _(u8"液路故障:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"液路故障:否").c_str()); // // if (tfs.m_IsLevelFailure)ImGui::TextColored(Toast::COLOR_RED, _(u8"液位故障:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"液位故障:否").c_str()); // // if (tfs.m_IsLiquidPumpAlarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"液泵热继电器报警:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"液泵热继电器报警:否").c_str()); // // if (tfs.m_IsPressAlarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"压机热继电器报警:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"压机热继电器报警:否").c_str()); // // if (tfs.m_IsElectricHeatingFailure)ImGui::TextColored(Toast::COLOR_RED, _(u8"电加热故障:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"电加热故障:否").c_str()); // // if (tfs.m_IsAntifreezeAlarm)ImGui::TextColored(Toast::COLOR_RED, _(u8"防冻报警:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"防冻报警:否").c_str()); // // if (tfs.m_IsLiquidTempTooHigh)ImGui::TextColored(Toast::COLOR_RED, _(u8"液温太高:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"液温太高:否").c_str()); // // if (tfs.m_IsLiquidTempProbeFailure)ImGui::TextColored(Toast::COLOR_RED, _(u8"液温温度探头故障:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"液温温度探头故障:否").c_str()); // // if (tfs.m_IsEffluentTempProbeFailure)ImGui::TextColored(Toast::COLOR_RED, _(u8"出液温度探头故障:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"出液温度探头故障:否").c_str()); // // if (tfs.m_IsAmbientTempProbeFailure)ImGui::TextColored(Toast::COLOR_RED, _(u8"环境温度探头故障:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"环境温度探头故障:否").c_str()); // // if (tfs.m_IsCondensationTempProbeFailure)ImGui::TextColored(Toast::COLOR_RED, _(u8"冷凝温度探头故障:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"冷凝温度探头故障:否").c_str()); // // if (tfs.m_IsEvaporationInletTempProbeFailure)ImGui::TextColored(Toast::COLOR_RED, _(u8"蒸发进口温度探头故障:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"蒸发进口温度探头故障:否").c_str()); // // if (tfs.m_IsEvaporationOutletTempProbeFailure)ImGui::TextColored(Toast::COLOR_RED, _(u8"蒸发出口温度探头故障:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"蒸发出口温度探头故障:否").c_str()); // // if (tfs.m_IsCondensationTempTooHigh)ImGui::TextColored(Toast::COLOR_RED, _(u8"冷凝温度过高:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"冷凝温度过高:否").c_str()); // // if (tfs.m_IsPhaseOrderError)ImGui::TextColored(Toast::COLOR_RED, _(u8"相序错误:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"相序错误:否").c_str()); // // if (tfs.m_IsPowerFailure)ImGui::TextColored(Toast::COLOR_RED, _(u8"电源故障:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"电源故障:否").c_str()); // // if (tfs.m_IsCompressorFailure)ImGui::TextColored(Toast::COLOR_RED, _(u8"压缩机故障:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"压缩机故障:否").c_str()); // // if (tfs.m_IsAmbientTempTooHigh)ImGui::TextColored(Toast::COLOR_RED, _(u8"环境温度太高:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"环境温度太高:否").c_str()); // // if (tfs.m_IsAmbientTempException)ImGui::TextColored(Toast::COLOR_RED, _(u8"环境温度异常:是").c_str()); // else ImGui::TextColored(Toast::COLOR_GREEN, _(u8"环境温度异常:否").c_str()); // // ImGui::EndGroup(); // } // ImGui::End(); //} void ChillerClient::ProcTongfeiAlarmInputInfo(void* pobject, Command* pcommand) { if (pobject == NULL)return; ChillerClient* cc = (ChillerClient*)pobject; unsigned char* rseq = pcommand->m_RespSeq; bitset<8> arr1(rseq[3]); bitset<8> arr2(rseq[4]); bitset<8> arr3(rseq[5]); EnterCriticalSection(&cc->m_ValueCS); cc->m_TongFeiStat.m_IsLowVoltageAlarm = arr1[0]; cc->m_TongFeiStat.m_IsHydraulicFailure = arr1[1]; cc->m_TongFeiStat.m_IsLevelFailure = arr1[2]; cc->m_TongFeiStat.m_IsLiquidPumpAlarm = arr1[3]; cc->m_TongFeiStat.m_IsPressAlarm = arr1[4]; cc->m_TongFeiStat.m_IsElectricHeatingFailure = arr1[5]; cc->m_TongFeiStat.m_IsAntifreezeAlarm = arr1[6]; cc->m_TongFeiStat.m_IsLiquidTempTooHigh = arr1[7]; cc->m_TongFeiStat.m_IsLiquidTempProbeFailure = arr2[0]; cc->m_TongFeiStat.m_IsEffluentTempProbeFailure = arr2[1]; cc->m_TongFeiStat.m_IsAmbientTempProbeFailure = arr2[2]; cc->m_TongFeiStat.m_IsCondensationTempProbeFailure = arr2[3]; cc->m_TongFeiStat.m_IsEvaporationInletTempProbeFailure = arr2[4]; cc->m_TongFeiStat.m_IsEvaporationOutletTempProbeFailure = arr2[5]; cc->m_TongFeiStat.m_IsCondensationTempTooHigh = arr2[6]; cc->m_TongFeiStat.m_IsPhaseOrderError = arr2[7]; cc->m_TongFeiStat.m_IsPowerFailure = arr3[0]; cc->m_TongFeiStat.m_IsCompressorFailure = arr3[1]; cc->m_TongFeiStat.m_IsAmbientTempTooHigh = arr3[2]; cc->m_TongFeiStat.m_IsAmbientTempException = arr3[3]; LeaveCriticalSection(&cc->m_ValueCS); } void ChillerClient::ProcTongfeiAlarmStateInfo(void* pobject, Command* pcommand) { if (pobject == NULL)return; ChillerClient* cc = (ChillerClient*)pobject; unsigned char* rseq = pcommand->m_RespSeq; short state1 = (((rseq[3] & 0xff) << 8) + (rseq[4] & 0xff)); EnterCriticalSection(&cc->m_ValueCS); cc->m_TongFeiStat.m_AlarmState = state1; LeaveCriticalSection(&cc->m_ValueCS); } void ChillerClient::ProcTongfeiUserParamsInfo(void* pobject, Command* pcommand) { if (pobject == NULL)return; ChillerClient* cc = (ChillerClient*)pobject; unsigned char* rseq = pcommand->m_RespSeq; short roomTempSettingValue = (((rseq[3] & 0xff) << 8) + (rseq[4] & 0xff)); short constantTempSettingValue = (((rseq[5] & 0xff) << 8) + (rseq[6] & 0xff)); short workMode = (((rseq[7] & 0xff) << 8) + (rseq[8] & 0xff)); short refrigerationMethod = (((rseq[9] & 0xff) << 8) + (rseq[10] & 0xff)); short liquidAlarmTemp = (((rseq[11] & 0xff) << 8) + (rseq[12] & 0xff)); EnterCriticalSection(&cc->m_ValueCS); cc->m_TongFeiStat.m_RoomTempSettingValue = (float)roomTempSettingValue/10.0f; cc->m_TongFeiStat.m_ConstantTempSettingValue = (float)constantTempSettingValue / 10.0f; cc->m_TongFeiStat.m_WorkMode = workMode; cc->m_TongFeiStat.m_RefrigerationMethod = refrigerationMethod; cc->m_TongFeiStat.m_LiquidAlarmTemp = (float)liquidAlarmTemp / 10.0f; LeaveCriticalSection(&cc->m_ValueCS); } void ChillerClient::ProcTongfeiAnaShowInfo(void* pobject, Command* pcommand) { if (pobject == NULL)return; ChillerClient* cc = (ChillerClient*)pobject; unsigned char* rseq = pcommand->m_RespSeq; short liquidTempProbe = (((rseq[3] & 0xff) << 8) + (rseq[4] & 0xff)); short effluentTempProbe = (((rseq[5] & 0xff) << 8) + (rseq[6] & 0xff)); short ambientTempProbe = (((rseq[7] & 0xff) << 8) + (rseq[8] & 0xff)); short condensationTempProbe = (((rseq[9] & 0xff) << 8) + (rseq[10] & 0xff)); short evaporationInletTempProbe = (((rseq[11] & 0xff) << 8) + (rseq[12] & 0xff)); short evaporationOutletTempProbe = (((rseq[13] & 0xff) << 8) + (rseq[14] & 0xff)); short unitStatus = (((rseq[19] & 0xff) << 8) + (rseq[20] & 0xff)); EnterCriticalSection(&cc->m_ValueCS); cc->m_TongFeiStat.m_LiquidTempProbe = (float)liquidTempProbe/10.0f; cc->m_TongFeiStat.m_EffluentTempProbe = (float)effluentTempProbe / 10.0f; cc->m_TongFeiStat.m_AmbientTempProbe = (float)ambientTempProbe / 10.0f; cc->m_TongFeiStat.m_CondensationTempProbe = (float)condensationTempProbe / 10.0f; cc->m_TongFeiStat.m_EvaporationInletTempProbe = (float)evaporationInletTempProbe / 10.0f; cc->m_TongFeiStat.m_EvaporationOutletTempProbe = (float)evaporationOutletTempProbe / 10.0f; cc->m_TongFeiStat.m_UnitStatus = unitStatus; LeaveCriticalSection(&cc->m_ValueCS); } void ChillerClient::ProcTongfeiAnaShowInfo2(void* pobject, Command* pcommand) { if (pobject == NULL)return; ChillerClient* cc = (ChillerClient*)pobject; unsigned char* rseq = pcommand->m_RespSeq; short WorkingFrequency = (((rseq[3] & 0xff) << 8) + (rseq[4] & 0xff)); short OverHeatingValue = (((rseq[5] & 0xff) << 8) + (rseq[6] & 0xff)); short EEV1 = (((rseq[7] & 0xff) << 8) + (rseq[8] & 0xff)); short EEV2 = (((rseq[9] & 0xff) << 8) + (rseq[10] & 0xff)); EnterCriticalSection(&cc->m_ValueCS); cc->m_TongFeiStat.m_WorkingFrequency = (float)WorkingFrequency / 10.0f; cc->m_TongFeiStat.m_OverHeatingValue = (float)OverHeatingValue / 10.0f; cc->m_TongFeiStat.m_EEV1 = (float)EEV1/10.0f; cc->m_TongFeiStat.m_EEV2 = (float)EEV2/10.0f; LeaveCriticalSection(&cc->m_ValueCS); } void ChillerClient::ProcTongfeianaShowInfo3(void* pobject, Command* pcommand) { if (pobject == NULL)return; ChillerClient* cc = (ChillerClient*)pobject; unsigned char* rseq = pcommand->m_RespSeq; short CondensingFanRatio = (((rseq[3] & 0xff) << 8) + (rseq[4] & 0xff)); short ElectricHeatingRatio = (((rseq[5] & 0xff) << 8) + (rseq[6] & 0xff)); short FlowRate = (((rseq[11] & 0xff) << 8) + (rseq[12] & 0xff)); EnterCriticalSection(&cc->m_ValueCS); cc->m_TongFeiStat.m_CondensingFanRatio = (float)CondensingFanRatio / 10.0f; cc->m_TongFeiStat.m_ElectricHeatingRatio = (float)ElectricHeatingRatio / 10.0f; cc->m_TongFeiStat.m_FlowRate = (float)FlowRate/10.0f; LeaveCriticalSection(&cc->m_ValueCS); }