|
|
#include "StdAfx.h"
|
|
|
#include "Program_SZ_XL_TrackWorkFlow.h"
|
|
|
#include "GlobalFunction.h"
|
|
|
#include "CommonFlowMgr.h"
|
|
|
#include "ProductMgr.h"
|
|
|
#include "ProgramCutMgr.h"
|
|
|
#include "WorkCmdContainer.h"
|
|
|
#include "Program_SZ_XL.h"
|
|
|
#include "MotionCard_PCI1245.h"
|
|
|
#include "WorkCmdMoveMotor.h"
|
|
|
#include "WorkCmdInvoker.h"
|
|
|
#include "WorkCmdWaitMotorStop.h"
|
|
|
#include "WorkCmdSetMotorSpeed.h"
|
|
|
#include "ObjComponentMgr.h"
|
|
|
#include "LogMgr.h"
|
|
|
#include "MsgBox.h"
|
|
|
#include "WorkTime.h"
|
|
|
#include "FileMgr.h"
|
|
|
#include "Motor.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define PLC_READ_MSG_LEN 12 //接收PLC 数据的长度(字节)
|
|
|
|
|
|
#define TRACK_NAME_1 "轨道1"
|
|
|
#define TRACK_NAME_2 "轨道2"
|
|
|
int gStopTimes = 0;
|
|
|
//当前锁定的轨道
|
|
|
ETrackType gCurLockTrackType = _ETrackType_NULL;
|
|
|
|
|
|
CTrackWorkFlow gTrackWorkFlow1(TRACK_NAME_1);//轨道1 的流程管理
|
|
|
CTrackWorkFlow gTrackWorkFlow2(TRACK_NAME_2);//轨道2 的流程管理
|
|
|
|
|
|
#define TRACK1_RECORD_FILE "\\CutPar\\TrackRecord1.txt"
|
|
|
#define TRACK2_RECORD_FILE "\\CutPar\\TrackRecord2.txt"
|
|
|
|
|
|
|
|
|
//工作流程控制线程(无限循环)
|
|
|
UINT WorkFlowCtrlThread(LPVOID pParam)
|
|
|
{
|
|
|
CTrackWorkFlow *WorkFlow = (CTrackWorkFlow *)pParam;
|
|
|
WorkFlow->WorkFlowCtrl();
|
|
|
return 0;
|
|
|
}
|
|
|
//读取plc 消息的线程(无限循环)
|
|
|
UINT ReadPlcMsgThread(LPVOID pParam)
|
|
|
{
|
|
|
CTrackWorkFlow *WorkFlow = (CTrackWorkFlow *)pParam;
|
|
|
WorkFlow->ReadPlcMsg();
|
|
|
return 0;
|
|
|
}
|
|
|
//执行一个步骤的线程(执行一次)
|
|
|
UINT ExecuteStepThread(LPVOID pParam)
|
|
|
{
|
|
|
CTrackWorkFlow *WorkFlow = (CTrackWorkFlow *)pParam;
|
|
|
WorkFlow->ExecuteCurStep();
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
CTrackWorkFlow::CTrackWorkFlow(CString Name)
|
|
|
{
|
|
|
m_TrackName = Name;
|
|
|
m_ProductIdx = 0;//轨道对应产品工位的编号
|
|
|
//轨道的类型
|
|
|
if (m_TrackName == TRACK_NAME_1)
|
|
|
m_TrackType = _ETrackType_Track_1;
|
|
|
else
|
|
|
m_TrackType = _ETrackType_Track_2;
|
|
|
|
|
|
m_ComPort = 1;//通信用串口号
|
|
|
m_ComBaudRate = 115200;//通信用波特率
|
|
|
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Stop);//当前的工作步骤
|
|
|
m_OldWorkStep = _ETrack_Step_Stop;//之前的工作步骤
|
|
|
|
|
|
m_bStopReadMsg = false;//是否暂停读取plc 消息
|
|
|
m_bAutoWorking = false;//是否在自动加工
|
|
|
m_bLoadProduct = false;//轨道上是否load 了产品
|
|
|
m_ReadMsgDelay = 200;
|
|
|
m_CutProductCnt = 0;//切割产品的数量
|
|
|
m_bCircleStop = false;//当前循环后停止
|
|
|
|
|
|
}
|
|
|
CTrackWorkFlow::~CTrackWorkFlow(void)
|
|
|
{
|
|
|
}
|
|
|
//设置串口参数
|
|
|
void CTrackWorkFlow::SetComPar(int Port, int BaudRate)
|
|
|
{
|
|
|
m_ComPort = Port;//通信用串口号
|
|
|
m_ComBaudRate = BaudRate;//通信用波特率
|
|
|
}
|
|
|
|
|
|
#if 1
|
|
|
//启动工作流程管理
|
|
|
void CTrackWorkFlow::WorkFlowStart()
|
|
|
{
|
|
|
//启动WorkFlow 控制线程
|
|
|
AfxBeginThread(WorkFlowCtrlThread, this);
|
|
|
//打开plc 通信用串口
|
|
|
if (m_TrackCOM.Open(m_ComPort, m_ComBaudRate))
|
|
|
{
|
|
|
//启动读取plc 消息的线程
|
|
|
AfxBeginThread(ReadPlcMsgThread, this);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CString LogStr;
|
|
|
LogStr.Format(_T("TrackCOM %d 打开失败"), m_ComPort);
|
|
|
gLogMgr->WriteDebugLog(LogStr);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//工作流程控制
|
|
|
void CTrackWorkFlow::WorkFlowCtrl()
|
|
|
{
|
|
|
while (1)
|
|
|
{
|
|
|
if (gExitApp)
|
|
|
return;
|
|
|
Sleep(100);
|
|
|
if (m_CurWorkStep == m_OldWorkStep)//无变化
|
|
|
continue;
|
|
|
if (m_OldWorkStep == _ETrack_Step_Unload)//unload 结束步骤时
|
|
|
{
|
|
|
//取消下料请求
|
|
|
CancelUnloadRequest();
|
|
|
gStopTimes = 0;
|
|
|
}
|
|
|
m_OldWorkStep = m_CurWorkStep;//记录当前步骤
|
|
|
//在新线程中执行
|
|
|
AfxBeginThread(ExecuteStepThread, this);
|
|
|
}
|
|
|
}
|
|
|
//执行当前步骤
|
|
|
void CTrackWorkFlow::ExecuteCurStep()
|
|
|
{
|
|
|
if (gExitApp)
|
|
|
return;
|
|
|
switch (m_CurWorkStep)
|
|
|
{
|
|
|
/*case _ETrack_Step_Load_End://上料完成
|
|
|
MoveToWaitPos();//移动到等待位置
|
|
|
break;
|
|
|
case _ETrack_Step_Mark_Waiting://等待加工
|
|
|
CatchMark();//抓取定位
|
|
|
break;*/
|
|
|
case _ETrack_Step_Catch_mark_End://等待加工
|
|
|
MarkProcess();//计算,收集加工数据(服务端)
|
|
|
break;
|
|
|
/*case _ETrack_Step_Mark_End://加工完成
|
|
|
ThrowEdge();//去边框
|
|
|
break;
|
|
|
case _ETrack_Step_Throw_Edge_End://去边框完成
|
|
|
UnLoad();//下料
|
|
|
break;
|
|
|
case _ETrack_Step_Unload_End://下料完成
|
|
|
Load();//上料
|
|
|
break;
|
|
|
case _ETrack_Step_Load_Err://下料错误
|
|
|
case _ETrack_Step_Catch_mark_Err://抓取定位错误
|
|
|
case _ETrack_Step_Mark_Err://切割过程错误
|
|
|
case _ETrack_Step_Unload_Err://下料错误
|
|
|
case _ETrack_Step_Throw_Edge_Err://去边框错误
|
|
|
{
|
|
|
//解除锁定
|
|
|
if (m_TrackType == gCurLockTrackType)
|
|
|
gCurLockTrackType = _ETrackType_NULL;
|
|
|
//退出自动状态
|
|
|
StopAutoWork();
|
|
|
}
|
|
|
break;*/
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
void CTrackWorkFlow::SetCurTrackWorkStep(ETrackWorkStep Step)
|
|
|
{
|
|
|
if (m_CurWorkStep == _ETrack_Step_Load || m_CurWorkStep == _ETrack_Step_Throw_Edge)
|
|
|
{
|
|
|
if (Step == _ETrack_Step_Unload_End)
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("Canot Set Track_Step_Unload_End");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
m_CurWorkStep = Step;
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
#if 1
|
|
|
//启动自动加工
|
|
|
bool CTrackWorkFlow::StartAutoWork()
|
|
|
{
|
|
|
if (m_bAutoWorking)
|
|
|
{
|
|
|
if (m_CurWorkStep == _ETrack_Step_Unload)
|
|
|
{
|
|
|
if (gStopTimes < gProgram_SZ_XL->GetStopStepUnloadTimes())//连续点n 次可以强制停止
|
|
|
{
|
|
|
CMsgBox MsgBox;
|
|
|
MsgBox.Show("下料未完成不能停止!");
|
|
|
CString str;
|
|
|
str.Format("StopTimes = %ld", gStopTimes);
|
|
|
gLogMgr->WriteDebugLog(str);
|
|
|
gStopTimes++;
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
//停止自动加工
|
|
|
StopAutoWork();
|
|
|
return true;
|
|
|
}
|
|
|
gStopTimes = 0;//重新计数
|
|
|
//检测是否有定位mark
|
|
|
Dbxy MarkPt1;
|
|
|
Dbxy MarkPt2;
|
|
|
if (!gObjComponentMgr->GetTwoMarkPt(MarkPt1, MarkPt2))//获取定位点
|
|
|
{
|
|
|
CMsgBox MsgBox;
|
|
|
MsgBox.Show("没有加工图形!");
|
|
|
return false;
|
|
|
}
|
|
|
//设置自动运行状态
|
|
|
m_bAutoWorking = true;
|
|
|
if (gProgram_SZ_XL->IsbAutoWorkMode())//半自动模式不要自动开始
|
|
|
{
|
|
|
//如果load 了产品
|
|
|
if (m_bLoadProduct)
|
|
|
{
|
|
|
CMsgBox MsgBox;
|
|
|
if (MsgBox.ConfirmOkCancel("确定:继续切割,取消:重新上料"))
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Mark_Waiting);
|
|
|
else
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Unload_End);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Unload_End);//直接上料
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Load);
|
|
|
}
|
|
|
CString Log = m_TrackName + " 开始自动运行";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
return true;
|
|
|
}
|
|
|
//停止自动加工
|
|
|
void CTrackWorkFlow::StopAutoWork()
|
|
|
{
|
|
|
CString Log = m_TrackName + " 停止自动运行";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
|
|
|
m_bAutoWorking = false;
|
|
|
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Stop);
|
|
|
//取消下料请求
|
|
|
CancelUnloadRequest();
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
#if 1
|
|
|
//手动操作
|
|
|
void CTrackWorkFlow::ManualOperation(ETrackWorkStep TrackWorkStep)
|
|
|
{
|
|
|
//自动加工时不能手动操作(手动触发Load_End 例外)
|
|
|
if (m_bAutoWorking && TrackWorkStep != _ETrack_Step_Load_End)
|
|
|
{
|
|
|
CString Log = m_TrackName + " 自动运行中";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
return;
|
|
|
}
|
|
|
//手动触发Load_End 在自动模式下无效
|
|
|
if (TrackWorkStep == _ETrack_Step_Load_End && gProgram_SZ_XL->IsbAutoWorkMode())
|
|
|
return;
|
|
|
|
|
|
if (TrackWorkStep == _ETrack_Step_Load_End)
|
|
|
{
|
|
|
//夹紧载盘
|
|
|
ProductCarrierOpenClose(false);
|
|
|
}
|
|
|
|
|
|
SetCurTrackWorkStep(TrackWorkStep);
|
|
|
}
|
|
|
#endif
|
|
|
#if 1
|
|
|
//读取串口消息
|
|
|
void CTrackWorkFlow::ReadPlcMsg()
|
|
|
{
|
|
|
while (1)
|
|
|
{
|
|
|
if (gExitApp)
|
|
|
break;
|
|
|
if (m_bStopReadMsg)
|
|
|
{
|
|
|
Sleep(100);
|
|
|
continue;
|
|
|
}
|
|
|
ReadPlcMsgExt();
|
|
|
}
|
|
|
}
|
|
|
void CTrackWorkFlow::ReadPlcMsgExt()
|
|
|
{
|
|
|
Sleep(m_ReadMsgDelay);
|
|
|
char buf[PLC_READ_MSG_LEN];
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
int ReadBytes = m_TrackCOM.Read(buf, PLC_READ_MSG_LEN);
|
|
|
//分析命令内容
|
|
|
if (ReadBytes > 0)
|
|
|
{
|
|
|
AnalyzeRecvCmd(buf, PLC_READ_MSG_LEN);
|
|
|
}
|
|
|
}
|
|
|
//解析反馈指令
|
|
|
void CTrackWorkFlow::AnalyzeRecvCmd(char *buf, int len)
|
|
|
{
|
|
|
//找到# 的位置
|
|
|
int IdxEnd = -1;
|
|
|
for (int k = 0;k < len;k++)
|
|
|
{
|
|
|
if (buf[k] == '#')
|
|
|
{
|
|
|
IdxEnd = k;
|
|
|
CString s;
|
|
|
s.Format(_T("Idx # = %d"), IdxEnd);
|
|
|
gLogMgr->WriteDebugLog(s);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (IdxEnd < 0)//没找到
|
|
|
return;
|
|
|
|
|
|
if (IdxEnd != len - 1)
|
|
|
buf[IdxEnd + 1] = '\0';
|
|
|
|
|
|
CString PlcMsg(buf);
|
|
|
gLogMgr->WriteDebugLog("ReadPlcMsg--->" + PlcMsg);
|
|
|
|
|
|
int IdxK = -1;//第一个K 的位置
|
|
|
for (int k = 0;k < IdxEnd;k++)
|
|
|
{
|
|
|
if (buf[k] == 'K')
|
|
|
{
|
|
|
IdxK = k;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (IdxK < 0)
|
|
|
return;
|
|
|
|
|
|
if (PlcMsg.Find("$(KQ3D1)#") != -1 || PlcMsg.Find("$(KQ4D1)#") != -1)//下料完成
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("ReadPlcMsg--->_ETrack_Step_Unload_End");
|
|
|
if (m_CurWorkStep == _ETrack_Step_Unload)//只有下料状态才响应下料完成信号
|
|
|
{
|
|
|
if (m_bCircleStop)//当前循环停止
|
|
|
{
|
|
|
m_bCircleStop = false;//只停止一次
|
|
|
GetFrame()->m_DlgSW_XL_Flow.ResetCircleStopCheck(m_TrackType);//自动恢复check 状态
|
|
|
CString Log = m_TrackName + " Circle Stop";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
StopAutoWork();//停止自动运行
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Unload_End);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (PlcMsg.Find("$(KQ3E)#") != -1 || PlcMsg.Find("$(KQ4E)#") != -1)//下料错误
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Unload_Err);
|
|
|
gLogMgr->WriteDebugLog("ReadPlcMsg--->_ETrack_Step_Unload_Err");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
#if 1
|
|
|
//获取发送给plc 的字符串
|
|
|
CString CTrackWorkFlow::GetSendPlcMsgStr(ETrackPlcCmd PlcCmd)
|
|
|
{
|
|
|
CString log;
|
|
|
CString msg = "$(KQ";
|
|
|
if (PlcCmd == _ETrack_PlcCmd_Open_Product)//打开载盘
|
|
|
{
|
|
|
if (m_TrackType == _ETrackType_Track_1)
|
|
|
{
|
|
|
msg += "G";
|
|
|
log = "SendPlcMsg: Track_1 打开载盘";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
msg += "I";
|
|
|
log = "SendPlcMsg: Track_2 打开载盘";
|
|
|
}
|
|
|
}
|
|
|
if (PlcCmd == _ETrack_PlcCmd_Close_Product)//夹紧载盘
|
|
|
{
|
|
|
if (m_TrackType == _ETrackType_Track_1)
|
|
|
{
|
|
|
msg += "F";
|
|
|
log = "SendPlcMsg: Track_1 夹紧载盘";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
msg += "H";
|
|
|
log = "SendPlcMsg: Track_2 夹紧载盘";
|
|
|
}
|
|
|
}
|
|
|
if (PlcCmd == _ETrack_PlcCmd_Vac_Sorb_On)//真空吸附开
|
|
|
{
|
|
|
if (m_TrackType == _ETrackType_Track_1)
|
|
|
{
|
|
|
msg += "9";
|
|
|
log = "SendPlcMsg: Track_1 真空吸附开";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
msg += "B";
|
|
|
log = "SendPlcMsg: Track_2 真空吸附开";
|
|
|
}
|
|
|
}
|
|
|
if (PlcCmd == _ETrack_PlcCmd_Vac_Sorb_Off)//真空吸附关
|
|
|
{
|
|
|
if (m_TrackType == _ETrackType_Track_1)
|
|
|
{
|
|
|
msg += "A";
|
|
|
log = "SendPlcMsg: Track_1 真空吸附关";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
msg += "C";
|
|
|
log = "SendPlcMsg: Track_2 真空吸附关";
|
|
|
}
|
|
|
}
|
|
|
if (PlcCmd == _ETrack_PlcCmd_Auto_Start)//自动开始
|
|
|
{
|
|
|
msg += "5";
|
|
|
log = "SendPlcMsg: 自动开始";
|
|
|
}
|
|
|
if (PlcCmd == _ETrack_PlcCmd_Auto_End)//自动结束
|
|
|
{
|
|
|
msg += "6";
|
|
|
log = "SendPlcMsg: 自动结束";
|
|
|
}
|
|
|
if (PlcCmd == _ETrack_PlcCmd_Unload)//下料
|
|
|
{
|
|
|
if (m_TrackType == _ETrackType_Track_1)
|
|
|
{
|
|
|
msg += "3";
|
|
|
log = "SendPlcMsg: Track_1 下料";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
msg += "4";
|
|
|
log = "SendPlcMsg: Track_2 下料";
|
|
|
}
|
|
|
}
|
|
|
if (PlcCmd == _ETrack_PlcCmd_Cancel_Unload)//取消请求下料
|
|
|
{
|
|
|
if (m_TrackType == _ETrackType_Track_1)
|
|
|
{
|
|
|
msg += "D";
|
|
|
log = "SendPlcMsg: Track_1 取消请求下料";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
msg += "E";
|
|
|
log = "SendPlcMsg: Track_2 取消请求下料";
|
|
|
}
|
|
|
}
|
|
|
if (PlcCmd == _ETrack_PlcCmd_Red_Alam_On)//红灯蜂鸣器开
|
|
|
{
|
|
|
msg += "1";
|
|
|
log = "SendPlcMsg: 红灯蜂鸣器开";
|
|
|
}
|
|
|
if (PlcCmd == _ETrack_PlcCmd_Red_Alam_Off)//红灯蜂鸣器开
|
|
|
{
|
|
|
msg += "2";
|
|
|
log = "SendPlcMsg: 红灯蜂鸣器关";
|
|
|
}
|
|
|
gLogMgr->WriteDebugLog(log);
|
|
|
msg += ")#\r\n";
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
//发送指令给PLC (bStopReadMsg 是否暂停读取PLC 消息)
|
|
|
bool CTrackWorkFlow::SendMsgToPlc(ETrackPlcCmd PlcCmd, bool bStopReadMsg)
|
|
|
{
|
|
|
if (bStopReadMsg)
|
|
|
{
|
|
|
m_bStopReadMsg = true;//暂停读取
|
|
|
Sleep(300);
|
|
|
}
|
|
|
CString Msg = GetSendPlcMsgStr(PlcCmd);
|
|
|
if (m_TrackCOM.IsOpen())
|
|
|
{
|
|
|
char * buf = Msg.GetBuffer();
|
|
|
int len = Msg.GetLength();
|
|
|
m_TrackCOM.WriteBuf(buf, len);//发送
|
|
|
gLogMgr->WriteDebugLog("SendMsgToPlc--->" + Msg);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("Plc 串口连接失败!");
|
|
|
return false;
|
|
|
}
|
|
|
//等待PLC 反馈信号
|
|
|
bool Ret = true;
|
|
|
//Ret = WaitPlcRevMsg(PlcCmd);
|
|
|
if (bStopReadMsg)
|
|
|
{
|
|
|
m_bStopReadMsg = false;//恢复读取
|
|
|
}
|
|
|
Sleep(gProgram_SZ_XL->GetPlcCmdSendDelay());
|
|
|
return Ret;
|
|
|
}
|
|
|
//打开/夹紧载盘
|
|
|
void CTrackWorkFlow::ProductCarrierOpenClose(bool bOpen)
|
|
|
{
|
|
|
ETrackPlcCmd PlcCmd;
|
|
|
if (bOpen)
|
|
|
PlcCmd = _ETrack_PlcCmd_Open_Product;
|
|
|
else
|
|
|
PlcCmd = _ETrack_PlcCmd_Close_Product;
|
|
|
|
|
|
SendMsgToPlc(PlcCmd, false);
|
|
|
}
|
|
|
//真空吸附
|
|
|
void CTrackWorkFlow::VacSorbOnOff(bool bOn)
|
|
|
{
|
|
|
ETrackPlcCmd PlcCmd;
|
|
|
if (bOn)
|
|
|
PlcCmd = _ETrack_PlcCmd_Vac_Sorb_On;
|
|
|
else
|
|
|
PlcCmd = _ETrack_PlcCmd_Vac_Sorb_Off;
|
|
|
|
|
|
SendMsgToPlc(PlcCmd, false);
|
|
|
}
|
|
|
//红灯蜂鸣器
|
|
|
void CTrackWorkFlow::RadAlamOnOff(bool bOn)
|
|
|
{
|
|
|
ETrackPlcCmd PlcCmd;
|
|
|
if (bOn)
|
|
|
PlcCmd = _ETrack_PlcCmd_Red_Alam_On;
|
|
|
else
|
|
|
PlcCmd = _ETrack_PlcCmd_Red_Alam_Off;
|
|
|
|
|
|
SendMsgToPlc(PlcCmd, false);
|
|
|
}
|
|
|
|
|
|
//通知plc 自动开始或结束
|
|
|
void CTrackWorkFlow::SendAutoStartFlg(bool bStart)
|
|
|
{
|
|
|
if (m_TrackType == _ETrackType_Track_1)//用轨道1 串口控制
|
|
|
{
|
|
|
ETrackPlcCmd PlcCmd;
|
|
|
if (bStart)
|
|
|
PlcCmd = _ETrack_PlcCmd_Auto_Start;
|
|
|
else
|
|
|
PlcCmd = _ETrack_PlcCmd_Auto_End;
|
|
|
|
|
|
SendMsgToPlc(PlcCmd, false);
|
|
|
}
|
|
|
}
|
|
|
//取消下料请求
|
|
|
void CTrackWorkFlow::CancelUnloadRequest()
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog(m_TrackName + " CancelUnloadRequest");
|
|
|
SendMsgToPlc(_ETrack_PlcCmd_Cancel_Unload, false);
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
#if 1
|
|
|
//移动到位置
|
|
|
void CTrackWorkFlow::MoveToPos(ETrackWorkStep WorkStep)
|
|
|
{
|
|
|
double Coord = gProgram_SZ_XL->GetMoveCoord(m_TrackType, WorkStep);
|
|
|
|
|
|
CString MotorStr = (m_TrackType == _ETrackType_Track_1) ? (MOTOR_X) : (MOTOR_X2);
|
|
|
CMotor &Motor = *(CMotor::GetMotor(MotorStr));
|
|
|
|
|
|
CWorkCmdContainer CmdContainer;
|
|
|
//设置电机速度
|
|
|
{
|
|
|
CWorkCmdSetMotorSpeed *pCmd = new CWorkCmdSetMotorSpeed();
|
|
|
if (m_TrackType == _ETrackType_Track_1)
|
|
|
pCmd->SetbSetMotorX();
|
|
|
else
|
|
|
pCmd->SetbSetMotorX2();
|
|
|
pCmd->SetSpeedType(_SpeedType_Move);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//移动
|
|
|
{
|
|
|
CWorkCmdMoveMotor *pCmd = new CWorkCmdMoveMotor(Motor, Coord);
|
|
|
pCmd->SetMoveFlg(false);//移动到坐标
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//等待移动结束
|
|
|
{
|
|
|
CWorkCmdWaitMotorStop *pCmd = new CWorkCmdWaitMotorStop();
|
|
|
if (m_TrackType == _ETrackType_Track_1)
|
|
|
pCmd->SetbWaitMotorX();
|
|
|
else
|
|
|
pCmd->SetbWaitMotorX2();
|
|
|
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
CWorkCmdInvoker WorkInvoker;//工作调度者
|
|
|
WorkInvoker.Excute(CmdContainer);
|
|
|
|
|
|
Motor.NotifyObservers();
|
|
|
}
|
|
|
//上料
|
|
|
void CTrackWorkFlow::Load()
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Load);
|
|
|
//平台移动到上料位置
|
|
|
if (gProgram_SZ_XL->IsbAutoWorkMode())//自动模式
|
|
|
{
|
|
|
//夹紧载盘
|
|
|
ProductCarrierOpenClose(false);
|
|
|
MoveToPos(_ETrack_Step_Load);
|
|
|
}
|
|
|
else//手动模式移动到unload 的位置
|
|
|
{
|
|
|
MoveToPos(_ETrack_Step_Unload);
|
|
|
}
|
|
|
CString Log = m_TrackName + " Load";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
|
|
|
if (gProgram_SZ_XL->IsbShieldLoad())//屏蔽上料
|
|
|
{
|
|
|
if (m_bAutoWorking)//自动生产中
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Load_End);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Load_Stop);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
if (gProgram_SZ_XL->IsbAutoWorkMode())//自动模式
|
|
|
{
|
|
|
//发送上料信号给上料PLC
|
|
|
if (gProgram_SZ_XL->SendMsgToLoadDevice(m_TrackType, _ETrack_Step_Load, true) == false)
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Load_Err);
|
|
|
Log = m_TrackName + " Load Err";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (m_bAutoWorking)//自动生产中
|
|
|
{
|
|
|
//等待PLC 上料完成
|
|
|
while (1)
|
|
|
{
|
|
|
if (m_CurWorkStep == _ETrack_Step_Load_End)
|
|
|
break;
|
|
|
Sleep(200);
|
|
|
}
|
|
|
Log = m_TrackName + " Load End";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
}
|
|
|
else//半自动模式直接上料结束
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Load_Stop);
|
|
|
Log = m_TrackName + " Load Stop";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
}
|
|
|
}
|
|
|
//移动到等待位置
|
|
|
void CTrackWorkFlow::MoveToWaitPos()
|
|
|
{
|
|
|
CString Log = m_TrackName + " MoveToWaitPos";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
|
|
|
SetCurTrackWorkStep(_ETrack_Step_To_Wait_Pos);
|
|
|
MoveToPos(_ETrack_Step_To_Wait_Pos);
|
|
|
|
|
|
if (m_bAutoWorking)
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Mark_Waiting);
|
|
|
Log = m_TrackName + " Mark Waiting";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
m_bLoadProduct = true;//轨道上是否load 了产品
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Stop);
|
|
|
}
|
|
|
}
|
|
|
//切换平台XY 组编号
|
|
|
void CTrackWorkFlow::ChangePlatXYGroupIdx()
|
|
|
{
|
|
|
int idx = (m_TrackType == _ETrackType_Track_1) ? 0 : 1;
|
|
|
gMotionCard_PCI1245->SetCurGpIdx(idx);
|
|
|
}
|
|
|
//抓取定位,并计算偏移和旋转
|
|
|
void CTrackWorkFlow::CatchMark()
|
|
|
{
|
|
|
//只有无锁定状态才能CatchMark
|
|
|
/*if (gCurLockTrackType != _ETrackType_NULL)
|
|
|
{
|
|
|
m_OldWorkStep = _ETrack_Step_NULL;//强制改变之前的状态
|
|
|
return;
|
|
|
}
|
|
|
gCurLockTrackType = m_TrackType;//锁定当前轨道
|
|
|
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Catch_mark);
|
|
|
CString Log = m_TrackName + " CatchMark";
|
|
|
gLogMgr->WriteDebugLog(Log);*/
|
|
|
|
|
|
/*//真空吸附
|
|
|
VacSorbOnOff(true);
|
|
|
|
|
|
bool Ret = true;
|
|
|
if (gProgram_SZ_XL->IsbShieldMarking() == false)//屏蔽加工过程
|
|
|
{
|
|
|
//切换平台XY 组编号
|
|
|
ChangePlatXYGroupIdx();
|
|
|
/ *CProduct &Product = gServer->m_RcvProduct;
|
|
|
//将数据移动到当前product 的基准点上
|
|
|
Dbxy BasePt = Product.GetProductBasePt();
|
|
|
//轨道2 要偏移基准点
|
|
|
if (m_TrackType == _ETrackType_Track_2)
|
|
|
{
|
|
|
Dbxy Track2Offset = gProgram_SZ_XL->GetTrack2Offset();
|
|
|
BasePt.x += Track2Offset.x;
|
|
|
BasePt.y += Track2Offset.y;
|
|
|
}
|
|
|
//移动obj
|
|
|
gProgramCutMgr->MoveObjData(BasePt);
|
|
|
//移动area
|
|
|
//计算所有obj 的中心点
|
|
|
gObjComponentMgr->CalAllObjCenterPt();
|
|
|
Dbxy AllObjCenterPt = gObjComponentMgr->GetAllObjCenterPt();
|
|
|
gMarkAreaMgr->MoveAllAreaToTargetPt(AllObjCenterPt);
|
|
|
|
|
|
//识别定位点3
|
|
|
Dbxy MarkPt3;
|
|
|
if (gObjComponentMgr->GetMark3Pt(MarkPt3))
|
|
|
{
|
|
|
Ret = gCommonFlowMgr->CameraCatchMark3(Product);
|
|
|
}
|
|
|
if (Ret)
|
|
|
{
|
|
|
//识别定位点1
|
|
|
gCommonFlowMgr->CameraCatchTwoMark(Product);//只抓取一个点
|
|
|
if (!Product.IsSetRealMarkPt1())
|
|
|
{
|
|
|
Ret = false;
|
|
|
}
|
|
|
}
|
|
|
//识别定位点2
|
|
|
if (Ret)
|
|
|
{
|
|
|
gCommonFlowMgr->CameraCatchTwoMark(Product);//只抓取一个点
|
|
|
}
|
|
|
if (!Product.IsMarkReady())//mark 识别错误
|
|
|
{
|
|
|
Ret = false;
|
|
|
}
|
|
|
//抓取失败时/非自动状态时
|
|
|
if (Ret == false || m_bAutoWorking == false)
|
|
|
{
|
|
|
VacSorbOnOff(false);//真空放开
|
|
|
//解除锁定
|
|
|
gCurLockTrackType = _ETrackType_NULL;
|
|
|
}
|
|
|
}* /
|
|
|
if (m_bAutoWorking)
|
|
|
{
|
|
|
if (Ret == false)
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Catch_mark_Err);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Catch_mark_End);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Stop);
|
|
|
//解除锁定
|
|
|
if (m_TrackType == gCurLockTrackType)
|
|
|
{
|
|
|
gCurLockTrackType = _ETrackType_NULL;
|
|
|
}
|
|
|
}
|
|
|
if (m_CurWorkStep != _ETrack_Step_Catch_mark_End)//异常停止时
|
|
|
{
|
|
|
//数据移动回默认的位置(防止area 移位)
|
|
|
gProgramCutMgr->MoveObjData(Dbxy(0, 0));
|
|
|
gMarkAreaMgr->MoveAllAreaToTargetPt(Dbxy(0, 0));
|
|
|
}
|
|
|
//恢复报警状态
|
|
|
gTrackWorkFlow1.RadAlamOnOff(false);*/
|
|
|
}
|
|
|
//加工过程
|
|
|
void CTrackWorkFlow::MarkProcess()
|
|
|
{
|
|
|
gWorkTime.StartRecordTime();//计时开始
|
|
|
|
|
|
//设置当前的工作步骤
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Marking);
|
|
|
//XY 组切换
|
|
|
MarkProcessExt();
|
|
|
CString str = "READY";
|
|
|
gServer->BroadCast(str);
|
|
|
gLogMgr->WriteDebugLog(str);
|
|
|
|
|
|
//设置当前的工作步骤
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Marking);
|
|
|
//数据移动回默认的位置
|
|
|
/* gProgramCutMgr->MoveObjData(Dbxy(0, 0));
|
|
|
gMarkAreaMgr->MoveAllAreaToTargetPt(Dbxy(0, 0));*/
|
|
|
|
|
|
|
|
|
//gCurLockTrackType = _ETrackType_NULL;//解锁
|
|
|
//VacSorbOnOff(false);//真空放开
|
|
|
|
|
|
m_CutProductCnt++;//切割产品的数量 //向客户端发送加工完成
|
|
|
WriteRecordTimesToFile();
|
|
|
gWorkTime.StopRecordTime();//停止计时
|
|
|
|
|
|
SetCurTrackWorkStep(_ETrack_Step_NULL);//置空
|
|
|
}
|
|
|
bool CTrackWorkFlow::MarkProcessExt()
|
|
|
{
|
|
|
//设置整体加工偏移
|
|
|
Dbxy MarkOffset = gProgram_SZ_XL->GetTrackMarkOffset(m_TrackType);
|
|
|
gCommonFlowMgr->SetAdjustOffsetAll(MarkOffset);
|
|
|
//记录当前正在切割的轨道
|
|
|
gProgram_SZ_XL->SetCurMarkingTrack(m_TrackType);
|
|
|
|
|
|
CProduct &Product = gServer->m_RcvProduct;
|
|
|
|
|
|
|
|
|
/*
|
|
|
Dbxy BasePt = Product.GetProductBasePt();
|
|
|
//=======移动obj==============
|
|
|
gProgramCutMgr->MoveObjData(BasePt);
|
|
|
///--------移动area--------------------------
|
|
|
//计算所有obj 的中心点
|
|
|
gObjComponentMgr->CalAllObjCenterPt();
|
|
|
Dbxy AllObjCenterPt = gObjComponentMgr->GetAllObjCenterPt();
|
|
|
gMarkAreaMgr->MoveAllAreaToTargetPt(AllObjCenterPt);*/
|
|
|
|
|
|
bool Ret;
|
|
|
//启动切割
|
|
|
if (!gProgram_SZ_XL->IsbSelMarkMode())//全部加工时自动选择所有obj
|
|
|
gObjComponentMgr->SelAllObj();
|
|
|
Ret = gProgramCutMgr->StartWork(Product, true);
|
|
|
|
|
|
//清空指令集
|
|
|
CWorkCmdContainer &CmdContainer = CWorkCmdContainer::GetInstance();//指令集
|
|
|
CmdContainer.Clear();
|
|
|
//取消选择状态
|
|
|
gObjComponentMgr->NotSelAllObj();
|
|
|
|
|
|
return Ret;
|
|
|
}
|
|
|
|
|
|
//去边框
|
|
|
void CTrackWorkFlow::ThrowEdge()
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Throw_Edge);
|
|
|
//通知plc 上料
|
|
|
CString Log = m_TrackName + " Throw Edge";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
|
|
|
if (gProgram_SZ_XL->IsbShieldLoad())//屏蔽上料
|
|
|
{
|
|
|
if (m_bAutoWorking)//自动生产中
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Throw_Edge_End);
|
|
|
else
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Stop);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (gProgram_SZ_XL->IsbAutoWorkMode())//自动模式
|
|
|
{
|
|
|
//平台移动到上料位置
|
|
|
MoveToPos(_ETrack_Step_Load);
|
|
|
|
|
|
if (gProgram_SZ_XL->SendMsgToLoadDevice(m_TrackType, _ETrack_Step_Throw_Edge, true) == false)
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Throw_Edge_Err);
|
|
|
Log = m_TrackName + " Throw Edge Err";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
return;
|
|
|
}
|
|
|
if (m_bAutoWorking)//自动生产中
|
|
|
{
|
|
|
//等待上料完成
|
|
|
while (1)
|
|
|
{
|
|
|
if (m_CurWorkStep == _ETrack_Step_Throw_Edge_End)
|
|
|
break;
|
|
|
Sleep(200);
|
|
|
}
|
|
|
Log = m_TrackName + " Throw Edge End";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Throw_Edge_Stop);
|
|
|
Log = m_TrackName + " Load Stop";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Throw_Edge_End);
|
|
|
Log = m_TrackName + " Throw Edge End";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
}
|
|
|
}
|
|
|
//下料
|
|
|
void CTrackWorkFlow::UnLoad()
|
|
|
{
|
|
|
//设置当前步骤
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Unload);
|
|
|
//检查下料机的状态
|
|
|
if (gProgram_SZ_XL->IsbCheckUnloadState())
|
|
|
{
|
|
|
//如果另外一个轨道没有在下料,下料机在轨道上的时候判断为unload错误
|
|
|
if (gMotionCard_PCI1245->CheckUnloadState() == false)
|
|
|
{
|
|
|
//获取另外一个轴的状态
|
|
|
ETrackWorkStep OtherTrackWorkStep = gProgram_SZ_XL->GetOtherTrackWorkStep(m_TrackType);
|
|
|
if (OtherTrackWorkStep != _ETrack_Step_Unload)
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Unload_Err);
|
|
|
CMsgBox MsgBox;
|
|
|
MsgBox.Show("下料机位置异常!");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//平台移动到下料位置
|
|
|
MoveToPos(_ETrack_Step_Unload);
|
|
|
//自动打开载盘
|
|
|
ProductCarrierOpenClose(true);
|
|
|
|
|
|
//通知plc 下料
|
|
|
CString Log = m_TrackName + " UnLoad";
|
|
|
gLogMgr->WriteDebugLog(Log);
|
|
|
|
|
|
if (gProgram_SZ_XL->IsbShieldUnLoad())//屏蔽下料
|
|
|
{
|
|
|
if (m_bAutoWorking)//自动运行中
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Unload_End);
|
|
|
else
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Stop);
|
|
|
return;
|
|
|
}
|
|
|
//如果另外一个轴在unload ,要等待其unload 完成
|
|
|
if (gProgram_SZ_XL->IsbAutoWorkMode())
|
|
|
{
|
|
|
while (1)
|
|
|
{
|
|
|
Sleep(200);
|
|
|
if (m_bAutoWorking == false)//如果没有在自动运行状态,退出
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Stop);
|
|
|
return;
|
|
|
}
|
|
|
//获取另外一个轴的状态
|
|
|
ETrackWorkStep OtherTrackWorkStep = gProgram_SZ_XL->GetOtherTrackWorkStep(m_TrackType);
|
|
|
if (OtherTrackWorkStep != _ETrack_Step_Unload)
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
//如果Y 轴在本轴的区域,要把Y 轴移到另外一个轨道上才能通知下料
|
|
|
MoveMotorYToSafePos();
|
|
|
//通知PLC 下料
|
|
|
SendMsgToPlc(_ETrack_PlcCmd_Unload, false);
|
|
|
}
|
|
|
|
|
|
if (m_bAutoWorking)//自动运行中
|
|
|
{
|
|
|
if (gProgram_SZ_XL->IsbAutoWorkMode())//自动模式
|
|
|
{
|
|
|
//等待PLC 下料完成
|
|
|
while (1)
|
|
|
{
|
|
|
if (m_CurWorkStep == _ETrack_Step_Unload_End)
|
|
|
break;
|
|
|
Sleep(200);
|
|
|
}
|
|
|
m_bLoadProduct = false;//轨道上是否load 了产品
|
|
|
}
|
|
|
else//手动模式直接跳过下料步骤
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Unload_End);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
SetCurTrackWorkStep(_ETrack_Step_Stop);
|
|
|
}
|
|
|
}
|
|
|
//移动Y 轴到安全区域
|
|
|
void CTrackWorkFlow::MoveMotorYToSafePos()
|
|
|
{
|
|
|
double DangerCoordStart;//危险范围start
|
|
|
double DangerCoordEnd;//危险范围end
|
|
|
double SafeCoord;//安全坐标
|
|
|
gProgram_SZ_XL->GetTrackMotorYCoord(m_TrackType, DangerCoordStart, DangerCoordEnd, SafeCoord);
|
|
|
|
|
|
//获取当前的Y 轴坐标
|
|
|
CMotor &MotorY = *(CMotor::GetMotor(MOTOR_Y));
|
|
|
double CoordY = gMotionCard_PCI1245->GetMotorCoord(MotorY);
|
|
|
|
|
|
if (DangerCoordStart <= CoordY && CoordY <= DangerCoordEnd)
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("Move MotorY To Safe Coord");
|
|
|
gCurLockTrackType = m_TrackType;//锁定当前轨道
|
|
|
//移动Y 轴到安全坐标
|
|
|
CWorkCmdContainer CmdContainer;
|
|
|
//设置电机速度
|
|
|
{
|
|
|
CWorkCmdSetMotorSpeed *pCmd = new CWorkCmdSetMotorSpeed();
|
|
|
pCmd->SetbSetMotorY();
|
|
|
pCmd->SetSpeedType(_SpeedType_Move);
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//移动
|
|
|
{
|
|
|
CWorkCmdMoveMotor *pCmd = new CWorkCmdMoveMotor(MotorY, SafeCoord);
|
|
|
pCmd->SetMoveFlg(false);//移动到坐标
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
//等待移动结束
|
|
|
{
|
|
|
CWorkCmdWaitMotorStop *pCmd = new CWorkCmdWaitMotorStop();
|
|
|
pCmd->SetbWaitMotorY();
|
|
|
CmdContainer.AddCmd(pCmd);
|
|
|
}
|
|
|
CWorkCmdInvoker WorkInvoker;//工作调度者
|
|
|
WorkInvoker.Excute(CmdContainer);
|
|
|
|
|
|
MotorY.NotifyObservers();
|
|
|
|
|
|
//解除锁定
|
|
|
gCurLockTrackType = _ETrackType_NULL;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
gLogMgr->WriteDebugLog("MotorY At Safe Coord");
|
|
|
}
|
|
|
}
|
|
|
CString CTrackWorkFlow::GetRecordFilePath()
|
|
|
{
|
|
|
CString Path = (m_TrackType == _ETrackType_Track_1) ? (TRACK1_RECORD_FILE) : (TRACK2_RECORD_FILE);
|
|
|
CString FilePath;
|
|
|
CFileMgr FileMgr;
|
|
|
FileMgr.GetFullFilePath(FilePath, Path);
|
|
|
return FilePath;
|
|
|
}
|
|
|
//加工次数次数写入到文件
|
|
|
void CTrackWorkFlow::WriteRecordTimesToFile()
|
|
|
{
|
|
|
CString FilePath = GetRecordFilePath();
|
|
|
|
|
|
CFile file(FilePath, CFile::modeReadWrite | CFile::modeCreate);
|
|
|
CArchive ar(&file, CArchive::store);
|
|
|
|
|
|
ar << m_CutProductCnt;
|
|
|
}
|
|
|
void CTrackWorkFlow::ReadRecordTimesFromFile()
|
|
|
{
|
|
|
CString FilePath = GetRecordFilePath();
|
|
|
|
|
|
CFile file;
|
|
|
if (file.Open(FilePath, CFile::modeRead))
|
|
|
{
|
|
|
CArchive ar(&file, CArchive::load);
|
|
|
ar >> m_CutProductCnt;
|
|
|
}
|
|
|
}
|
|
|
void CTrackWorkFlow::ResetRecordTimes()
|
|
|
{
|
|
|
m_CutProductCnt = 0;
|
|
|
WriteRecordTimesToFile();
|
|
|
}
|
|
|
|
|
|
#endif
|