362 lines
10 KiB
C++
362 lines
10 KiB
C++
#pragma once
|
|
#include <string>
|
|
#include <vector>
|
|
#include "../config/bean/IOCfg.h"
|
|
#include "../config/bean/AlarmCfg.h"
|
|
#include "../config/bean/AxisCfg.h"
|
|
#include "../config/bean/SystemBase.h"
|
|
#include "../config/bean/CoverCfg.h"
|
|
#include "../config/bean/ExtCfg.h"
|
|
#include "../config/bean/CommunicationCfg.h"
|
|
#include "../config/bean/MachineCfg.h"
|
|
#include "../config/bean/ParamLimitCfg.h"
|
|
#include "../Communication/IPGLaserClient.h"
|
|
//#include "../Purifier/BasePurifier.h"
|
|
#include "../PLC/SignalState.h"
|
|
#include "../PLC/MachineCtrl.h"
|
|
//#include "../UI/UIBean.h"
|
|
#include "../PLC/Axis.h"
|
|
#include <bitset>
|
|
#include "../DataManage/ClientInfo.h"
|
|
#include "../LanguageManager.h"
|
|
using namespace std;
|
|
|
|
struct MACHINEPARAM {
|
|
int m_LoadInResut;
|
|
string m_LoadInfo;
|
|
int m_LoadOutResut;
|
|
int m_LoadInProcStep;
|
|
int m_LoadOutProcStep;
|
|
bool m_isLoadIn; //绑定m_LoadInThread
|
|
bool m_isLoadOut; //绑定m_LoadOutThread
|
|
bool m_WaitConnectBoxCommit;
|
|
bool m_NeedWaitSelectOutPos;
|
|
bool m_WaitSelectOutPosCommit;
|
|
int m_SelectOutPos;
|
|
};
|
|
|
|
enum MACHINEFUNC {
|
|
LOADIN = 0, //载入
|
|
LOADOUT, //载出
|
|
INTERCEPTLOAD, //中断载入/载出
|
|
SUPPLYAXLEAFTER, //供粉轴后移
|
|
SUPPLYAXLEFRONT, //供粉轴前移
|
|
SUPPLYAXLEAFTERCONTSTART, //供粉轴后移连续开始
|
|
SUPPLYAXLEAFTERCONTSTOP, //供粉轴后移连续停止
|
|
SUPPLYAXLEFRONTCONTSTART, //供粉轴前移连续开始
|
|
SUPPLYAXLEFRONTCONTSTOP, //供粉轴前移连续停止
|
|
PAVEAXLEFRONT, // 铺粉臂前移
|
|
PAVEAXLEFRONTCONTSTART, //铺粉臂前移连续
|
|
PAVEAXLEFRONTCONTSTOP, //铺粉臂前移连续
|
|
PAVEAXLEAFTER, //铺粉臂后移
|
|
PAVEAXLEAFTERCONTSTART, //铺粉臂后移连续开始
|
|
PAVEAXLEAFTERCONTSTOP, //铺粉臂后移连续停止
|
|
PAVEAXLECLEAR, //铺粉臂清零
|
|
PRINTAXLEUP, //成型缸上升
|
|
PRINTAXLEUPCONTSTART, //成型缸连续上升开始
|
|
PRINTAXLEUPCONTSTOP, //成型缸连续上升停止
|
|
PRINTAXLEDOWN, //成型缸下降
|
|
PRINTAXLEDOWNCONTSTART, //成型缸连续下降开始
|
|
PRINTAXLEDOWNCONTSTOP, //成型缸连续下降停止
|
|
PRINTAXLECLEAR, //成型缸清零
|
|
TRANSFERAXIELEFT, //移载轴左移
|
|
TRANSFERAXIELEFTCONTSTART, //移载轴连续左移开始
|
|
TRANSFERAXIELEFTCONTSTOP, //移载轴连续左移停止
|
|
TRANSFERAXIERIGHT, //移载轴右移
|
|
TRANSFERAXIERIGHTCONTSTART, //移载轴连续右移开始
|
|
TRANSFERAXIERIGHTCONTSTOP, //移载轴连续右移停止
|
|
TRANSFERAXIECLEAR, //移载轴清零
|
|
|
|
END, //结束标记
|
|
};
|
|
|
|
|
|
class Machine :public Base {
|
|
typedef void(*IoVersionCheck)(vector<string>&, IOCfgWrapper*, string str, int type);
|
|
public:
|
|
Machine(MachineTypeCfg::MachineTypeId type);
|
|
virtual ~Machine();
|
|
static Machine* CreateInstance(int type);
|
|
|
|
virtual void Init();
|
|
virtual string GetFindIOStr();
|
|
virtual string GetInsertIOStr();
|
|
virtual void GetStartupIO(vector<IOCfg*>& vec);
|
|
virtual void BindLaser();
|
|
virtual void CheckIO(vector<string>&ins, IOCfgWrapper* iocfgWrapper , int vid);
|
|
//virtual void CheckIO_NEW(vector<string>&ins, IOCfgWrapper* iocfgWrapper) = 0;
|
|
//virtual void DrawIO(bool* isShow);
|
|
|
|
virtual AxisCfg* CreateMoldAxisCfg() = 0;
|
|
virtual AxisCfg* CreateLoadAxisCfg() = 0;
|
|
virtual AxisCfg* CreateArmAxisCfg() = 0;
|
|
virtual AxisCfg* CreateSupplyAxisCfg() = 0;
|
|
virtual AxisCfg* CreateCleanAxisCfg() = 0;
|
|
virtual AxisCfg* CreateEleAxisCfg();
|
|
|
|
static void InitMachineCfg(MachineCfg* cfg);
|
|
|
|
//virtual void CheckStopAlarm(vector<string>&ins, AlarmCfgWrapper* alarmWrapper);
|
|
//virtual void CheckPauseAlarm(vector<string>&ins, AlarmCfgWrapper* alarmWrapper);
|
|
//virtual void CheckWarnAlarm(vector<string>&ins, AlarmCfgWrapper* alarmWrapper);
|
|
|
|
//virtual void Machine::CheckAlarm()
|
|
//{
|
|
//}
|
|
//virtual void CheckCoverCfgWhenCreate(CoverCfg* cfg) {}
|
|
//virtual void CheckExtCfgWhenCreate(ExtCfg* cfg) {}
|
|
//virtual void CheckRunCfgWhenCreate(RunCfg* cfg) {}
|
|
//virtual void InitScanParamBeforeFind(ScanCfgWrapper* cfgWrapper) {}
|
|
|
|
// virtual void CheckRealtimeAlarm();
|
|
virtual void ReleaseGTExt(){}
|
|
virtual void InitGTExt(){}
|
|
virtual void AutoCtrlLamp(){}
|
|
virtual void GetDebugRTC(vector<CardSerialPair>& vec) {
|
|
CardSerialPair pair;
|
|
pair.cardNo = 1;
|
|
pair.serialNo = 123456;
|
|
vec.push_back(pair);
|
|
|
|
CardSerialPair pair2;
|
|
pair2.cardNo = 2;
|
|
pair2.serialNo = 234567;
|
|
vec.push_back(pair2);
|
|
|
|
CardSerialPair pair3;
|
|
pair3.cardNo = 3;
|
|
pair3.serialNo = 345678;
|
|
vec.push_back(pair3);
|
|
|
|
CardSerialPair pair4;
|
|
pair4.cardNo = 4;
|
|
pair4.serialNo = 456789;
|
|
vec.push_back(pair4);
|
|
}
|
|
|
|
//void SetPurifier(BasePurifier* bp) { m_Purifier = bp; }
|
|
|
|
//virtual void DrawSignal(bool *isshow)=0;
|
|
|
|
//virtual void DrawAxisCfg() = 0;
|
|
|
|
//virtual void DrawPowderCtrl(bool* winShow) = 0;
|
|
|
|
//virtual void DrawAnalogExt();
|
|
|
|
//virtual void DrawServoState(bool* winShow) = 0;
|
|
|
|
void SetAxisAndSignal(SysParamWrapper* sysParamWrapper,AxisRecordWrapper* axisRecordWrapper, PLCAxis* axis)
|
|
{
|
|
m_SysParamWrapper = sysParamWrapper;
|
|
m_AxisRecordWrapper = axisRecordWrapper;
|
|
m_Axis = axis;
|
|
}
|
|
|
|
void SetMachineCtrl(MachineCtrl* mc) {
|
|
m_MachineCtrl = mc;
|
|
}
|
|
|
|
virtual void InitSignal(SignalStateWrapper* ssw, PLCReveiver* cc) = 0;
|
|
|
|
virtual void InitSysParam(SysParamWrapper* spw, PLCReveiver* cc) = 0;
|
|
|
|
virtual void InitPLCCommand(vector<S7Command*>& vecs) = 0;
|
|
|
|
//virtual void GetAlarmState(SignalState& signalState) = 0;
|
|
|
|
virtual void LoadIn();
|
|
virtual void LoadOut();
|
|
|
|
//virtual bool CheckPrintMoldReady() = 0;
|
|
|
|
virtual bool CheckPrintHigh(float jobhigh) {
|
|
return true;
|
|
}
|
|
|
|
virtual void LoadAxisMove(AxisConfig::ActiveDirect adr, bool isContinue = false, bool isStart = false); //移栽轴运动
|
|
virtual void SupplyAxisMove(AxisConfig::ActiveDirect adr, bool isContinue = false, bool isStart = false); //供粉轴运动
|
|
virtual void PrintAxisMove(AxisConfig::ActiveDirect adr, bool isContinue = false, bool isStart = false); //成型缸运动
|
|
virtual void ArmAxisMove(AxisConfig::ActiveDirect adr, bool isContinue = false, bool isStart = false); //铺粉臂运动
|
|
|
|
void InterceptLoad();
|
|
|
|
//void SendToClients();
|
|
|
|
|
|
void CallAxisFunc(const ReadData& msg); //轴运动函数
|
|
protected:
|
|
virtual void LoadOutRun() = 0;
|
|
virtual void LoadInRun() = 0;
|
|
|
|
void SetLoadInResult(int res,string info) {
|
|
{
|
|
std::unique_lock<std::shared_mutex> lock(m_mtx); // 获取写锁
|
|
m_LoadInResut->SetValue(res);
|
|
m_LoadInfo->SetValue(info);
|
|
}
|
|
|
|
SendToClients(LOADPARAMRSP);
|
|
}
|
|
|
|
void SetLoadOutResult(int res,string info) {
|
|
{
|
|
std::unique_lock<std::shared_mutex> lock(m_mtx); // 获取写锁
|
|
m_LoadOutResut->SetValue(res);
|
|
m_LoadInfo->SetValue(info);
|
|
}
|
|
|
|
SendToClients(LOADPARAMRSP);
|
|
}
|
|
|
|
bool GetMachineParam(MACHINEPARAM& mp) {
|
|
//EnterCriticalSection(&m_LoadCS);
|
|
std::shared_lock<std::shared_mutex> lock(m_mtx); // 获取读锁(共享锁)
|
|
mp.m_LoadInResut = m_LoadInResut->GetValue();
|
|
mp.m_LoadInfo = m_LoadInfo->GetValueStr();
|
|
mp.m_LoadOutResut = m_LoadOutResut->GetValue();
|
|
mp.m_LoadInProcStep = m_LoadInProcStep->GetValue();
|
|
mp.m_LoadOutProcStep = m_LoadOutProcStep->GetValue();
|
|
mp.m_isLoadIn = m_isLoadIn->GetValue();
|
|
mp.m_isLoadOut = m_isLoadOut->GetValue();
|
|
mp.m_WaitConnectBoxCommit = m_WaitConnectBoxCommit->GetValue();
|
|
mp.m_NeedWaitSelectOutPos = m_NeedWaitSelectOutPos->GetValue();
|
|
mp.m_WaitSelectOutPosCommit = m_WaitSelectOutPosCommit->GetValue();
|
|
mp.m_SelectOutPos = m_SelectOutPos->GetValue();
|
|
|
|
//LeaveCriticalSection(&m_LoadCS);
|
|
return true;
|
|
}
|
|
|
|
|
|
void SetLoadInProcStep(int res) {
|
|
{
|
|
std::unique_lock<std::shared_mutex> lock(m_mtx); // 获取写锁
|
|
m_LoadInProcStep->SetValue(res);
|
|
}
|
|
SendToClients(LOADPARAMRSP);
|
|
}
|
|
void SetLoadOutProcStep(int res) {
|
|
{
|
|
std::unique_lock<std::shared_mutex> lock(m_mtx); // 获取写锁
|
|
m_LoadOutProcStep->SetValue(res);
|
|
}
|
|
|
|
SendToClients(LOADPARAMRSP);
|
|
}
|
|
|
|
void SetIsLoadIn(bool res) {
|
|
{
|
|
std::unique_lock<std::shared_mutex> lock(m_mtx); // 获取写锁
|
|
m_isLoadIn->SetValue(res);
|
|
}
|
|
|
|
SendToClients(LOADPARAMRSP);
|
|
}
|
|
|
|
void SetIsLoadOut(bool res) {
|
|
{
|
|
std::unique_lock<std::shared_mutex> lock(m_mtx); // 获取写锁
|
|
m_isLoadOut->SetValue(res);
|
|
}
|
|
|
|
SendToClients(LOADPARAMRSP);
|
|
}
|
|
|
|
void SetWaitConnectBoxCommit(bool res) {
|
|
{
|
|
std::unique_lock<std::shared_mutex> lock(m_mtx); // 获取写锁
|
|
m_WaitConnectBoxCommit->SetValue(res);
|
|
}
|
|
|
|
SendToClients(LOADPARAMRSP);
|
|
}
|
|
|
|
void SetNeedWaitSelectOutPos(bool res) {
|
|
{
|
|
std::unique_lock<std::shared_mutex> lock(m_mtx); // 获取写锁
|
|
m_NeedWaitSelectOutPos->SetValue(res);
|
|
}
|
|
|
|
SendToClients(LOADPARAMRSP);
|
|
}
|
|
|
|
void SetWaitSelectOutPosCommit(bool res) {
|
|
{
|
|
std::unique_lock<std::shared_mutex> lock(m_mtx); // 获取写锁
|
|
m_WaitSelectOutPosCommit->SetValue(res);
|
|
}
|
|
|
|
SendToClients(LOADPARAMRSP);
|
|
}
|
|
|
|
void SetSelectOutPos(int res) {
|
|
{
|
|
std::unique_lock<std::shared_mutex> lock(m_mtx); // 获取写锁
|
|
m_SelectOutPos->SetValue(res);
|
|
}
|
|
|
|
SendToClients(LOADPARAMRSP);
|
|
}
|
|
|
|
|
|
private:
|
|
static DWORD WINAPI LoadOutProc(Machine* _this);
|
|
static DWORD WINAPI LoadInProc(Machine* _this);
|
|
protected:
|
|
MachineTypeCfg::MachineTypeId m_Type;
|
|
map<string, bool> m_AlarmEnableMap;
|
|
map<string, bool> m_CommunicationEnableMap;
|
|
uint64_t m_SSRCheckTick;
|
|
|
|
AlarmCfgWrapper* m_AlarmCfgWrapper;
|
|
IOCfgWrapper* m_IOCfgWrapper;
|
|
SysParamWrapper* m_SysParamWrapper;
|
|
PLCAxis* m_Axis;
|
|
MachineCtrl* m_MachineCtrl;
|
|
SignalState m_SignalState;
|
|
|
|
AxisRecordWrapper* m_AxisRecordWrapper;
|
|
SignalStateWrapper* m_SignalStateWrapper;
|
|
ExtCfg* m_ExtCfg;
|
|
RunCfg* m_RunCfg;
|
|
CoverCfg* m_CoverCfg;
|
|
ParamLimitCfg* m_ParamLimitCfg;
|
|
|
|
AxisCfg* m_MoldAxisCfg;
|
|
AxisCfg* m_LoadAxisCfg;
|
|
AxisCfg* m_ArmAxisCfg;
|
|
AxisCfg* m_SupplyAxisCfg;
|
|
AxisCfg* m_CleanAxisCfg;
|
|
//BasePurifier* m_Purifier;
|
|
|
|
map<int, IoVersionCheck> m_IoRef;
|
|
//PowderAssistBean m_PowderAssist;
|
|
|
|
PLCReveiver* m_PLC;
|
|
|
|
HANDLE m_LoadInThread;
|
|
HANDLE m_LoadOutThread;
|
|
bool m_LoadCtrlFlag;
|
|
|
|
|
|
IntData* m_LoadInResut;
|
|
StrData* m_LoadInfo;
|
|
IntData* m_LoadOutResut;
|
|
IntData* m_LoadInProcStep;
|
|
IntData* m_LoadOutProcStep;
|
|
BoolData* m_isLoadIn; //绑定m_LoadInThread
|
|
BoolData* m_isLoadOut; //绑定m_LoadOutThread
|
|
BoolData* m_WaitConnectBoxCommit;
|
|
BoolData* m_NeedWaitSelectOutPos;
|
|
BoolData* m_WaitSelectOutPosCommit;
|
|
IntData* m_SelectOutPos;
|
|
|
|
|
|
//CRITICAL_SECTION m_LoadCS;
|
|
vector<string> m_AxisTabs;
|
|
|
|
};
|
|
|
|
|