You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

631 lines
15 KiB
C++

#pragma once
//全局类型定义
using namespace std;/*使用标准库的名字空间*/
//STL 标准头文件
#include <set>
#include <vector>
#include <list>
#include <iostream>
#include <fstream>
#include <string>
#include <utility>
#include <map>
#include <deque>
#include <algorithm>
#include <CString>
//#include <afxwin.h>
//屏蔽编译警告
#pragma warning(disable : 4800)
#pragma warning(disable : 4244)
#pragma warning(disable : 4996)
#pragma warning(disable : 4018)
#pragma warning(disable : 4477)
#define PI 3.14159265358979323846
//#define COORD_EPS 0.001 //坐标误差精度(0.001 表示在坐标比较中,两个点的距离小于1um 就认为是相等)
#define COORD_EPS 0.00001
#define RGB_WHITE RGB(255,255,255) //白色
#define RGB_BLACK RGB(0,0,0) //黑色
#define RGB_GREEN RGB(0,255,0) //绿色
#define RGB_GREEN1 RGB(29,241,135) //绿色
#define RGB_RED RGB(255,0,0) //红色
#define RGB_PINK RGB(255,55,120) //粉红色
#define RGB_PINK1 RGB(231,61,175) //粉红色
#define RGB_YELLOW RGB(255,255,0) //黄色
#define RGB_BLUE RGB(0,0,255) //蓝色
#define RGB_BLUE1 RGB(153,217,234) //天蓝色
#define RGB_NODE_BLUE RGB(0,63,255) //节点蓝色
#define RGB_PURPLE RGB(163,73,164) //紫色
#define RGB_GRAY RGB(240,240,240) //灰色
#define RGB_GRAY1 RGB(160,160,160) //灰色
#define bOPEN true
#define bCLOSE false
#define STR_NULL ""
#define STR_INPUT_ERROR "无效指令: "
#define STR_INPUT_SYMBOL '>'
#define MARK_OBJ_CNT 25//载盘上obj 的数量
enum eGlobalVariableType
{
_GlobalVar_NULL = 0,
_GlobalVar_Alarm_Robot_StateErr,
_GlobalVar_Alarm_Robot_OverLoad1,
_GlobalVar_Alarm_Robot_Crash1,
_GlobalVar_Alarm_Robot_InsideFANAlarm,
_GlobalVar_Alarm_Robot_SoftLimitErr,
_GlobalVar_Alarm_Robot_CassetteStepZero,
_GlobalVar_Alarm_Robot_CassetteStepOverN,
_GlobalVar_Alarm_Robot_PointNumberZero,
_GlobalVar_Alarm_Robot_HostBufferFull,
_GlobalVar_Alarm_Robot_PositioningTimeOverAx,
_GlobalVar_Alarm_Robot_IllegalRemoteCommandStr,
_GlobalVar_Alarm_Robot_CommunicationRetryOver,
_GlobalVar_Alarm_Robot_ExecutionBufferOver,
_GlobalVar_Alarm_Robot_IllegalCassetteNo,
_GlobalVar_Alarm_Robot_ServoDriverAlarmCodeAx,
_GlobalVar_Alarm_Robot_IllegalGroupNo,
_GlobalVar_Alarm_Robot_ILError,
_GlobalVar_Alarm_Robot_ServoSignalOFF,
_GlobalVar_Alarm_Robot_IllegalCassetteSel,
_GlobalVar_Alarm_Robot_IllegalStageSel,
_GlobalVar_Alarm_Robot_WorkExist,
_GlobalVar_Alarm_Robot_IllegalCassetteOrStageOrPoint,
_GlobalVar_Alarm_Robot_RetryVacuumMiss1,
_GlobalVar_Alarm_Robot_IllegalSensor,
_GlobalVar_Alarm_Robot_CanNotGet,
_GlobalVar_Alarm_Robot_CanNotPut,
_GlobalVar_Alarm_Robot_TeachingCombiCheckError,
_GlobalVar_Alarm_Robot_RetryVacuumMiss2,
_GlobalVar_Alarm_Robot_DriverNotReady,
_GlobalVar_Alarm_Robot_MinusStrokeOver,
_GlobalVar_Alarm_Robot_DiffOver,
_GlobalVar_Alarm_Robot_EncoderAlarm1,
_GlobalVar_Alarm_Robot_VelocityOver,
_GlobalVar_Alarm_Robot_CarryingAlarm,
_GlobalVar_Alarm_Robot_OverLoad2,
_GlobalVar_Alarm_Robot_Crash2,
_GlobalVar_Alarm_Robot_EmergencyStop,
_GlobalVar_Alarm_Robot_MappingAlarm,
_GlobalVar_Alarm_Robot_ClampError,
_GlobalVar_Alarm_Robot_ServoDriverAlarm,
_GlobalVar_Alarm_Robot_DataAlarmCode,
_GlobalVar_Alarm_Robot_EncoderAlarm2,
_GlobalVar_Alarm_Robot_CmdOverTime,
_GlobalVar_Alarm_Robot_ComPortNotOpen,
_GlobalVar_Alarm_Robot_CmdNak,
_GlobalVar_Alarm_LoadPort1_StateCheckError,
_GlobalVar_Alarm_LoadPort2_StateCheckError,
_GlobalVar_Alarm_LoadPort1_WaferProtrusion,
_GlobalVar_Alarm_LoadPort2_WaferProtrusion,
_GlobalVar_Alarm_LoadPort1_MainAirError,
_GlobalVar_Alarm_LoadPort2_MainAirError,
_GlobalVar_Alarm_LoadPort1_ZAxisPositionNG,
_GlobalVar_Alarm_LoadPort2_ZAxisPositionNG,
_GlobalVar_Alarm_LoadPort1_YAxisPositionNG,
_GlobalVar_Alarm_LoadPort2_YAxisPositionNG,
_GlobalVar_Alarm_LoadPort1_DoorPositionNG,
_GlobalVar_Alarm_LoadPort2_DoorPositionNG,
_GlobalVar_Alarm_LoadPort1_MapperArmPositionNG,
_GlobalVar_Alarm_LoadPort2_MapperArmPositionNG,
_GlobalVar_Alarm_LoadPort1_MapperZAxisPositionNG,
_GlobalVar_Alarm_LoadPort2_MapperZAxisPositionNG,
_GlobalVar_Alarm_LoadPort1_MapperStopperPositionNG,
_GlobalVar_Alarm_LoadPort2_MapperStopperPositionNG,
_GlobalVar_Alarm_LoadPort1_MappingEndPositionNG,
_GlobalVar_Alarm_LoadPort2_MappingEndPositionNG,
_GlobalVar_Alarm_LoadPort1_FOUPClampOpenError,
_GlobalVar_Alarm_LoadPort2_FOUPClampOpenError,
_GlobalVar_Alarm_LoadPort1_FOUPClampCloseError,
_GlobalVar_Alarm_LoadPort2_FOUPClampCloseError,
_GlobalVar_Alarm_LoadPort1_LatchKeyOpenError,
_GlobalVar_Alarm_LoadPort2_LatchKeyOpenError,
_GlobalVar_Alarm_LoadPort1_LatchKeyCloseError,
_GlobalVar_Alarm_LoadPort2_LatchKeyCloseError,
_GlobalVar_Alarm_LoadPort1_VacuumOnError,
_GlobalVar_Alarm_LoadPort2_VacuumOnError,
_GlobalVar_Alarm_LoadPort1_VacuumOffError,
_GlobalVar_Alarm_LoadPort2_VacuumOffError,
_GlobalVar_Alarm_LoadPort1_FOUPOpenOvertime,
_GlobalVar_Alarm_LoadPort2_FOUPOpenOvertime,
_GlobalVar_Alarm_LoadPort1_FOUPCloseOvertime,
_GlobalVar_Alarm_LoadPort2_FOUPCloseOvertime,
_GlobalVar_Alarm_LoadPort1_ParallelSignalError,
_GlobalVar_Alarm_LoadPort2_ParallelSignalError,
_GlobalVar_Alarm_LoadPort1_FanOperationError,
_GlobalVar_Alarm_LoadPort2_FanOperationError,
_GlobalVar_Alarm_LoadPort1_InterlockCircuitFailure,
_GlobalVar_Alarm_LoadPort2_InterlockCircuitFailure,
_GlobalVar_Alarm_LoadPort1_CommunicationError,
_GlobalVar_Alarm_LoadPort2_CommunicationError,
_GlobalVar_Alarm_LoadPort1_ObstaclesSensorError,
_GlobalVar_Alarm_LoadPort2_ObstaclesSensorError,
_GlobalVar_Alarm_LoadPort1_MappingMechanicalError,
_GlobalVar_Alarm_LoadPort2_MappingMechanicalError,
_GlobalVar_Alarm_LoadPort1_LoadFailed_RobotRunning,
_GlobalVar_Alarm_LoadPort2_LoadFailed_RobotRunning,
_GlobalVar_Alarm_LoadPort1_LoadFailed_E84Running,
_GlobalVar_Alarm_LoadPort2_LoadFailed_E84Running,
_GlobalVar_Alarm_Port1E84_ReadIO_Failed,
_GlobalVar_Alarm_Port2E84_ReadIO_Failed,
_GlobalVar_Alarm_LoadPort1_LoadFailed_OHTNotLeave,
_GlobalVar_Alarm_LoadPort2_LoadFailed_OHTNotLeave,
_GlobalVar_Alarm_LoadPort1_MAPDT_Feedback_Error,
_GlobalVar_Alarm_LoadPort2_MAPDT_Feedback_Error,
_GlobalVar_Alarm_LoadPort1_STATE_Feedback_Error,
_GlobalVar_Alarm_LoadPort2_STATE_Feedback_Error,
_GlobalVar_Alarm_LoadPort1_UnloadFailed_RobotRunning,
_GlobalVar_Alarm_LoadPort1_InitialPositionError,
_GlobalVar_Alarm_LoadPort1_OperationNotStopped,
_GlobalVar_Alarm_LoadPort1_DoorNotOpened,
_GlobalVar_Alarm_LoadPort1_DoorNotClosed,
_GlobalVar_Alarm_LoadPort1_WaferProtrusionSensorOn,
_GlobalVar_Alarm_Port1E84_CmdOverTime,
_GlobalVar_Alarm_Port1E84_CmdExtErr,
_GlobalVar_Alarm_Port1E84_VALID_BreakOff,
_GlobalVar_Alarm_Port1E84_TP3_OverTime,
_GlobalVar_Alarm_Port1E84_TP4_OverTime,
_GlobalVar_Alarm_Port1E84_E84ExecuteError,
_GlobalVar_Alarm_Port2E84_CmdOverTime,
_GlobalVar_Alarm_Port2E84_CmdExtErr,
_GlobalVar_Alarm_Port2E84_VALID_BreakOff,
_GlobalVar_Alarm_Port2E84_TP3_OverTime,
_GlobalVar_Alarm_Port2E84_TP4_OverTime,
_GlobalVar_Alarm_Port2E84_E84ExecuteError,
};
//鼠标工具的类型
enum MOUSE_TOOL
{
_TOOL_POINT=0,
_TOOL_RECT,
_TOOL_LINE,
_TOOL_PLINE,//多线段
_TOOL_CIRCLE,
_TOOL_MOVE,
_TOOL_MOVE2,//指定基点移动
_TOOL_ROTATO,
_TOOL_COPY,
_TOOL_MEASURE,//测量
_TOOL_ZOOM,//缩放
_TOOL_CUT,//修剪
_TOOL_ADD_NODE,//添加节点
_TOOL_DEL_NODE,//删除节点
_TOOL_BREAK_NODE,//打断节点
_TOOL_MOVE_NODE,//移动节点
_TOOL_TEXT,//文字
_TOOL_BARCODE,//条码
_TOOL_ONE_POINT,//一个点
_TOOL_STRETCH,//拉伸工具
_TOOL_PT_MOVE_TO_CCD,//设置特定用途的点
_TOOL_SET_MARK_PT,//手动指定定位点
};
enum OBJ_TYPE
{
_TYPE_BASE = 0,
_TYPE_PLINE,//多线段1
_TYPE_POINT,//点2
_TYPE_CIRCLE,//圆3
_TYPE_COMPOSITE,//一般组合类型4
_TYPE_TXT,//字符串5
_TYPE_BARCODE,//条码6
_TYPE_STR,//string 7
_TYPE_CHAR,//字符8
};
enum X_OR_Y
{
_X=0,
_Y,
_XY,
};
enum CATCH_PT_TYPE//抓取点的类型
{
_CATCH_NODE = 0,//结点
_CATCH_INTERSECT,//线段的交点
_CATCH_ORTHO,//正交
_CATCH_CUT_TRACK,//元件切割道交点
};
enum STATUS//鼠标工具的状态值,用于确定每一步做什么事情
{
_STATUS_1 = 0,
_STATUS_2,
_STATUS_3,
_STATUS_4,
_STATUS_5,
_STATUS_6,
_STATUS_END
};
enum OBJ_OP_TYPR
{
_OP_MOVE = 0,
_OP_ROTATO,
_OP_MIRROR,
_OP_STRETCH,//拉伸
_OP_REVERSE,//反转数据点
_OP_SCALE,//按比例缩放
_OP_SET,
};
inline bool IsDbEqual(double a,double b)
{
if((abs(a-b))<COORD_EPS)
return true;
else
return false;
}
//浮点型的xy 组合,单位毫米
class Dbxy
{
friend bool operator==(const Dbxy &lhs, const Dbxy &rhs);
public:
Dbxy(double _x,double _y):x(_x),y(_y),w(0){};
Dbxy(double _x, double _y, double _w) :x(_x), y(_y), w(_w){};
Dbxy(const Dbxy &lhs) :x(lhs.x), y(lhs.y), w(0) {};
Dbxy& operator=(const Dbxy &lhs)
{
x = lhs.x;
y = lhs.y;
w = lhs.w;
return *this;
}
Dbxy()
{
x= y =w=0;
};
bool Equal(Dbxy &pt)
{
if(IsDbEqual(x,pt.x) && IsDbEqual(y,pt.y))
return true;
else
return false;
}
void operator+=(const Dbxy &rhs)
{
(*this).x += rhs.x;
(*this).y += rhs.y;
}
void operator-=(const Dbxy &rhs)
{
(*this).x -= rhs.x;
(*this).y -= rhs.y;
}
void Reversed(bool bRx = true, bool bRy = true)
{
if (bRx) (*this).x *= -1;
if (bRy) (*this).y *= -1;
}
public:
double x;
double y;
double w;
};
inline bool operator==(const Dbxy &lhs, const Dbxy &rhs)
{
return (IsDbEqual(lhs.x,rhs.x) && IsDbEqual(lhs.y,rhs.y));
}
//抓取点的类型
class CCatchPoint :public Dbxy
{
public:
CCatchPoint(double _x,double _y,CATCH_PT_TYPE type):Dbxy(_x,_y),m_type(type){};
CCatchPoint()
{
Dbxy::Dbxy();
};
CATCH_PT_TYPE GetType(){return m_type;};
public:
CATCH_PT_TYPE m_type;
};
class DbSize
{
public:
DbSize(double _w,double _h):w(_w),h(_h){};
DbSize()
{
w= h =0;
};
public:
double w;
double h;
};
class IntXY
{
friend bool operator==(const IntXY &lhs, const IntXY &rhs);
public:
IntXY(int _x,int _y):x(_x),y(_y){};
IntXY()
{
x = y =0;
};
public:
int x;
int y;
};
inline bool operator==(const IntXY &lhs, const IntXY &rhs)
{
return (lhs.x == rhs.x && lhs.y == rhs.y);
}
#if 1
class DbRect
{
public:
DbRect(double _L,double _R,double _T,double _B):L(_L),R(_R),T(_T),B(_B){};
DbRect(Dbxy pt1,Dbxy pt2){Creat(pt1,pt2);}
DbRect(Dbxy pt,double size){Creat(pt,size);}//size 是rect 的半径
DbRect(Dbxy pt,DbSize size)//根据中心点和尺寸来创建
{
Creat(pt,size);
};
DbRect(){Reset();};
void Creat(Dbxy pt1,Dbxy pt2);
void Creat(Dbxy pt,double size);
void Creat(Dbxy pt,DbSize size);
void Reset();
bool IsZero();
DbSize GetSize();
Dbxy GetCenterPt();
Dbxy GetBottomCenterPt();
double Width();
double Height();
public:
double L;
double R;
double T;
double B;
};
inline void DbRect::Reset()
{
L= B = 0.1;
R = T = 0;
}
inline void DbRect::Creat(Dbxy pt1,Dbxy pt2)
{
if(pt1.x < pt2.x)
{
L = pt1.x;
R = pt2.x;
}
else
{
L = pt2.x;
R = pt1.x;
}
if(pt2.y<pt1.y)
{
T = pt1.y;
B = pt2.y;
}
else
{
T = pt2.y;
B = pt1.y;
}
}
inline void DbRect::Creat(Dbxy pt,double size)
{
L = pt.x-size;
R = pt.x+size;
T = pt.y+size;
B = pt.y-size;
}
inline void DbRect::Creat(Dbxy pt,DbSize size)
{
L = pt.x-size.w/2;
R = pt.x+size.w/2;
T = pt.y+size.h/2;
B = pt.y-size.h/2;
}
inline bool DbRect::IsZero()
{
if(L<R || B<T)
return false;
else
return true;
}
inline Dbxy DbRect::GetCenterPt()
{
Dbxy pt;
if(L<=R)
{
pt.x = (L+R)/2;
}
if(T>=B)
{
pt.y = (T+B)/2;
}
return pt;
}
inline DbSize DbRect::GetSize()
{
DbSize size;
size.w = R - L;
size.h = T - B;
if(size.w<0)
size.w = 0;
if(size.h<0)
size.h = 0;
return size;
}
//底部中心点
inline Dbxy DbRect::GetBottomCenterPt()
{
Dbxy pt;
pt.x = (L+R)/2;
pt.y = B;
return pt;
}
inline double DbRect::Width()
{
return R-L;
}
inline double DbRect::Height()
{
return T-B;
}
#endif
//封装所有对象操作的参数,便于统一发送格式
struct SObjOperatePar{
SObjOperatePar()
{
MoveX = MoveY = 0;
Angle = 0;
OldSize = NewSize = Diff = 0;
Scale = 1;
}
OBJ_OP_TYPR OpType;//操作类型
X_OR_Y xy;//标识xy 方向
Dbxy BasePt;//基准点
double MoveX;//移动量
double MoveY;
double Angle;//360 度角
double OldSize;
double NewSize;
double Diff;
double Scale;//缩放比例
};
typedef pair<CPoint,bool> PointType;
//创建圆的参数
class CCirclePar
{
public:
CCirclePar(void)
{
Radius = 1;
DEdgeCnt = 32;
bMerge = true;
StartAng = 0;
EndAng = 360;
}
public:
Dbxy CenterPt;//圆心
double Radius;//半径
int DEdgeCnt;//边数
bool bMerge;//是否合并
double StartAng;//起始角度360 度角
double EndAng;//结束角度
};
//对象位置的参数
class CObjPosPar
{
public:
CObjPosPar()
{
m_Ang =0;
};
public:
Dbxy m_Offset;//偏移
double m_Ang;//角度
};
//晶圆的类型
enum eCspWaferType
{
_CspWaferType_Null = 0,//未定义
_CspWaferType_8,//8寸
_CspWaferType_12,//12寸
};
enum CAlamLightStateType
{
_AlamLightStateType_NULL=0,
_AlamLightStateType_Off,//关闭
_AlamLightStateType_On,//打开
_AlamLightStateType_Flash,//闪烁
};
//警示灯状态
class CAlamLightState
{
public:
CAlamLightState(void)
{
m_LightRedState = _AlamLightStateType_NULL;//红灯状态
m_LightYellowState = _AlamLightStateType_NULL;//黄灯状态
m_LightGreenState = _AlamLightStateType_NULL;//绿灯状态
m_LightAlamState = _AlamLightStateType_NULL;//蜂鸣器状态
};
public:
CAlamLightStateType m_LightRedState;//红灯状态
CAlamLightStateType m_LightYellowState;//黄灯状态
CAlamLightStateType m_LightGreenState;//绿灯状态
CAlamLightStateType m_LightAlamState;//蜂鸣器状态
};
class CDlgItemStr
{
public:
CDlgItemStr(void)
{
m_ID = 0;
};
public:
int m_ID;//编号
CString m_Str;//显示的内容
};
enum AlignDirect {
AlignTop = 0,
AlignBottom,
AlignLeft,
AlignRight,
AlignVecticalCenter, //居中对齐
AlignHorizonalCenter,
AlignVecticalArrange, //排列
AlignHorizonalArrange,
};
class _declspec(dllexport) CDataPoint
{
public:
void Stretch(Dbxy &Pt, Dbxy BasePt, double Size, double Diff, X_OR_Y xy);
public:
Dbxy m_pt;//坐标值
bool m_bIsNode;//是否为节点
};
class _declspec(dllexport) CFontSizeScale
{
public:
CFontSizeScale(void)
{
m_SizeScale.x = 1;
m_SizeScale.y = 1;
m_CharStr = "A";
};
public:
CString m_CharStr;//对应的字符(0~9)(A~Z)
Dbxy m_SizeScale;//尺寸的比例
};
//字符转换坐标需要用的结构
typedef struct {
Dbxy oldBasePt;//中心为拉伸基准点
double oldSizeWidth; //拉伸前尺寸
double oldSizeHeight;
double diff; //旧尺寸和新尺寸之间的差值
}OldCharAttr;