#include "stdafx.h"
|
#include "CRobotTask.h"
|
#include "ToolUnits.h"
|
|
|
namespace SERVO {
|
CRobotTask::CRobotTask()
|
{
|
generateId(m_strId);
|
m_state = ROBOT_TASK_STATE::Ready;
|
m_timeCreate = CToolUnits::getTimestamp();
|
m_timeFetchOut = 0;
|
m_timeStored = 0;
|
m_timeFinish = 0;
|
m_pContext = nullptr;
|
}
|
|
CRobotTask::~CRobotTask()
|
{
|
if (m_pContext != nullptr) {
|
m_pContext->release();
|
m_pContext = nullptr;
|
}
|
}
|
|
std::string CRobotTask::getDescription() const
|
{
|
std::string strOut = "CRobotTask<ID:";
|
strOut = strOut + std::to_string(m_robotCmdParam.sequenceNo);
|
strOut = strOut + ",Arm:";
|
strOut = strOut + std::to_string(m_robotCmdParam.armNo);
|
strOut = strOut + ",GetPossion:";
|
strOut = strOut + std::to_string(m_robotCmdParam.getPosition);
|
strOut = strOut + ",GetSlot:";
|
strOut = strOut + std::to_string(m_robotCmdParam.getSlotNo);
|
strOut = strOut + ",PutPossion:";
|
strOut = strOut + std::to_string(m_robotCmdParam.putPosition);
|
strOut = strOut + ",PutSlot:";
|
strOut = strOut + std::to_string(m_robotCmdParam.putSlotNo);
|
strOut = strOut + ">";
|
|
return strOut;
|
}
|
|
std::string CRobotTask::getSimpleDescription() const
|
{
|
std::string strOut = "CRobotTask<ID:";
|
strOut = strOut + std::to_string(m_robotCmdParam.sequenceNo);
|
strOut = strOut + ",Arm:";
|
strOut = strOut + std::to_string(m_robotCmdParam.armNo);
|
strOut = strOut + ",GetPossion:";
|
strOut = strOut + std::to_string(m_robotCmdParam.getPosition);
|
strOut = strOut + ",GetSlot:";
|
strOut = strOut + std::to_string(m_robotCmdParam.getSlotNo);
|
strOut = strOut + ",PutPossion:";
|
strOut = strOut + std::to_string(m_robotCmdParam.putPosition);
|
strOut = strOut + ",PutSlot:";
|
strOut = strOut + std::to_string(m_robotCmdParam.putSlotNo);
|
strOut = strOut + ">";
|
|
return strOut;
|
}
|
|
void CRobotTask::setContext(CContext* pContext)
|
{
|
if (m_pContext != nullptr) {
|
m_pContext->release();
|
}
|
|
m_pContext = pContext;
|
if (m_pContext != nullptr) {
|
m_pContext->addRef();
|
}
|
}
|
|
CContext* CRobotTask::getContext()
|
{
|
return m_pContext;
|
}
|
|
std::string& CRobotTask::generateId(std::string& out)
|
{
|
char szBuffer[256];
|
CTime time = CTime::GetCurrentTime();
|
__int64 nTick = 0;
|
QueryPerformanceCounter((LARGE_INTEGER*)&nTick);
|
sprintf_s(szBuffer, 256, "%d%02d%02d%02d%02d%02d%010llu", time.GetYear(),
|
time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond(),
|
nTick % 10000000000);
|
out = szBuffer;
|
|
return out;
|
}
|
|
std::string& CRobotTask::getId()
|
{
|
return m_strId;
|
}
|
|
void CRobotTask::setRobotTransferParam(int seq, int armNo, int fromPos, int toPos, int fromSlot, int toSlot)
|
{
|
m_robotCmdParam = {};
|
m_robotCmdParam.sequenceNo = static_cast<short>(seq);
|
m_robotCmdParam.rcmd = static_cast<short>(SERVO::RCMD::Transfer);
|
m_robotCmdParam.armNo = static_cast<short>(armNo);
|
m_robotCmdParam.getPosition = static_cast<short>(fromPos);
|
m_robotCmdParam.getSlotNo = static_cast<short>(fromSlot);
|
m_robotCmdParam.putPosition = static_cast<short>(toPos);
|
m_robotCmdParam.putSlotNo = static_cast<short>(toSlot);
|
}
|
|
ROBOT_CMD_PARAM& CRobotTask::getRobotCmdParam()
|
{
|
return m_robotCmdParam;
|
}
|
|
time_t CRobotTask::getCreateTime()
|
{
|
return m_timeCreate;
|
}
|
|
time_t CRobotTask::getFetchoutTime()
|
{
|
return m_timeFetchOut;
|
}
|
|
time_t CRobotTask::getStoredTime()
|
{
|
return m_timeStored;
|
}
|
|
time_t CRobotTask::getFinishTime()
|
{
|
return m_timeFinish;
|
}
|
|
ROBOT_TASK_STATE CRobotTask::getState()
|
{
|
return m_state;
|
}
|
|
void CRobotTask::completed()
|
{
|
m_state = ROBOT_TASK_STATE::Completed;
|
}
|
|
void CRobotTask::error()
|
{
|
m_state = ROBOT_TASK_STATE::Error;
|
}
|
|
void CRobotTask::abort()
|
{
|
m_state = ROBOT_TASK_STATE::Abort;
|
}
|
|
int CRobotTask::getSrcPosition()
|
{
|
return m_robotCmdParam.getPosition;
|
}
|
|
int CRobotTask::getTarPosition()
|
{
|
return m_robotCmdParam.putPosition;
|
}
|
|
int CRobotTask::getSrcSlot()
|
{
|
return m_robotCmdParam.getSlotNo;
|
}
|
|
int CRobotTask::getTarSlot()
|
{
|
return m_robotCmdParam.putSlotNo;
|
}
|
|
void CRobotTask::fetchOut()
|
{
|
m_timeFetchOut = CToolUnits::getTimestamp();;
|
}
|
|
void CRobotTask::stored()
|
{
|
m_timeStored = CToolUnits::getTimestamp();;
|
}
|
}
|