GrpcPrint/PrintS/SystemInfo.h

229 lines
4.3 KiB
C
Raw Permalink Normal View History

#pragma once
2024-03-19 17:45:12 +08:00
#include <windows.h>
#include <time.h>
#include <string>
#include <queue>
#include "PLC/EnvState.h"
using namespace std;
struct LaserParam
{
double laserPower;
double laserDefocus;
double laserSpeed;
LaserParam() {
laserPower = 0.0;
laserDefocus = 0.0;
laserSpeed = 0.0;
}
};
struct MStatue {
int64_t m_MoldPos; //脉冲数
int64_t m_PowderPos; //脉冲数
int64_t m_ArmPos; //脉冲数
int64_t m_TotalPrintTime; //打印时间 毫秒
//int64_t m_TotalLaserUsedTime; //出光时间 毫秒
2024-03-19 17:45:12 +08:00
MStatue() {
m_MoldPos=0;
m_PowderPos = 0;
m_ArmPos = 0;
//m_TotalLaserUsedTime = 0;
m_TotalPrintTime = 0;
}
};
struct StateBean
{
unsigned int layerIndex;
unsigned int maxLayerIndex;
float jobProgress;
vector<LaserParam*> laserParams;
double layerThick;
string systemState;
unsigned int jobCostMil;
unsigned int remainMil;
double realCostSeconds;
time_t currentTime;
explicit StateBean() {
jobProgress = 0.0f;
layerIndex = 0;
maxLayerIndex = 0;
remainMil = 0;
layerThick = 0;
jobCostMil = 0;
realCostSeconds = 0;
systemState = u8"停止";
2024-03-19 17:45:12 +08:00
time(&currentTime);
}
};
enum AutoPrintCtrlState {
NoAuto=0,
AutoPrint,
AutoPause
};
struct EnvInfo {
float m_OxygenRealTimeValue1;
float m_OxygenRealTimeValue2;
float m_WindValue;
float m_AnaWindValue;
float m_AmbientTemp;
float m_InnerTemp;
float m_PlatformTemp;
float m_PlatformTempSettingValue;
float m_WaterTemp;
float m_PrintPressure;
float m_AvgPrintPressure;
float m_MoldPos;
float m_LinearEncoderPos;
float m_PowderPos;
float m_ArmPos;
float m_SupplyPos;
float m_MoldLoadTorque;
float m_PowderLoadTorque;
float m_ArmLoadTorque;
float m_SupplyLoadTorque;
float m_PipeWaterTemp;
2024-03-19 17:45:12 +08:00
float m_FanVoltage;
float m_FanFrequency;
bool m_IsUpDownLimit; //升降限位
2024-03-19 17:45:12 +08:00
bool m_IsDedustingStopAlarm;
float m_PowderQty;
float m_ProtectGasPressure;
float m_PrintPowderPressureDif;
float m_PowderJarPressureDif;
bool m_IsOxygenSensorConnect;
bool m_IsChillerComConnect;
bool m_IsCameraConnect;
bool m_IsHeatingConnect;
bool m_IsFreqAlarm;
bool m_IsPurifierConnectAlarm;
float m_RemainPowder;
unsigned int jobCostMil;
unsigned int remainMil;
double realCostSeconds;
string m_CurrentAlarmInfo;
EnvState m_EnvState;
};
class SystemInfo
{
public:
SystemInfo();
~SystemInfo();
void LockInfo();
void UnlockInfo();
void GetEnvInfo(EnvInfo& envInfo);
void SetDedustingStopAlarm(bool bvalue);
bool IsDedustingStopAlarm();
float GetComPrintOxygen1() {
float rel = 0.0f;
LockInfo();
rel = m_ComPrintOxygen1;
UnlockInfo();
return rel;
}
float GetComPrintOxygen2() {
float rel = 0.0f;
LockInfo();
rel = m_ComPrintOxygen2;
UnlockInfo();
return rel;
}
float GetComOutsideOxygen() {
float rel = 0.0f;
LockInfo();
rel = m_ComOutsideOxygen;
UnlockInfo();
return rel;
}
float GetPowderQty();
float GetPrintPressure() {
float rel = 0.0f;
LockInfo();
rel = m_EnvState.m_PrintPressureAnalog;
UnlockInfo();
return rel;
}
float GetOxygenRealTimeMaxValue()
{
float value = 0.0f;
LockInfo();
value = (m_ComPrintOxygen1 > m_ComPrintOxygen2 ? m_ComPrintOxygen1 : m_ComPrintOxygen2);
UnlockInfo();
return value;
}
float GetOxygenRealTimeMinValue()
{
float value = 0.0f;
LockInfo();
value = (m_ComPrintOxygen1 < m_ComPrintOxygen2 ? m_ComPrintOxygen1 : m_ComPrintOxygen2);
UnlockInfo();
return value;
}
2024-03-19 17:45:12 +08:00
public:
StateBean m_StateBean;
MStatue m_MStatue;
CRITICAL_SECTION m_MStatueCS;
EnvState m_EnvState;
float m_ComPrintOxygen1; //通讯氧含量
2024-03-19 17:45:12 +08:00
float m_ComPrintOxygen2;
float m_ComOutsideOxygen;
float m_PrintTemp;
float m_PrintHumidity;
2024-03-19 17:45:12 +08:00
float m_WindValue;
float m_PlatformTemp;
float m_PlatformTempSettingValue;
float m_WaterTemp;
2024-03-19 17:45:12 +08:00
//float m_PrintPressure;
float m_PowderQtyPos;
float m_FanFrequency;
float m_PipeWaterTemp;
2024-03-19 17:45:12 +08:00
float m_MoldMainPos;
float m_MoldSlavePos;
float m_ArmPos;
bool m_IsOxygenSensorConnect;
bool m_IsHeatingConnect;
int64_t m_PrintRemainTime;
int64_t m_PauseRemainTime;
AutoPrintCtrlState m_AutoPrintCtrlState;
short m_TestAdc[5];
long m_TestOutputState;
long m_TestInputState;
long m_TestExtout1State;
long m_TestExtin1State;
bool m_IsDedustingStopAlarm;
string m_ProductVersion;
float m_RemainPowder;
bool m_PrintAirEvacuationNeedOpen;
bool m_PurifierCtrlPrintAirEvacuation;
2024-03-19 17:45:12 +08:00
CRITICAL_SECTION m_InfoCs;
};
extern SystemInfo* g_SystemInfo;