添加项目文件。

master
bestlqiang 5 years ago
parent 3057ca84c8
commit 85ad5e1c30

Binary file not shown.

@ -0,0 +1,122 @@
//
// Copyright (c) Advantech Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Advantech end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
#if !defined(ADVDXFREADER__INCLUDED_)
#define ADVDXFREADER__INCLUDED_
#ifdef __cplusplus
extern "C"
{
#endif
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
#define ADVDXFREADERAPI __stdcall
#endif
/////////////////////////////////////////////////////////////////////////////
#define CLOSE 1
#define NOT_CLOSE 0
#ifndef SUCCESS
#define SUCCESS 0
#endif
//#define PI 3.1415926535897931
// DXF 错误码
#define AtEmptyPathErr 0x01 //路径为空错误
#define AtFileTypeErr 0x02 //文件类型错误
#define AtEmptyFileErr 0x03 //文件为空错误
//#define AtSerialNumErr 0x04 //图样序列号超出范围错误
#define AtSampleTypeErr 0x05 //图样类型错误
#define AtDataLoseErr 0x06 //数据丢失错误
#define AtCreatSpaceErr 0x07 //开辟数据空间失败malloc失败
#define AtInputLocusNumErr 0x08 //输入轨迹数目错误
#define AtLocusPtrErr 0x09 //轨迹链表错误
#define AtInputSampleNumErr 0x0a //输入图元数目错误
#define AtSamplePtrErr 0x0b //图元链表错误
#define AtInputPataErr 0x0c //输入参数错误OpenDxf函数的精度参数
#define CW 0
#define CCW 1
LRESULT ADVDXFREADERAPI AtOpenDXF(char *dxfFilePath, //文件路径
double Proportion, //CAD现实的图和绘制中的图的比例
DWORD Ellipse_Cut_Min_Angel, //分割查补椭圆的最小角度
DWORD Spline_Cut_Step //一段曲线要分为多少直线段
); //比例关系
LRESULT ADVDXFREADERAPI AtGetType(DWORD * Type,
DWORD Direction,
DWORD Locus_Num,
DWORD Sample_Num);
LRESULT ADVDXFREADERAPI AtGetArc(double * Center_x, //圆弧圆心坐标的x值
double * Center_y, //圆弧圆心坐标的y值
double * Center_z, //圆弧圆心坐标的z值
double * r, //圆弧的半径
double * Start_X, //圆弧的起始点的X坐标
double * Start_Y, //圆弧的起始点的Y坐标角度
double * Start_Z, //圆弧的起始点的z坐标角度
double * End_X, //圆弧的终止点的X坐标
double * End_Y, //圆弧的终止点的Y坐标
double * End_Z, //圆弧的终止点的Y坐标
DWORD * MoveDirection, //运动方向
double * Start_Angle, //圆弧的起始角度
double * End_Angle, //圆弧的终止角度
DWORD * Plane, //圆弧所在平面
DWORD Direction, //轨迹的方向
DWORD Locus_Num, //轨迹的序列号
DWORD Sample_Num); //图元的序列号
LRESULT ADVDXFREADERAPI AtGetLine(double *Start_x, //直线起始点坐标的x值
double *Start_y, //直线起始点坐标的y值
double *Start_z, //直线起始点坐标的z值
double *End_x, //直线终止点坐标的x值
double *End_y, //直线终止点坐标的y值
double *End_z, //直线终止点坐标的z值
double *k, //直线的斜率
DWORD Direction, //轨迹的方向
DWORD Locus_Num, //轨迹的序列号
DWORD Sample_Num);//图元的序列号
LRESULT ADVDXFREADERAPI AtGetPoint(double *Point_x,//Point's x value
double *Point_y,//Point's y value
double *Point_z,//Point's z value
DWORD Direction, //轨迹的方向
DWORD Locus_Num, //轨迹的序列号
DWORD Sample_Num);//图元的序列号
LRESULT ADVDXFREADERAPI AtGetMostValue( double * Min_x, //整个文件的最小点的X坐标
double * Min_y, //整个文件的最小点的y坐标
double * Min_z, //整个文件的最小点的z坐标
double * Max_x, //整个文件的最大点的X坐标
double * Max_y, //整个文件的最大点的y坐标
double * Max_z //整个文件的最大点的z坐标
);
LRESULT ADVDXFREADERAPI AtGetLocusCount( DWORD * Count); //获取轨迹的数目
LRESULT ADVDXFREADERAPI AtGetSampleCount(DWORD * Count, //第Locus_Num个轨迹中图元的个数
DWORD Locus_Num); //第几个轨迹
LRESULT ADVDXFREADERAPI AtCloseDXF();
#ifdef __cplusplus
}
#endif
#endif

@ -0,0 +1,767 @@
//
// Copyright (c) Advantech Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Advantech end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
#ifdef __cplusplus
extern "C"
{
#endif
#include "AdvMotDev.h"
#include "AdvMotDrv.h"
#include "AdvMotPropID.h"
#include "AdvMotErr.h"
//Add for other Corp. // [6/8/2011 dan.yang]
#ifndef tagPT_DEVLIST
#define tagPT_DEVLIST
typedef struct tagPT_DEVLIST
{
DWORD dwDeviceNum;
char szDeviceName[50];
SHORT nNumOfSubdevices;
} DEVLIST, *LPDEVLIST;
#endif
// [11/26/2014 dan]
#ifndef _DEV_IO_MAP_INFO
#define _DEV_IO_MAP_INFO
typedef struct _DEV_IO_MAP_INFO
{
char Name[50];
ULONG Index;
ULONG Offset;
ULONG ByteLength;
ULONG SlotID;
ULONG PortChanID;
ULONG ModuleID;
char ModuleName[16];
char Description[100];
} DEV_IO_MAP_INFO, *PDEV_IO_MAP_INFO;
#endif
#ifndef _ADVAPI_SLAVE_INFO
#define _ADVAPI_SLAVE_INFO
typedef struct {
ULONG desc; /**< Port descriptors. */
ULONG link_up; /**< Link detected. */
ULONG loop_closed; /**< Loop closed. */
ULONG next_slave; /**< Connected Position of slaves. */
ULONG delay_to_next_dc;
} port_info;
typedef struct _ADVAPI_SLAVE_INFO_
{
ULONG SlaveID;
ULONG Position;
ULONG VendorID;
ULONG ProductID;
ULONG RevisionNo;
ULONG SerialNo;
ULONG driverCnts;
port_info ports[4];
ULONG transmission_delay;
char DeviceName[64];
}ADVAPI_SLAVE_INFO, *PADVAPI_SLAVE_INFO;
#endif
#ifndef _DEV_ARES_INFO
#define _DEV_ARES_INFO
typedef struct _DEV_ARES_INFO
{
char Name[10][32];
} DEV_ARES_INFO, *PDEV_ARES_INFO;
#endif
#ifndef _DEV_PRE_SCAN_DATA
#define _DEV_PRE_SCAN_DATA
typedef struct _DEV_PRE_SCAN_DATA
{
F64 XScanData;
F64 YScanData;
F64 ZScanData;
} DEV_PRE_SCAN_DATA, *PDEV_PRE_SCAN_DATA;
#endif
#ifndef ADVCMNAPI
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
#define ADVCMNAPI __stdcall
#endif
#endif
/*
+-----------------------------------------------------------------------------+
| ************ Advantech Motion Master Device Type ID************************ |
+-----------------------------------------------------------------------------+
*/
//U32 ADVCMNAPI Acm_GetAvailableDevNum(U32 *DeviceNum); //Add for other corp. [dan.yang 2011.06.08]
U32 ADVCMNAPI Acm_GetAvailableDevs(DEVLIST *DeviceList, U32 MaxEntries, PU32 OutEntries); //Add for other corp. [dan.yang 2011.06.08]
void ADVCMNAPI GetAvailalbe_AMONet(DWORD dwMasDevNum, //Add for other corp. [dan.yang 2011.07.13]
DEVLIST *DeviceList,
ULONG *devIndex,
ULONG *OutEntries);
BOOL ADVCMNAPI Acm_GetErrorMessage(U32 ErrorCode, PI8 lpszError, U32 nMaxError);// [9/5/2011 dan.yang]
U32 ADVCMNAPI Acm_GpMoveCircularRel_Angle(HAND GroupHandle, // [8/15/2012 dan.yang]
PF64 CenterArray,
U16 Degree,
PU32 ArrayElements,
I16 Direction);
U32 ADVCMNAPI Acm_GpMoveCircularAbs_Angle(HAND GroupHandle, // [8/15/2012 dan.yang]
PF64 CenterArray,
U16 Degree,
PU32 ArrayElements,
I16 Direction);
//Device operation
U32 ADVCMNAPI Acm_DevOpen(U32 DeviceNumber, PHAND DeviceHandle);
U32 ADVCMNAPI Acm_DevReOpen(HAND DeviceHandle); // [11/25/2014 dan]
U32 ADVCMNAPI Acm_DevClose(PHAND DeviceHandle);
U32 ADVCMNAPI Acm_DevReadEEPROM(HAND DeviceHandle, U16 EEPROMAddr, PU16 readValue);
U32 ADVCMNAPI Acm_DevWriteEEPROM(HAND DeviceHandle, U16 EEPROMAddr, U16 writeValue);
U32 ADVCMNAPI Acm_DevReadEEPROM_Ex(HAND DeviceHandle, U16 PrivateID, PU32 PassWordArray, U32 PassArrayCnt, PU32 ReadArray, U32 BufferLength);// [6/15/2012 dan.yang]
U32 ADVCMNAPI Acm_DevWriteEEPROM_Ex(HAND DeviceHandle, U16 PrivateID, PU32 PassWordArray, U32 PassArrayCnt, PU32 WriteArray, U32 BufferLength); // [6/15/2012 dan.yang]
U32 ADVCMNAPI Acm_GetProperty(HAND Handle, U32 ProperyID, PVOID Buffer, PU32 BufferLength);
U32 ADVCMNAPI Acm_SetProperty(HAND Handle, U32 ProperyID, PVOID Buffer, U32 BufferLength);
U32 ADVCMNAPI Acm_EnableMotionEvent(HAND DeviceHandle,
PU32 AxEnableEvtArray,
PU32 GpEnableEvtArray,
U32 AxArrayElements,
U32 GpArrayElements);
U32 ADVCMNAPI Acm_CheckMotionEvent(HAND DeviceHandle,
PU32 AxEvtStatusArray,
PU32 GpEvtStatusArray,
U32 AxArrayElements,
U32 GpArrayElements,
U32 Millisecond);
U32 ADVCMNAPI Acm_CancelCheckEvent (HAND ObjectHandle);
U32 ADVCMNAPI Acm_DevLoadConfig(HAND DeviceHandle, PI8 ConfigPath);
U32 ADVCMNAPI Acm_DevFwDownload(HAND DeviceHandle, U32 Data, U32 DataID); //internal function don't release.
U32 ADVCMNAPI Acm_DevSlaveFwDownload(HAND DeviceHandle, U16 RingNo, U16 Position, PI8 FileName, PI8 FilePath, U32 Password); // [6/4/2015 andy.wang]
U32 ADVCMNAPI Acm_DevDownloadCAMTable (HAND DeviceHandle,
U32 CamTableID,
PF64 pMasterArray,
PF64 pSlaveArray,
PF64 pPointRangeArray,
PF64 pPointSlopeArray,
U32 ArrayElements);
U32 ADVCMNAPI Acm_DevLoadCAMTableFile(HAND DeviceHandle, PI8 FilePath, U32 CamTableID, PU32 Range, PU32 PointsCount); // [dan.yang 2011.08.22]
U32 ADVCMNAPI Acm_DevConfigCAMTable(HAND DeviceHandle, //Add for pci1265 and pci1245 [dan.yang 2011.06.23]
U32 CamTableID,
U32 Periodic,
U32 MasterAbsolute,
U32 SlaveAbsolute);
U32 ADVCMNAPI Acm_DevReadMailBox(HAND Handle, U16 par_id, U32 data_index, U32 data_count, PU32 DataBuffer); //[dan.yang 2012.12.28]
U32 ADVCMNAPI Acm_DevWriteMailBox(HAND Handle, U16 par_id, U32 data_index, U32 data_count, PU32 DataBuffer); //[dan.yang 2012.12.28]
U32 ADVCMNAPI Acm_LoadENI(HAND DeviceHandle, PI8 FilePath); // [11/12/2014 dan]
U32 ADVCMNAPI Acm_DevGetComStatus(HAND DeviceHandle, U16 RingNo, PU16 pStatus); // [11/20/2014 dan]
U32 ADVCMNAPI Acm_DevGetSlaveStates(HAND DeviceHandle, U16 RingNo, U16 SlaveIP, PU16 pStatus);
U32 ADVCMNAPI Acm_DevGetErrorTable(HAND DeviceHandle, U16 RingNo, PU32 ErrorTableArray, PU32 ArrayElements);
U32 ADVCMNAPI Acm_DevEnableEvent(HAND DeviceHandle, U32 MasEnableEvt); // [11/20/2014 dan]
U32 ADVCMNAPI Acm_DevCheckEvent(HAND DeviceHandle, PU32 MasCheckEvt, U32 Millisecond); // [11/20/2014 dan]
U32 ADVCMNAPI Acm_DevGetSlaveInfo(HAND DeviceHandle, U16 RingNo, U16 SlaveIP, PVOID pInfo);
U32 ADVCMNAPI Acm_DevGetMasInfo(HAND DeviceHandle, PVOID pMasInfo, PU16 SlaveIPArray, PU32 SlvCnt);
U32 ADVCMNAPI Acm_DevGetSlaveDataCnt(HAND DeviceHandle, U16 RingNo, U16 SlaveIP, U8 DataType, PU32 DataCnt);
U32 ADVCMNAPI Acm_DevGetSlaveFwVersion(HAND DeviceHandle, U16 RingNo, U16 SlaveIP, OUT char *VersionInfo); // [6/4/2015 andy.wang]
U32 ADVCMNAPI Acm_DevSetSlaveID(HAND DeviceHandle, U16 RingNo, U16 SlaveIP, U16 SlaveNewIP); // [6/23/2015 andy.wang]
U32 ADVCMNAPI Acm_WriteRingBuffer(HAND Handle, U32 cmd_id, U32 data_index, U32 data_cnt, PU32 dataBuffer);
U32 ADVCMNAPI Acm_ReadRingBuffer(HAND Handle, PU32 cmd_id, PU32 data_index, U32 data_cnt, PU32 dataBuffer);
U32 ADVCMNAPI Acm_DevGetModuleInfo(HAND DeviceHandle, U16 RingNo, U16 SlaveIP, PU32 ModIDArray, PU32 ModCnt);
U32 ADVCMNAPI Acm_DevSetSlaveID(HAND DeviceHandle, U16 RingNo, U16 SlaveIP, U16 SlaveNewIP);
// [2/28/2014 dan.yang]
U32 ADVCMNAPI Acm_GetU32Property(HAND Handle, U32 ProperyID, PU32 Value);
U32 ADVCMNAPI Acm_GetI32Property(HAND Handle, U32 ProperyID, PI32 Value);
U32 ADVCMNAPI Acm_GetF64Property(HAND Handle, U32 ProperyID, PF64 Value);
U32 ADVCMNAPI Acm_GetStringProperty (HAND Handle, U32 ProperyID, PU8 Value);
U32 ADVCMNAPI Acm_SetU32Property (HAND Handle, U32 ProperyID, U32 Value);
U32 ADVCMNAPI Acm_SetI32Property (HAND Handle, U32 ProperyID, I32 Value);
U32 ADVCMNAPI Acm_SetF64Property (HAND Handle, U32 ProperyID, F64 Value);
U32 ADVCMNAPI Acm_SetStringProperty (HAND Handle, U32 ProperyID, PU8 Value);
U32 ADVCMNAPI Acm_CheckVersion(HAND DeviceHandle, U32 VersionID, PU32 Result); // [11/3/2015 dandan.yang]:just for utility
// [11/20/2014 dan]
U32 ADVCMNAPI Acm_GetChannelProperty(HAND Handle, U32 ChannelID, U32 ProperyID, PF64 Value);
U32 ADVCMNAPI Acm_SetChannelProperty(HAND Handle, U32 ChannelID, U32 ProperyID, F64 Value);
U32 ADVCMNAPI Acm_GetMultiChannelProperty(HAND Handle, U32 ProperyID, U32 StartChID, U32 ChCount, PF64 ValueArray);
U32 ADVCMNAPI Acm_SetMultiChannelProperty(HAND Handle, U32 ProperyID, U32 StartChID, U32 ChCount, PF64 ValueArray);
U32 ADVCMNAPI Acm_DevMutiTrigSetCmpDO(HAND DeviceHandle,U32 OFForON);
U32 ADVCMNAPI Acm_DevMutiTrigForceCmpOut(HAND DeviceHandle, U32 OFForON);
//Master device operation
U32 ADVCMNAPI Acm_MasStartRing(HAND DeviceHandle, U16 RingNo);
U32 ADVCMNAPI Acm_MasStopRing(HAND DeviceHandle, U16 RingNo);
U32 ADVCMNAPI Acm_MasGetComStatus(HAND DeviceHandle, U16 RingNo, PU16 pStatus);
U32 ADVCMNAPI Acm_MasGetComCyclicTime(HAND DeviceHandle, U16 RingNo, PF64 pTime);
U32 ADVCMNAPI Acm_MasGetDataCyclicTime(HAND DeviceHandle, U16 RingNo, PF64 DataCyclicTime);
U32 ADVCMNAPI Acm_MasGetActiveTable(HAND DeviceHandle, U16 RingNo, PU32 ActiveTableArray, PU32 ArrayElements);
U32 ADVCMNAPI Acm_MasGetErrorTable(HAND DeviceHandle, U16 RingNo, PU32 ErrorTableArray, PU32 ArrayElements);
U32 ADVCMNAPI Acm_MasGetSlaveInfo(HAND DeviceHandle, U16 RingNo, U16 SlaveIP, PU32 pInfo);
U32 ADVCMNAPI Acm_MasLogComStatus(HAND DeviceHandle, U16 RingNo);
U32 ADVCMNAPI Acm_MasTrigOut(HAND DeviceHandle, U16 RingNo);//Engineer function, don't release
U32 ADVCMNAPI Acm_MasGetRingStatus(HAND DeviceHandle, U16 RingNo, PU16 pStatus);//internal function don't release.
//Axis operation
U32 ADVCMNAPI Acm_AxOpen(HAND DeviceHandle, U16 PhyAxis, PHAND AxisHandle);
U32 ADVCMNAPI Acm_AxOpenbyID(HAND DeviceHandle, U16 SlaveIP, PHAND AxisHandle);//Add for pci1203
U32 ADVCMNAPI Acm_AxClose(PHAND AxisHandle);
U32 ADVCMNAPI Acm_AxSetSvOn(HAND AxisHandle, U32 OnOff);
U32 ADVCMNAPI Acm_AxSetErcOn(HAND AxisHandle, U32 OnOff);
U32 ADVCMNAPI Acm_AxResetAlm(HAND AxisHandle, U32 OnOff);
U32 ADVCMNAPI Acm_AxMoveRel(HAND AxisHandle, F64 Distance);
U32 ADVCMNAPI Acm_AxMoveAbs(HAND AxisHandle, F64 Position);
U32 ADVCMNAPI Acm_AxMoveRel_EC(HAND AxisHandle, F64 Position);//zhaocui add 20131203 for hongjin
U32 ADVCMNAPI Acm_AxMoveVel(HAND AxisHandle, U16 Direction);
U32 ADVCMNAPI Acm_AxStopDec(HAND AxisHandle);
U32 ADVCMNAPI Acm_AxStopEmg(HAND AxisHandle);
U32 ADVCMNAPI Acm_AxMoveImpose(HAND AxisHandle, F64 Position, F64 NewVel); //Add for pci1265 and pci1245 [dan.yang 2011.04.20]
U32 ADVCMNAPI Acm_AxHomeEx(HAND AxisHandle, U32 DirMode);
U32 ADVCMNAPI Acm_AxHome(HAND AxisHandle, U32 HomeMode, U32 DirMode);
U32 ADVCMNAPI Acm_AxMoveHome(HAND AxisHandle, U32 HomeMode, U32 Dir);
// U32 Acm_AxPauseMotion(U32 AxisHandle);
// U32 Acm_AxResumeMotion(U32 AxisHandle);
U32 ADVCMNAPI Acm_AxChangeVel(HAND AxisHandle, F64 NewVel);
U32 ADVCMNAPI Acm_AxChangePos(HAND AxisHandle, F64 NewPos);
U32 ADVCMNAPI Acm_AxChangeVelByRate(HAND AxisHandle, U32 Rate); // [11/21/2012 dan.yang]
U32 ADVCMNAPI Acm_AxResetError(HAND AxisHandle);
U32 ADVCMNAPI Acm_AxGetState(HAND AxisHandle, PU16 State);
U32 ADVCMNAPI Acm_AxGetMotionIO(HAND AxisHandle, PU32 Status);
U32 ADVCMNAPI Acm_AxGetMotionStatus(HAND AxisHandle, PU32 Status);
U32 ADVCMNAPI Acm_GetLastError(HAND Handle);
U32 ADVCMNAPI Acm_AxGetCmdPosition(HAND AxisHandle, PF64 Position);
U32 ADVCMNAPI Acm_AxGetMachPosition(HAND AxisHandle, PF64 Position);
U32 ADVCMNAPI Acm_AxSetCmdPosition(HAND AxisHandle, F64 Position);
U32 ADVCMNAPI Acm_AxGetActualPosition(HAND AxisHandle, PF64 Position);
U32 ADVCMNAPI Acm_AxSetActualPosition(HAND AxisHandle, F64 Position);
U32 ADVCMNAPI Acm_AxGetCmdVelocity(HAND AxisHandle, PF64 Velocity);
U32 ADVCMNAPI Acm_AxGetLagCounter(HAND AxisHandle, PF64 Position);
U32 ADVCMNAPI Acm_AxGetLatchData(HAND AxisHandle, U32 PositionNo, PF64 Position); // [5/30/2011 dan.yang]
U32 ADVCMNAPI Acm_AxStartSoftLatch(U32 AxisHandle);
U32 ADVCMNAPI Acm_AxSetExtDrive(HAND AxisHandle, U16 ExtDrvMode);
U32 ADVCMNAPI Acm_AxDoSetBit(HAND AxisHandle, U16 DoChannel, U8 BitData);
U32 ADVCMNAPI Acm_AxDoGetBit(HAND AxisHandle, U16 DoChannel, PU8 BitData);
U32 ADVCMNAPI Acm_AxDiGetBit(HAND AxisHandle, U16 DiChannel, PU8 BitData);
U32 ADVCMNAPI Acm_AxSimStartSuspendVel(HAND AxisHandle, U16 DriDir);
U32 ADVCMNAPI Acm_AxSimStartSuspendRel(HAND AxisHandle,F64 Distance);
U32 ADVCMNAPI Acm_AxSimStartSuspendAbs(HAND AxisHandle,F64 EndPoint);
U32 ADVCMNAPI Acm_AxSimStart(HAND AxisHandle);
U32 ADVCMNAPI Acm_AxSimStop(HAND AxisHandle);
U32 ADVCMNAPI Acm_AxResetLatch(HAND AxisHandle);//Add for pci1245 and pci1265 [dan.yang 2011.05.05]
U32 ADVCMNAPI Acm_AxGetLatchFlag(HAND AxisHandle, PU8 LatchFlag);//Add for pci1245 and pci1265 [dan.yang 2011.05.05]
U32 ADVCMNAPI Acm_AxTriggerLatch(HAND AxisHandle); //Add for pci1245 and pci1265 [dan.yang 2011.05.10]
U32 ADVCMNAPI Acm_AxCamInAx (HAND AxisHandle, //Add for pci1245 and pci1265 [dan.yang 2011.05.10]
HAND MasAxisHandle,
F64 MasterOffset,
F64 SlaveOffset,
F64 MasterScaling,
F64 SlaveScaling,
U32 CamTableID,
U32 RefSrc);
U32 ADVCMNAPI Acm_AxGearInAx(HAND AxisHandle, //Add for pci1245 and pci1265 [dan.yang 2011.06.23]
HAND MasAxisHandle,
I32 Numerator,
I32 Denominator,
U32 RefSrc,
U32 Absolute);
U32 ADVCMNAPI Acm_AxTangentInGp (HAND AxisHandle, //Add for pci1245 and pci1265 [dan.yang 2011.06.24]
HAND MasGroupHandle,
PI16 StartVectorArray, //must three dimension
U8 Working_plane, // 0: XY plane (default), 1: YZ plane, 2: XZ plane
I16 Direction); //0: same with master group. 1:opposite
U32 ADVCMNAPI Acm_AxGantryInAx (HAND AxisHandle, //Add for pci1245 and pci1265 [dan.yang 2011.06.24]
HAND MasAxisHandle,
I16 RefMasterSrc,
I16 direction); //0: same with master axis. 1:opposite
U32 ADVCMNAPI Acm_AxPhaseAx(HAND AxisHandle, F64 Acc, F64 Dec, F64 PhaseSpeed, F64 PhaseDist);
// [12/14/2012 dan.yang]
U32 ADVCMNAPI Acm_AxChangeVelEx(HAND AxisHandle,
F64 NewVel,
F64 NewAcc,
F64 NewDec);
U32 ADVCMNAPI Acm_AxChangeVelExByRate(HAND AxisHandle,
U32 Rate, //The percentage of velocity to be changed.
F64 NewAcc, // New acceleration.
F64 NewDec); // New deceleration.
// [12/14/2012 dan.yang]
U32 ADVCMNAPI Acm_AxStopDecEx(HAND AxisHandle,
F64 NewDec);
// [10/30/2013 dan.yang]: Add compare channel
U32 ADVCMNAPI Acm_AxSetChannelCmpSetting(HAND AxisHandle, U16 ChannelID, U32 CmpSrc, U32 CmpMethod, U32 CmpPulseMode, U32 CmpPulseWidth);
U32 ADVCMNAPI Acm_AxGetChannelCmpSetting(HAND AxisHandle, U16 ChannelID, PU32 CmpSrc, PU32 CmpMethod, PU32 CmpPulseMode, PU32 CmpPulseWidth);
U32 ADVCMNAPI Acm_AxResetChannelCmp (HAND AxisHandle, U16 ChannelID);
U32 ADVCMNAPI Acm_AxAddChannelCmpDatas(HAND AxisHandle, U16 ChannelID, PF64 TableArray, U32 ArrayCount);
U32 ADVCMNAPI Acm_AxGetChannelCmpData(HAND AxisHandle, U16 ChannelID, PF64 CmpData);
U32 ADVCMNAPI Acm_AxLoadChannelNextData(HAND AxisHandle, U16 ChannelID);
U32 ADVCMNAPI Acm_AxGetCmpbufferRemainCount(HAND AxisHandle, U16 ChannelID,PU32 DataCount);
U32 ADVCMNAPI Acm_AxDoSetByte(HAND AxisHandle, U16 DoPort, U8 ByteData);
U32 ADVCMNAPI Acm_AxDoGetByte(HAND AxisHandle, U16 DoPort, PU8 ByteData);
U32 ADVCMNAPI Acm_AxDiGetByte(HAND AxisHandle, U16 DiPort, PU8 ByteData);
//Group operation
U32 ADVCMNAPI Acm_GpAddAxis(PHAND GpHandle,HAND AxHandle);
U32 ADVCMNAPI Acm_GpRemAxis(HAND GroupHandle, HAND AxisHandle);
U32 ADVCMNAPI Acm_GpClose(PHAND GroupHandle);
U32 ADVCMNAPI Acm_GpGetState(HAND GroupHandle, PU16 State);
U32 ADVCMNAPI Acm_GpResetError(HAND GroupHandle);
U32 ADVCMNAPI Acm_GpMoveLinearRel(HAND GroupHandle, PF64 DistanceArray, PU32 ArrayElements);
U32 ADVCMNAPI Acm_GpMoveLinearAbs(HAND GroupHandle, PF64 PositionArray, PU32 ArrayElements);
U32 ADVCMNAPI Acm_GpMoveDirectRel(HAND GroupHandle, PF64 DistanceArray, PU32 ArrayElements);
U32 ADVCMNAPI Acm_GpMoveDirectAbs(HAND GroupHandle, PF64 PositionArray, PU32 ArrayElements);
U32 ADVCMNAPI Acm_GpMoveCircularRel(HAND GroupHandle, PF64 CenterArray, PF64 EndArray,
PU32 ArrayElements, I16 Direction);
U32 ADVCMNAPI Acm_GpMoveCircularAbs(HAND GroupHandle, PF64 CenterArray, PF64 EndArray,
PU32 ArrayElements, I16 Direction);
U32 ADVCMNAPI Acm_GpMoveCircularRel_3P(HAND GroupHandle,
PF64 RefArray,
PF64 EndArray,
PU32 pArrayElements,
I16 Direction );
U32 ADVCMNAPI Acm_GpMoveCircularAbs_3P(HAND GroupHandle,
PF64 RefArray,
PF64 EndArray,
PU32 pArrayElements,
I16 Direction );
U32 ADVCMNAPI Acm_GpMoveHelixAbs(HAND GroupHandle,
PF64 CenterArray,
PF64 EndArray,
PU32 pArrayElements,
I16 Direction); // [6/21/2011 dan.yang]
U32 ADVCMNAPI Acm_GpMoveHelixRel(HAND GroupHandle,
PF64 CenterArray,
PF64 EndArray,
PU32 pArrayElements,
I16 Direction); // [6/21/2011 dan.yang]
U32 ADVCMNAPI Acm_GpMoveHelixAbs_3P(HAND GroupHandle,
PF64 RefArray,
PF64 EndArray,
PU32 pArrayElements,
I16 Direction ); // [6/21/2011 dan.yang]
U32 ADVCMNAPI Acm_GpMoveHelixRel_3P(HAND GroupHandle,
PF64 RefArray,
PF64 EndArray,
PU32 pArrayElements,
I16 Direction ); // [6/21/2011 dan.yang]
U32 ADVCMNAPI Acm_GpLoadPath(HAND GroupHandle, PI8 FilePath, PHAND PathHandle, PU32 pTotalCount);
U32 ADVCMNAPI Acm_GpUnloadPath(HAND GroupHandle, PHAND PathHandle);
U32 ADVCMNAPI Acm_GpMovePath(HAND GroupHandle, HAND PathHandle);
U32 ADVCMNAPI Acm_GpMoveAllPath(PHAND GroupHandle, U32 ArrayElements);
U32 ADVCMNAPI Acm_GpAddPath (HAND GroupHandle,U16 MoveCmd,U16 MoveMode,F64 FH,F64 FL,
PF64 EndPoint_DataArray,PF64 CenPoint_DataArray,PU32 ArrayElements);
U32 ADVCMNAPI Acm_GpResetPath (PHAND GroupHandle);
U32 ADVCMNAPI Acm_GpGetPathStatus (HAND GroupHandle, // IN, Group Handle
PU32 pCurIndex, // IN, OUT, Current index of path data in path buffer
PU32 pCurCmdFunc, // IN, OUT, Return current command function in executing
PU32 pRemainCount, // IN, OUT, Number of unexecuted path data in path
PU32 pFreeSpaceCount );
U32 ADVCMNAPI Acm_GpStopDec(HAND GroupHandle);
U32 ADVCMNAPI Acm_GpStopEmg(HAND GroupHandle);
U32 ADVCMNAPI Acm_GpChangeVel(HAND GroupHandle, F64 NewVelocity);
U32 ADVCMNAPI Acm_GpChangeVelByRate(HAND GroupHandle, U32 Rate);// [11/21/2012 dan.yang]
U32 ADVCMNAPI Acm_GpGetCmdVel(HAND GroupHandle, PF64 CmdVel); //Add for PCI1245 and PCI1265.[Dan.Yang 20110607]
U32 ADVCMNAPI Acm_GpMoveSelPath(HAND GroupHandle, // [6/22/2011 dan.yang]
HAND PathHandle,
U32 StartIndex, // range: 0~9999
U32 EndIndex, // range: 0~9999
U8 Repeat);
U32 ADVCMNAPI Acm_GpGetPathIndexStatus(HAND GroupHandle, // [6/22/2011 dan.yang]
U32 Index, // index of path
PU16 CmdFunc,
PU16 MoveMode,
PF64 FH,
PF64 FL,
PF64 EndPoint_DataArray,
PF64 CenPoint_DataArray,
PU32 ArrayElements);
U32 ADVCMNAPI Acm_GpResumeMotion(HAND GroupHandle); // [10/12/2012 dan.yang]
U32 ADVCMNAPI Acm_GpPauseMotion(HAND GroupHandle); // [10/12/2012 dan.yang]
U32 ADVCMNAPI Acm_GpMove3DArcAbs( HAND GroupHandle,
PF64 CenterArray,
PF64 EndArray,
PU32 pArrayElements,
I16 Direction);//zhaocui add 201308
U32 ADVCMNAPI Acm_GpMove3DArcRel( HAND GroupHandle,
PF64 CenterArray,
PF64 EndArray,
PU32 pArrayElements,
I16 Direction);//zhaocui add 201308
U32 ADVCMNAPI Acm_GpMove3DArcAbs_V( HAND GroupHandle,
PF64 CenterArray,
PF64 NVectorArray,
F64 Degree,
PU32 pArrayElements,
I16 Direction);//zhaocui add 201308
U32 ADVCMNAPI Acm_GpMove3DArcRel_V( HAND GroupHandle,
PF64 CenterArray,
PF64 NVectorArray,
F64 Degree,
PU32 pArrayElements,
I16 Direction);//zhaocui add 201308
U32 ADVCMNAPI Acm_GpMove3DArcAbs_3P( HAND GroupHandle,
PF64 RefArray,
PF64 EndArray,
PU32 pArrayElements,
I16 Direction,
U16 cycCount);
U32 ADVCMNAPI Acm_GpMove3DArcRel_3P( HAND GroupHandle,
PF64 RefArray,
PF64 EndArray,
PU32 pArrayElements,
I16 Direction,
U16 cycCount);
U32 ADVCMNAPI Acm_GpAddBSplinePath(
HAND GroupHandle, // Handle
F64 FH, // Feed rate
F64 FL, // Initial feed rate
F64 *CtrlP0List, // The control points of axis 0 (X-Axis)
F64 *CtrlP1List, // The control points of axis 1 (Y-Axis)
U32 CtrlPCount, // The number of control points
F64 *NodeList, // *B-Spine knot list
U32 NodeCount, // *The number of knot
U32 Degree, // B-Spline degree
U32 CutPointCount // The number of line segments used in interpolation
);
U32 Acm_GpAddCSplinePath(
HAND GroupHandle, // Group Handle
F64 FH, // Feed rate
F64 FL, // Initial feed rate
F64 *CtrlP0List, // The control points of axis 0 (X-Axis)
F64 *CtrlP1List, // The control points of axis 1 (Y-Axis)
F64 *Tightness, //
U32 CtrlPCount, // The number of control points
U32 CutPointCount // The number of line segments used in interpolation
);
// DIO
U32 ADVCMNAPI Acm_DaqDiGetByte(HAND DeviceHandle, U16 DiPort,PU8 ByteData);
U32 ADVCMNAPI Acm_DaqDiGetBit(HAND DeviceHandle, U16 DiChannel, PU8 BitData);
U32 ADVCMNAPI Acm_DaqDoSetByte(HAND DeviceHandle, U16 DoPort, U8 ByteData);
U32 ADVCMNAPI Acm_DaqDoSetBit(HAND DeviceHandle, U16 DoChannel, U8 BitData);
U32 ADVCMNAPI Acm_DaqDoGetByte(HAND DeviceHandle, U16 DoPort, PU8 ByteData);
U32 ADVCMNAPI Acm_DaqDoGetBit(HAND DeviceHandle, U16 DoChannel, PU8 BitData);
U32 ADVCMNAPI Acm_DaqDiGetBytes(HAND DeviceHandle, U16 StartPort, U16 NumPort, PU8 ByteDataArray);
U32 ADVCMNAPI Acm_DaqDoSetBytes(HAND DeviceHandle, U16 StartPort, U16 NumPort, PU8 ByteDataArray);
U32 ADVCMNAPI Acm_DaqDoGetBytes(HAND DeviceHandle, U16 StartPort, U16 NumPort, PU8 ByteDataArray);
//AIO [Dan.Yang 2011.07.19]
U32 ADVCMNAPI Acm_DaqAiGetRawData(HAND DeviceHandle, U16 AiChannel, PU16 AiData);
U32 ADVCMNAPI Acm_DaqAiGetVoltData(HAND DeviceHandle, U16 AiChannel, PF32 AiData);
U32 ADVCMNAPI Acm_DaqAiGetCurrData(HAND DeviceHandle, U16 AiChannel, PF32 AiData);
U32 ADVCMNAPI Acm_DaqAiZeroCalibration(HAND DeviceHandle, U16 AiChannel);
U32 ADVCMNAPI Acm_DaqAiSpanCalibration(HAND DeviceHandle, U16 AiChannel);
U32 ADVCMNAPI Acm_DaqAiGetChannelStatus(HAND DeviceHandle, U16 AiChannel, PU32 ChanStatus);
U32 ADVCMNAPI Acm_DaqAoSetRawData(HAND DeviceHandle, U16 AoChannel, U16 AoData);
U32 ADVCMNAPI Acm_DaqAoSetVoltData(HAND DeviceHandle, U16 AoChannel, F32 AoData);
U32 ADVCMNAPI Acm_DaqAoSetCurrData(HAND DeviceHandle, U16 AoChannel, F32 AoData);
U32 ADVCMNAPI Acm_DaqAoGetRawData(HAND DeviceHandle, U16 AoChannel, PU16 AoData);
U32 ADVCMNAPI Acm_DaqAoGetVoltData(HAND DeviceHandle, U16 AoChannel, PF32 AoData);
U32 ADVCMNAPI Acm_DaqAoGetCurrData(HAND DeviceHandle, U16 AoChannel, PF32 AoData);
U32 ADVCMNAPI Acm_DaqAoSetCaliType(HAND DeviceHandle, U16 AoChannel, U16 TrimType);
U32 ADVCMNAPI Acm_DaqAoSetCaliValue(HAND DeviceHandle, U16 AoChannel, U16 CaliData);
U32 ADVCMNAPI Acm_DaqAoCaliDone(HAND DeviceHandle, U16 AoChannel, bool done);
U32 ADVCMNAPI Acm_DaqAoCaliDefault(HAND DeviceHandle, U16 AoChannel);
U32 ADVCMNAPI Acm_DaqGetIOLinkStatus(HAND DeviceHandle, PU32 pStatus); //ydd 16.2.4
//Counter [Andy.Wang 2015.04.21]
U32 ADVCMNAPI Acm_DaqCntTriggerCmp(HAND DeviceHandle, U16 CntChannel);
U32 ADVCMNAPI Acm_DaqCntResetLatch(HAND DeviceHandle, U16 CntChannel);
U32 ADVCMNAPI Acm_DaqCntResetCmp(HAND DeviceHandle, U16 CntChannel);
U32 ADVCMNAPI Acm_DaqCntResetCnt(HAND DeviceHandle, U16 CntChannel);
U32 ADVCMNAPI Acm_DaqCntGetCounterData(HAND DeviceHandle, U16 CntChannel, PI32 CounterData);
U32 ADVCMNAPI Acm_DaqCntGetLatchData(HAND DeviceHandle, U16 CntChannel, PI32 LatchData);
U32 ADVCMNAPI Acm_DaqCntGetCmpData(HAND DeviceHandle, U16 CntChannel, PI32 CmpData);
//mining: Compare functions
U32 ADVCMNAPI Acm_AxSetCmpAuto(HAND AxisHandle, F64 Start, F64 End, F64 Interval);
U32 ADVCMNAPI Acm_AxGetCmpData(HAND AxisHandle, PF64 CmpPosition);
U32 ADVCMNAPI Acm_AxSetCmpData(HAND AxisHandle, F64 CmpPosition);
U32 ADVCMNAPI Acm_AxSetCmpTable(HAND AxisHandle, PF64 TableArray, I32 ArrayCount);
//Dan.Yang 2011.07.12 :Add for download Dsp Firmware program.
U32 ADVCMNAPI Acm_GetDSPFrmWareDwnLoadRate(HAND DeviceHandle, PF64 Percentage);
U32 ADVCMNAPI Acm_DevDownLoadDSPFrmWare_STP1(HAND DeviceHandle);
U32 ADVCMNAPI Acm_DevDownLoadDSPFrmWare_STP2(HAND DeviceHandle, PI8 FilePath);
U32 ADVCMNAPI Acm_DevDownLoadDSPFrmWare_STP3(HAND DeviceHandle);
U32 ADVCMNAPI Acm_DownLoadMCU_ST2(HAND DeviceHandle, U16 CPLDNo, PI8 FilePath);
U32 ADVCMNAPI Acm_DownLoadMCU_ST1(HAND DeviceHandle, U16 CPLDNo);
U32 ADVCMNAPI Acm_GetMCUDownLoadRate(HAND DeviceHandle, PF64 Percentage);
U32 ADVCMNAPI Acm_AxPWMOut(HAND AxisHandle,U32 OFForON,U32 PulseCount);
U32 ADVCMNAPI Acm_AxGetPWMOutState(HAND AxisHandle,PU32 OFForON);
U32 ADVCMNAPI Acm_DownLoadCPLD_ST2(HAND DeviceHandle, U16 CPLDNo, PI8 FilePath);
U32 ADVCMNAPI Acm_DownLoadCPLD_ST1(HAND DeviceHandle, U16 CPLDNo);
U32 ADVCMNAPI Acm_GetCPLDDownLoadRate(HAND DeviceHandle, PF64 Percentage);
U32 ADVCMNAPI Acm_DevMDaqConfig(HAND DeviceHandle, U16 ChannelID, U32 Period, U32 AxisNo, U32 Method, U32 ChanType, U32 Count);
U32 ADVCMNAPI Acm_DevMDaqStart(HAND DeviceHandle);
U32 ADVCMNAPI Acm_DevMDaqStop(HAND DeviceHandle);
U32 ADVCMNAPI Acm_DevMDaqReset(HAND DeviceHandle, U16 ChannelID);
U32 ADVCMNAPI Acm_DevMDaqGetStatus(HAND DeviceHandle, U16 ChannelID, PU16 CurrentCnt, PU8 Status);
U32 ADVCMNAPI Acm_DevMDaqGetData(HAND DeviceHandle, U16 ChannelID, U16 StartIndex, U16 MaxCount, PI32 DataBuffer);
U32 ADVCMNAPI Acm_DevMDaqGetConfig(HAND DeviceHandle, U16 ChannelID, PU32 Period, PU32 AxisNo, PU32 Method, PU32 ChanType, PU32 Count);
U32 ADVCMNAPI Acm_AxReadLatchBuffer(HAND AxisHandle, PF64 LatchDataArray, PU32 DataCnt);
U32 ADVCMNAPI Acm_AxResetLatchBuffer(HAND AxisHandle);
U32 ADVCMNAPI Acm_AxGetLatchBufferStatus(HAND AxisHandle, PU32 RemainCnt, PU32 SpaceCnt);
//******************SCARA Robot*************************************************/
U32 Acm_GpRbSetMode(HAND GroupHandle, U16 Mode, PI32 CurActPosiArray, U32 ArrayElement);
U32 Acm_GpRbGetCmdPosition(HAND GroupHandle, PF64 PositionArray, U32 ArrayElement);
U32 Acm_GpRbGetActualPosition(HAND GroupHandle, PF64 PositionArray, U32 ArrayElement);
U32 Acm_GpRbGetArmCmdPosition(HAND GroupHandle, U16 ArmID, PF64 CurPosi);
U32 Acm_GpRbGetArmActualPosition(HAND GroupHandle, U16 ArmID, PF64 CurPosi);
//******************************************************************************/
//add by dujunling on 2012.11.22,for GM code function ,
U32 ADVCMNAPI Acm_GmOpen( IN HAND DeviceHandle, OUT PHAND GMSHandle );
U32 ADVCMNAPI Acm_GmClose(IN HAND GMSHandle);
U32 ADVCMNAPI Acm_GmLoadJob(IN HAND GMSHandle, IN PI8 JobFilePath, OUT PU32 ErrorRow);
U32 ADVCMNAPI Acm_GmUploadJob( IN HAND GMSHandle, IN OUT PI8 GCodeBuffer, IN OUT PU32 GCodeLength);
U32 ADVCMNAPI Acm_GmResetJob( IN HAND GMSHandle);
U32 ADVCMNAPI Acm_GmCommand(IN HAND GMSHandle, IN PI8 InputCmd);
U32 ADVCMNAPI Acm_GmRemoveAxisFromSystem(IN HAND GMSHandle, IN U32 uAxisId);
U32 ADVCMNAPI Acm_GmSetCompensationRadius(IN HAND GMSHandle, IN U32 DValue,IN F64 Radius);
U32 ADVCMNAPI Acm_GmGetCompensationRadius(IN HAND GMSHandle, OUT PU32 pCRArray,IN OUT PU32 pCRArrayLength);
U32 ADVCMNAPI Acm_GmSetCurrentCompensationRadius(IN HAND GMSHandle, IN F64 Radius);
U32 ADVCMNAPI Acm_GmGetCurrentCompensationRadius(IN HAND GMSHandle, IN OUT PF64 pCRadius);
U32 ADVCMNAPI Acm_GmSetToolLengthOffset(IN HAND GMSHandle, IN U32 HValue,IN F64 ToolLengthOffset);
U32 ADVCMNAPI Acm_GmGetToolLengthOffset(IN HAND GMSHandle, OUT PU32 pTLOArray,IN OUT PU32 pTLOArrayLength);
U32 ADVCMNAPI Acm_GmSetCurrentToolLengthOffset(IN HAND GMSHandle,IN F64 ToolLengthOffset);
U32 ADVCMNAPI Acm_GmGetCurrentToolLengthOffset(IN HAND GMSHandle, IN OUT PF64 pToolLengthOffset);
U32 ADVCMNAPI Acm_GmSetMacro(IN HAND GMSHandle, IN U32 uMacroCmd,IN const PI8 MacroCmdContent);
U32 ADVCMNAPI Acm_GmGetMacro(IN HAND GMSHandle, IN U32 uMacroCmd,OUT PI8 pMacroCmdContent,IN OUT PU32 pMacroCmdContentLength);
U32 ADVCMNAPI Acm_GmGetMacroArray(IN HAND GMSHandle,OUT PU32 pMacroArray,IN OUT PU32 pMacroArrayLength);
U32 ADVCMNAPI Acm_GmSetPreCustomFunction(IN HAND GMSHandle, IN U32 (*ptrPreCustomFunction)(const U32 CustomMCommand,U32 TWordValue,bool &bDone));
U32 ADVCMNAPI Acm_GmSetFinalCustomFunction(IN HAND GMSHandle, IN U32 (*ptrFinalCustomFunction)(const U32 CustomMCommand,U32 TWordValue,bool &bDone));
U32 ADVCMNAPI Acm_GmSetExtDoFunction(IN HAND GMSHandle, IN U32 (*ptrExtDoFunction)(U32 uDoCh,U32 uDoLevel));
U32 ADVCMNAPI Acm_GmSetExtDiFunction(IN HAND GMSHandle, IN U32 (*ptrExtDiFunction)(U32 uDiCh));
U32 ADVCMNAPI Acm_GmSetBreakPoint(IN HAND GMSHandle, IN U32 uBreakPoint);
U32 ADVCMNAPI Acm_GmAddBreakPoint(IN HAND GMSHandle, IN U32 uBreakPoint);
U32 ADVCMNAPI Acm_GmRemoveBreakPoint(IN HAND GMSHandle, IN U32 uBreakPoint);
U32 ADVCMNAPI Acm_GmClearBreakPoint(IN HAND GMSHandle);
U32 ADVCMNAPI Acm_GmSetSpindleRatio(IN HAND GMSHandle, IN F64 fSpindleRatio);
U32 ADVCMNAPI Acm_GmSetJogRatio(IN HAND GMSHandle, IN F64 fJogRatio);
U32 ADVCMNAPI Acm_GmSetFastFeedRateRatio(IN HAND GMSHandle, IN U32 uAxis,IN F64 fFastFeedRateRatio);
U32 ADVCMNAPI Acm_GmGetFastFeedRateRatio(IN HAND GMSHandle, IN U32 uAxis,OUT PF64 pFastFeedRateRatio);
U32 ADVCMNAPI Acm_GmSetFeedRateRatio(IN HAND GMSHandle, IN F64 fFeedRateRatio);
U32 ADVCMNAPI Acm_GmGetFeedRateRatio(IN HAND GMSHandle, OUT PF64 pFeedRateRatio);
U32 ADVCMNAPI Acm_GmSetFeedRate(IN HAND GMSHandle, IN F64 fFeedRate);
U32 ADVCMNAPI Acm_GmGetFeedRate(IN HAND GMSHandle, IN PF64 pFeedRate);
U32 ADVCMNAPI Acm_GmSetFastFeedRate(IN HAND GMSHandle, IN F64 fFastFeedRate);
U32 ADVCMNAPI Acm_GmGetFastFeedRate(IN HAND GMSHandle, OUT PF64 pFastFeedRate);
U32 ADVCMNAPI Acm_GmSetOptionPause(IN HAND GMSHandle, IN U32 uOptionPause);
U32 ADVCMNAPI Acm_GmGetOptionPause(IN HAND GMSHandle, OUT PU32 pOptionPause);
U32 ADVCMNAPI Acm_GmSetOptionSkip(IN HAND GMSHandle, IN U32 uOptionSkip);
U32 ADVCMNAPI Acm_GmGetOptionSkip(IN HAND GMSHandle, OUT PU32 pOptionSkip);
U32 ADVCMNAPI Acm_GmSetModuleRange(IN HAND GMSHandle, IN U32 ModuleRange);
U32 ADVCMNAPI Acm_GmGetModuleRange(IN HAND GMSHandle, IN PU32 pModuleRange);
U32 ADVCMNAPI Acm_GmGetCurrentFeedRate(IN HAND GMSHandle, OUT PF64 pCurrentFeedRate);
U32 ADVCMNAPI Acm_GmGetCurrentRow(IN HAND GMSHandle, OUT PU32 CurrentRow);
U32 ADVCMNAPI Acm_GmGetErrorRow(IN HAND GMSHandle, OUT PU32 ErrorRow);
U32 ADVCMNAPI Acm_GmGetCurrentCommand(IN HAND GMSHandle, OUT PI8 CurrentCmd, IN OUT PU32 CurrentCmdLength);
U32 ADVCMNAPI Acm_GmGetState(IN HAND GMSHandle, OUT PU32 GmsState);
U32 ADVCMNAPI Acm_GmGetPattern(IN HAND GMSHandle, IN U32 GmsPatternId, PVOID Buffer, PU32 BufferLength);
U32 ADVCMNAPI Acm_GmGetCurrentCoordinateSystem(IN HAND GMSHandle, OUT PU32 pCurrentCoordinateIndex,OUT PF64 pCoordinateArray,IN OUT PU32 pArrayLength);
U32 ADVCMNAPI Acm_GmGetError(IN HAND GMSHandle, OUT PU32 ErrorCode, OUT PU32 LastError);
U32 ADVCMNAPI Acm_GmDxfToGCodeTextEx(IN PI8 DxfFilePath, IN F64 DxfProportion, IN U32 Ellipse_Cut_Min_Angel , IN U32 Spline_Cut_Step ,OUT PI8 GCodeBuffer, IN OUT PU32 Length);
U32 ADVCMNAPI Acm_GmDxfToGCodeText(IN PI8 DxfFilePath, IN F64 DxfProportion, OUT PI8 GCodeBuffer, IN OUT PU32 Length);
U32 ADVCMNAPI Acm_GmDxfToGCodeFileEx(IN PI8 DxfFilePath, IN F64 DxfProportion,IN U32 Ellipse_Cut_Min_Angel , IN U32 Spline_Cut_Step ,IN PI8 GcodeFilePath,OUT PU32 Length);
U32 ADVCMNAPI Acm_GmDxfToGCodeFile(IN PI8 DxfFilePath, IN F64 DxfProportion,IN PI8 GcodeFilePath,PU32 Length);
//Added by W.Y.Z on 2014.08.28 for P point function
U32 ADVCMNAPI Acm_GmSetPoint(IN HAND GMSHandle, IN U32 id, IN PF64 fPoint);
U32 ADVCMNAPI Acm_GmGetPoint(IN HAND GMSHandle, IN U32 id,OUT PF64 fPoint);
U32 ADVCMNAPI Acm_GmLoadPoint(IN HAND GMSHandle, IN PI8 FilePath);
U32 ADVCMNAPI Acm_GmSavePoint(IN HAND GMSHandle, IN PI8 FilePath);
U32 ADVCMNAPI Acm_GmResetPoint(IN HAND GMSHandle);
U32 ADVCMNAPI Acm_GmSetPointF(IN HAND GMSHandle, IN U32 id, IN PF64 fPoint,IN U32 filterFlag);
U32 ADVCMNAPI Acm_GmGetPointF(IN HAND GMSHandle, IN U32 id,OUT PF64 fPoint,OUT PU32 filterflag);
//U32 ADVCMNAPI Acm_GmLoadPointF(IN HAND GMSHandle, IN PI8 FilePath);
//U32 ADVCMNAPI Acm_GmSavePointF(IN HAND GMSHandle, IN PI8 FilePath);
//U32 ADVCMNAPI Acm_GmResetPointF(IN HAND GMSHandle);
U32 ADVCMNAPI Acm_GpMoveHelixRel_Angle(HAND GroupHandle,
PF64 CenterArray,
PF64 EndArray,
PU32 pArrayElements,
I16 Direction);//added by zhaocui 201305
U32 ADVCMNAPI Acm_GpMoveHelixAbs_Angle(HAND GroupHandle,
PF64 CenterArray,
PF64 EndArray,
PU32 pArrayElements,
I16 Direction);//added by zhaocui 201305
U32 ADVCMNAPI Acm_AxSetPWMTableOnTime(HAND AxisHandle, PU32 TimeTableArray, I32 ArrayCount);//zhaocui add
U32 ADVCMNAPI Acm_AxGetINxStopStatus(HAND AxisHandle,PU32 Stop_Flag);// [2/28/2014 deng]
U32 ADVCMNAPI Acm_AxResetINxStopStatus(HAND AxisHandle);// [2/28/2014 deng]
U32 ADVCMNAPI Acm_GpGetINxStopStatus(HAND GroupHandle,PU32 Stop_Flag);// [2/28/2014 deng]
U32 ADVCMNAPI Acm_GpResetINxStopStatus(HAND GroupHandle);// [2/28/2014 deng]
U32 ADVCMNAPI Acm_AxJog(HAND AxisHandle,U16 Direction); //[5/22/2014 kai.yang]
U32 ADVCMNAPI Acm_AxSetCmpDO(HAND AxisHandle,U32 OFForON);// [12/3/2014 deng]
U32 ADVCMNAPI Acm_AxDownloadTorqueTable (HAND AxisHandle, PF64 pPositionArray, PF64 pTorqueArray, U32 ArrayElements); //[8/6/2015 andy.wang]
U32 ADVCMNAPI Acm_AxLoadTorqueTableFile(HAND AxisHandle, PI8 FilePath, PU32 PointsCount); //[8/6/2015 andy.wang]
U32 ADVCMNAPI Acm_AxResetPVTTable(HAND AxisHandle);
U32 ADVCMNAPI Acm_AxLoadPVTTable(HAND AxisHandle, U16 Num, PF64 Pos, PF64 Vel, PF64 Time);
U32 ADVCMNAPI Acm_AxStartPVT(HAND AxisHandle, U16 rNum);
U32 ADVCMNAPI Acm_AxCheckPTBuffer(HAND AxisHandle,U16* remainblock);
U32 ADVCMNAPI Acm_AxAddPTData(HAND AxisHandle, F64 Pos, F64 time);
U32 ADVCMNAPI Acm_AxStartPT(HAND AxisHandle, U8 BfMode, U16 rNum);
U32 ADVCMNAPI Acm_AxResetPTData(HAND AxisHandle);
U32 ADVCMNAPI Acm_AxAddPVAData(HAND AxisHandle, F64 Position, PF64 VelArray, PF64 AccArray, PF64 DecArray, U32 ArrayElements);
//zhao cui add for robot 201307
U32 ADVCMNAPI Acm_RbGetActualPosition(HAND RbHandle, PF64 PositionArray, U32 ArrayElement);
U32 ADVCMNAPI Acm_RbGetCmdPosition(HAND RbHandle, PF64 PositionArray, U32 ArrayElement);
U32 ADVCMNAPI Acm_RbGetArmActualPosition(HAND RbHandle, U16 ArmID, PF64 CurPosi);
U32 ADVCMNAPI Acm_RbGetArmCmdPosition(HAND RbHandle, U16 ArmID, PF64 CurPosi);
U32 ADVCMNAPI Acm_RbOpen (HAND DeviceHandle,PHAND RbHandle);
U32 ADVCMNAPI Acm_RbClose (PHAND pRbHandle);
U32 ADVCMNAPI Acm_RbResetError (HAND RbHandle);
U32 ADVCMNAPI Acm_RbGetState (HAND RbHandle, PU16 PStates);
U32 ADVCMNAPI Acm_RbSetActPosition (HAND RbHandle, PF64 PositionArray, U32 ArrayElement);
U32 ADVCMNAPI Acm_RbMoveRel(HAND RbHandle, PF64 PosArray, PU32 ArrayElement);
U32 ADVCMNAPI Acm_RbMoveAbs(HAND RbHandle, PF64 PosArray, PU32 ArrayElement);
U32 ADVCMNAPI Acm_RbMoveDirectRel (HAND RbHandle, PF64 PositionArray, PU32 ArrayElements);
U32 ADVCMNAPI Acm_RbMoveDirectAbs (HAND RbHandle, PF64 PositionArray, PU32 ArrayElements);
U32 ADVCMNAPI Acm_RbMoveLinearRel( HAND RbHandle,PF64 PositionArray,PU32 pArrayElements);
U32 ADVCMNAPI Acm_RbMoveLinearAbs( HAND RbHandle,PF64 PositionArray,PU32 pArrayElements);
U32 ADVCMNAPI Acm_RbMoveArcAbs( HAND RbHandle,PF64 CenterArray,PF64 EndArray,PU32 pArrayElements, I16 Direction);
U32 ADVCMNAPI Acm_RbMoveArcRel( HAND RbHandle,PF64 CenterArray,PF64 EndArray,PU32 pArrayElements, I16 Direction);
U32 ADVCMNAPI Acm_RbMoveArcRel_3P ( HAND RbHandle,PF64 RefArray,PF64 EndArray,PU32 pArrayElements, I16 Direction);
U32 ADVCMNAPI Acm_RbMoveArcAbs_3P ( HAND RbHandle,PF64 RefArray,PF64 EndArray,PU32 pArrayElements, I16 Direction);
U32 ADVCMNAPI Acm_RbAddPath (HAND RbHandle,U16 MoveCmd,U16 MoveMode,F64 FH,F64 FL,
PF64 EndPoint_DataArray,PF64 CenPoint_DataArray,PU32 ArrayElements);
U32 ADVCMNAPI Acm_RbResetPath (PHAND RbHandle);
U32 ADVCMNAPI Acm_RbGetPathStatus (HAND RbHandle, // IN, Group Handle
PU32 pCurIndex, // IN, OUT, Current index of path data in path buffer
PU32 pCurCmdFunc, // IN, OUT, Return current command function in executing
PU32 pRemainCount, // IN, OUT, Number of unexecuted path data in path
PU32 pFreeSpaceCount );
U32 ADVCMNAPI Acm_RbMovePath(HAND RbHandle, HAND PathHandle);
U32 ADVCMNAPI Acm_RbChangeVel(HAND RbHandle, F64 NewVelocity);
U32 ADVCMNAPI Acm_RbChangeVelByRate(HAND RbHandle, U32 Rate);
U32 ADVCMNAPI Acm_RbGetCmdVel(HAND RbHandle, PF64 CmdVel);
U32 ADVCMNAPI Acm_RbStopDec ( HAND RbHandle);
U32 ADVCMNAPI Acm_RbStopEmg(HAND RbHandle);
U32 ADVCMNAPI Acm_RbPauseMotion(HAND RbHandle);
U32 ADVCMNAPI Acm_RbResumeMotion(HAND RbHandle);
bool IsGMSHandleValid(HAND GMSHandle);
U32 ADVCMNAPI Acm_RbLoadPath(HAND RbHandle, PI8 FilePath, PHAND PathHandle, PU32 pTotalCount);// [6/26/2014 deng]
U32 ADVCMNAPI Acm_RbUnloadPath(HAND RbHandle, PHAND PathHandle);// [6/26/2014 deng]
U32 ADVCMNAPI Acm_RbMoveSelPath(HAND RbHandle,
HAND PathHandle,
U32 StartIndex, // range: 0~9999
U32 EndIndex, // range: 0~9999
U8 Repeat);// [6/26/2014 deng]
U32 ADVCMNAPI Acm_RbGetPathIndexStatus(HAND RbHandle,
U32 Index, // index of path
PU16 CmdFunc,
PU16 MoveMode,
PF64 FH,
PF64 FL,
PF64 EndPoint_DataArray,
PF64 CenPoint_DataArray,
PU32 ArrayElements);// [6/26/2014 deng]
U32 ADVCMNAPI Acm_RbSetExtDrive(HAND RbHandle, U16 ExtDrvMode);// [7/3/2014 deng]
U32 ADVCMNAPI Acm_RbJog(HAND RbHandle,U16 Direction);// [7/3/2014 deng]
U32 ADVCMNAPI Acm_ServoSetCom(U32 ComPortID, U32 Baudrate, U32 Timeout);// [7/17/2014 yang.kai]
U32 ADVCMNAPI Acm_ServoGetAbsPosition(
U32 ComPortID,
U32 ServoType,
U32 ServoID,
U32 ServoAbsResolution,
U32 ServoCmdResolution,
U32 EncoderDir,
PF64 AbsPosition
); // [7/17/2014 yang.kai]
U32 ADVCMNAPI Acm_AxSetCmdPosi_Pulse(HAND AxisHandle,F64 Position); // [7/17/2014 yang.kai]
U32 ADVCMNAPI Acm_AxMoveAbs_EC(HAND AxisHandle, F64 Position);// [8/18/2014 deng]
U32 ADVCMNAPI Acm_RbGetWorldPosFromJoint(HAND RbHandle,PF64 JointPosArray, PF64 WorldPosArray); // [8/12/2014 yang.kai]
U32 ADVCMNAPI Acm_GetDevNum(U32 DevType,U32 BoardID,PU32 DeviceNumber); // [9/2/2014 yang.kai]
U32 ADVCMNAPI Acm_GpMoveArcRel_Angle(HAND GroupHandle, // [9/22/2014 yang.kai]
PF64 CenterArray,
F64 Degree,
PU32 ArrayElements,
I16 Direction);
U32 ADVCMNAPI Acm_GpMoveArcAbs_Angle(HAND GroupHandle, // [9/22/2014 yang.kai]
PF64 CenterArray,
F64 Degree,
PU32 ArrayElements,
I16 Direction);
U32 ADVCMNAPI Acm_AxChangeCmpIndex(HAND AxisHandle, // [9/22/2014 yang.kai]
U32 CmpIndex);
//mapping
U32 ADVCMNAPI Acm_DevSaveMapFile(HAND DeviceHandle, PI8 FilePath);
U32 ADVCMNAPI Acm_DevLoadMapFile(HAND DeviceHandle, PI8 FilePath);
U32 ADVCMNAPI Acm_DevUpLoadMapInfo(HAND DeviceHandle, U16 MapType, PDEV_IO_MAP_INFO MapInfoArray, PU32 ArrayLength);
U32 ADVCMNAPI Acm_DevDownLoadMapInfo(HAND DeviceHandle, U16 MapType, PDEV_IO_MAP_INFO MapInfoArray, U32 ArrayLength);
//SDO
U32 ADVCMNAPI Acm_DevWriteSDOData(HAND DeviceHandle, IN U16 RingNo, IN U16 SlaveIP, IN U16 Index, IN U16 SubIndex, IN U16 Type, IN U16 DataSize, IN VOID *pValue);
U32 ADVCMNAPI Acm_DevReadSDOData(HAND DeviceHandle, IN U16 RingNo, IN U16 SlaveIP, IN U16 Index, IN U16 SubIndex, IN U16 Type, IN U16 DataSize, OUT VOID *pValue);
//ARES
U32 ADVCMNAPI Acm_DevDownloadAres(HAND DeviceHandle, PI8 FilePath);
U32 ADVCMNAPI Acm_DevGetAresVariable(HAND DeviceHandle, U32 Address, PF64 Value);
U32 ADVCMNAPI Acm_DevSetAresVariable(HAND DeviceHandle, U32 Address, F64 Value);
U32 ADVCMNAPI Acm_DevGetDownloadedAresName(HAND DeviceHandle, PDEV_ARES_INFO FileName, PU32 Count);
U32 ADVCMNAPI Acm_DevDeleteAresFile(HAND DeviceHandle, PI8 FileName);
U32 ADVCMNAPI Acm_DevClearAresFile(HAND DeviceHandle);
U32 ADVCMNAPI Acm_GpGetRunningAresName(HAND GroupHandle, PI8 FileName);
U32 ADVCMNAPI Acm_GpGetAresState(HAND GroupHandle, PU16 pState);
U32 ADVCMNAPI Acm_GpLoadAresProgram(HAND GroupHandle, PI8 FileName);
U32 ADVCMNAPI Acm_GpRunAres(HAND GroupHandle);
U32 ADVCMNAPI Acm_GpHoldAres(HAND GroupHandle);
U32 ADVCMNAPI Acm_GpStopAres(HAND GroupHandle);
U32 ADVCMNAPI Acm_GpGetAresCrc(HAND GroupHandle, PU32 Crc);
U32 ADVCMNAPI Acm_GpStepAres(HAND GroupHandle, U32 Offset);
U32 ADVCMNAPI Acm_GpSetAresBreakPoint(HAND GroupHandle, U32 Offset);
U32 ADVCMNAPI Acm_GpRemoveAresBreakPoint(HAND GroupHandle, U32 Offset);
U32 ADVCMNAPI Acm_GpClearAresBreakPoints(HAND GroupHandle);
U32 ADVCMNAPI Acm_GpGetAresBreakPoints(HAND GroupHandle, PU32 Breakpoints, PU32 Count);
U32 ADVCMNAPI Acm_GpGetAresNextOffset(HAND GroupHandle, PU32 Offset);
#ifdef __cplusplus
}
#endif

@ -0,0 +1,95 @@
//
// Copyright (c) Advantech Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Advantech end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
#ifndef __ADV_MOT_DEV_H__
#define __ADV_MOT_DEV_H__
/*
+-----------------------------------------------------------------------------+
| ************ Advantech Motion Master Device Type ID************************ |
+-----------------------------------------------------------------------------+
*/
#define Adv_UNKNOWN 0xff
// ADAM Motion Series
#define Adv_ADAM_MOTION 0x0
#define Adv_ADAM5202 (Adv_ADAM_MOTION + 0)
#define Adv_ADAM5240 (Adv_ADAM_MOTION + 1)
#define Adv_APAX5202 (Adv_ADAM_MOTION + 2)
// IO Motion Series
#define Adv_IO_MOTION 0x20
#define Adv_PCI1240 (Adv_IO_MOTION + 0)
#define Adv_PCM3240 (Adv_IO_MOTION + 1)
#define Adv_PCI1202 (Adv_IO_MOTION + 2)
#define Adv_AMAX2050 (Adv_IO_MOTION + 3)
#define Adv_PCM3202 (Adv_IO_MOTION + 4)
#define Adv_PCI1220 (Adv_IO_MOTION + 5)
#define Adv_PCI1244 (Adv_IO_MOTION + 6)
#define Adv_PCI1245 (Adv_IO_MOTION + 7)
#define Adv_PCI1265 (Adv_IO_MOTION + 8)
#define Adv_PCI1245E (Adv_IO_MOTION + 9)
#define Adv_PCI1285 (Adv_IO_MOTION + 0xa)
#define Adv_PCI1285E (Adv_IO_MOTION + 0xb)
#define Adv_PCI1245V (Adv_IO_MOTION + 0xc)
#define Adv_PCI1245L (Adv_IO_MOTION + 0xd)
#define Adv_PCI1245S (Adv_IO_MOTION + 0xe)
#define Adv_PCI1285V (Adv_IO_MOTION + 0xf)
#define Adv_MIC3285 (Adv_IO_MOTION + 0x10)
#define Adv_MIC3245 (Adv_IO_MOTION + 0x11)
#define Adv_PCI1245HP (Adv_IO_MOTION + 0x12) //YDD 2015.6.1
#define Adv_PCI1245LIO (Adv_IO_MOTION + 0x13) //YDD 2015.6.1
//YDD 2015.9.29
#define Adv_MOTION_MVP 0xD0
#define Adv_MVP3245 (Adv_MOTION_MVP + 0x01)
#define Adv_MVP3245P (Adv_MOTION_MVP + 0x02)
#define Adv_IO_MOTION_EX 0x80 //Custom
#define Adv_PCI1285HT (Adv_IO_MOTION_EX + 0x0)
#define AdV_VIRTUAL_DIO_CARD 0x90 //VIRTUAL DIO CARD
#define AdV_V_PCI1750 (AdV_VIRTUAL_DIO_CARD + 0)
#define Adv_VirtualMotionCard (0xA0)
#define Adv_V_PCI1245 (Adv_VirtualMotionCard + Adv_PCI1245 -Adv_IO_MOTION)
#define Adv_V_PCI1245E (Adv_VirtualMotionCard + Adv_PCI1245E-Adv_IO_MOTION)
#define Adv_V_PCI1245V (Adv_VirtualMotionCard + Adv_PCI1245V-Adv_IO_MOTION)
#define Adv_V_PCI1245S (Adv_VirtualMotionCard + Adv_PCI1245S-Adv_IO_MOTION)
#define Adv_V_PCI1245L (Adv_VirtualMotionCard + Adv_PCI1245L-Adv_IO_MOTION)
#define Adv_V_PCI1265 (Adv_VirtualMotionCard + Adv_PCI1265 -Adv_IO_MOTION)
#define Adv_V_PCI1285 (Adv_VirtualMotionCard + Adv_PCI1285 -Adv_IO_MOTION)
#define Adv_V_PCI1285E (Adv_VirtualMotionCard + Adv_PCI1285E-Adv_IO_MOTION)
#define Adv_V_PCI1285V (Adv_VirtualMotionCard + Adv_PCI1285V-Adv_IO_MOTION)
#define Adv_V_PCI1203 (Adv_VirtualMotionCard + Adv_PCI1203-Adv_IO_MOTION)
//IO Slave Series
#define Adv_AMAX_SLAVE 0x40
#define Adv_AMAX2210 (Adv_AMAX_SLAVE + 0)
#define Adv_AMAX2240 (Adv_AMAX_SLAVE + 1)
#define Adv_AMAX2710 (Adv_AMAX_SLAVE + 2)
#define Adv_AMAX2754 (Adv_AMAX_SLAVE + 3)
#define Adv_AMAX2730 (Adv_AMAX_SLAVE + 4)
#define Adv_AMAX2756 (Adv_AMAX_SLAVE + 5)
#define Adv_AMAX2752 (Adv_AMAX_SLAVE + 6)
//EtherCAT
#define Adv_EtherCAT 0x60
#define Adv_ADAM5000 (Adv_EtherCAT + 1)
#define Adv_PCI1203 (Adv_EtherCAT + 2)
#endif // __ADV_MOT_DEV_H__

File diff suppressed because it is too large Load Diff

@ -0,0 +1,760 @@
//
// Copyright (c) Advantech Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Advantech end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
#ifndef __ADV_MOT_ERR_H__
#define __ADV_MOT_ERR_H__
#ifndef SUCCESS
#define SUCCESS 0x00000000
#endif
#define Warning 0x10000000
#define FuncError 0x80000000
#define CommError 0x80001000
#define MotionError 0x80002000
#define DaqError 0x80003000
#define DevEvtError 0x80004000
#define DspError 0x80005000 // [9/26/2011 dan.yang]
#define DspAxError 0x80005100 // [9/26/2011 dan.yang]
#define DspGpError 0x80005200 // [9/26/2011 dan.yang]
#define DspRbError 0x80005500
#define GmError 0x81000000 //by dujunling on 2012.11.22 for GM code error
#define ECTError 0x83000000 // [9/22/2014 dan]: Add for EtherCAT
#define ECTDevError 0x83010000 // [3/24/2015 Andy] : EtherCAT master & slave error
#define ECTDevSDOError 0x83020000 //Error from SDO communication 0x8301 XXXX
#define ECTMotionError 0x83030000 //Error from Motion port communication
#define ECTIOError 0x83040000 //Error from IO port communication
#define ECTAxError 0x83050000 //Error from CiA402 ecat driver
#define ECAT_DriveError 0x83100000 // [3/24/2015 Andy] : EtherCAT Drive error
#define InvalidDevNumber (FuncError + 0)
#define DevRegDataLost (FuncError + 1)
#define LoadDllFailed (FuncError + 2)
#define GetProcAddrFailed (FuncError + 3)
#define MemAllocateFailed (FuncError + 4)
#define InvalidHandle (FuncError + 5)
#define CreateFileFailed (FuncError + 6)
#define OpenEventFailed (FuncError + 7)
#define EventTimeOut (FuncError + 8)
#define InvalidInputParam (FuncError + 9)
#define PropertyIDNotSupport (FuncError + 10)
#define PropertyIDReadOnly (FuncError + 11)
#define ConnectWinIrqFailed (FuncError + 12)
#define InvalidAxCfgVel (FuncError + 13)
#define InvalidAxCfgAcc (FuncError + 14)
#define InvalidAxCfgDec (FuncError + 15)
#define InvalidAxCfgJerk (FuncError + 16)
#define InvalidAxParVelLow (FuncError + 17)
#define InvalidAxParVelHigh (FuncError + 18)
#define InvalidAxParAcc (FuncError + 19)
#define InvalidAxParDec (FuncError + 20)
#define InvalidAxParJerk (FuncError + 21)
#define InvalidAxPulseInMode (FuncError + 22)
#define InvalidAxPulseOutMode (FuncError + 23)
#define InvalidAxAlarmEn (FuncError + 24)
#define InvalidAxAlarmLogic (FuncError + 25)
#define InvalidAxInPEn (FuncError + 26)
#define InvalidAxInPLogic (FuncError + 27)
#define InvalidAxHLmtEn (FuncError + 28)
#define InvalidAxHLmtLogic (FuncError + 29)
#define InvalidAxHLmtReact (FuncError + 30)
#define InvalidAxSLmtPEn (FuncError + 31)
#define InvalidAxSLmtPReact (FuncError + 32)
#define InvalidAxSLmtPValue (FuncError + 33)
#define InvalidAxSLmtMEn (FuncError + 34)
#define InvalidAxSLmtMReact (FuncError + 35)
#define InvalidAxSLmtMValue (FuncError + 36)
#define InvalidAxOrgLogic (FuncError + 37)
#define InvalidAxOrgEnable (FuncError + 38)
#define InvalidAxEzLogic (FuncError + 39)
#define InvalidAxEzEnable (FuncError + 40)
#define InvalidAxEzCount (FuncError + 41)
#define InvalidAxState (FuncError + 42)
#define InvalidAxInEnable (FuncError + 43)
#define InvalidAxSvOnOff (FuncError + 44)
#define InvalidAxDistance (FuncError + 45)
#define InvalidAxPosition (FuncError + 46)
#define InvalidAxHomeModeKw (FuncError + 47)
#define InvalidAxCntInGp (FuncError + 48)
#define AxInGpNotFound (FuncError + 49)
#define AxIsInOtherGp (FuncError + 50)
#define AxCannotIntoGp (FuncError + 51)
#define GpInDevNotFound (FuncError + 52)
#define InvalidGpCfgVel (FuncError + 53)
#define InvalidGpCfgAcc (FuncError + 54)
#define InvalidGpCfgDec (FuncError + 55)
#define InvalidGpCfgJerk (FuncError + 56)
#define InvalidGpParVelLow (FuncError + 57)
#define InvalidGpParVelHigh (FuncError + 58)
#define InvalidGpParAcc (FuncError + 59)
#define InvalidGpParDec (FuncError + 60)
#define InvalidGpParJerk (FuncError + 61)
#define JerkNotSupport (FuncError + 62)
#define ThreeAxNotSupport (FuncError + 63)
#define DevIpoNotFinished (FuncError + 64)
#define InvalidGpState (FuncError + 65)
#define OpenFileFailed (FuncError + 66)
#define InvalidPathCnt (FuncError + 67)
#define InvalidPathHandle (FuncError + 68)
#define InvalidPath (FuncError + 69)
#define IoctlError (FuncError + 70)
#define AmnetRingUsed (FuncError + 71)
#define DeviceNotOpened (FuncError + 72)
#define InvalidRing (FuncError + 73)
#define InvalidSlaveIP (FuncError + 74)
#define InvalidParameter (FuncError + 75)
#define InvalidGpCenterPosition (FuncError + 76)
#define InvalidGpEndPosition (FuncError + 77)
#define InvalidAddress (FuncError + 78)
#define DeviceDisconnect (FuncError + 79)
#define DataOutBufExceeded (FuncError + 80)
#define SlaveDeviceNotMatch (FuncError + 81)
#define SlaveDeviceError (FuncError + 82)
#define SlaveDeviceUnknow (FuncError + 83)
#define FunctionNotSupport (FuncError + 84)
#define InvalidPhysicalAxis (FuncError + 85) //[Dean 2008.1.31]
#define InvalidVelocity (FuncError + 86) //[Dean 2008.2.5]
#define InvalidAxPulseInLogic (FuncError + 87) //[Dean 2008.2.13]
#define InvalidAxPulseInSource (FuncError + 88) //[Dean 2008.2.13]
#define InvalidAxErcLogic (FuncError + 89) //[Dean 2008.2.13]
#define InvalidAxErcOnTime (FuncError + 90) //[Dean 2008.2.13]
#define InvalidAxErcOffTime (FuncError + 91) //[Dean 2008.2.13]
#define InvalidAxErcEnableMode (FuncError + 92) //[Dean 2008.2.13]
#define InvalidAxSdEnable (FuncError + 93) //[Dean 2008.2.13]
#define InvalidAxSdLogic (FuncError + 94) //[Dean 2008.2.13]
#define InvalidAxSdReact (FuncError + 95) //[Dean 2008.2.13]
#define InvalidAxSdLatch (FuncError + 96) //[Dean 2008.2.13]
#define InvalidAxHomeResetEnable (FuncError + 97) //[Dean 2008.2.13]
#define InvalidAxBacklashEnable (FuncError + 98) //[Dean 2008.2.13]
#define InvalidAxBacklashPulses (FuncError + 99) //[Dean 2008.2.13]
#define InvalidAxVibrationEnable (FuncError + 100) //[Dean 2008.2.13]
#define InvalidAxVibrationRevTime (FuncError + 101) //[Dean 2008.2.13]
#define InvalidAxVibrationFwdTime (FuncError + 102) //[Dean 2008.2.13]
#define InvalidAxAlarmReact (FuncError + 103) //[Dean 2008.2.13]
#define InvalidAxLatchLogic (FuncError + 104) //[Dean 2008.2.13]
#define InvalidFwMemoryMode (FuncError + 105)
#define InvalidConfigFile (FuncError + 106)
#define InvalidAxEnEvtArraySize (FuncError + 107)
#define InvalidAxEnEvtArray (FuncError + 108)
#define InvalidGpEnEvtArraySize (FuncError + 109)
#define InvalidGpEnEvtArray (FuncError + 110)
#define InvalidIntervalData (FuncError + 111)
#define InvalidEndPosition (FuncError + 112)
#define InvalidAxisSelect (FuncError + 113)
#define InvalidTableSize (FuncError + 114)
#define InvalidGpHandle (FuncError + 115)
#define InvalidCmpSource (FuncError + 116)
#define InvalidCmpMethod (FuncError + 117)
#define InvalidCmpPulseMode (FuncError + 118)
#define InvalidCmpPulseLogic (FuncError + 119)
#define InvalidCmpPulseWidth (FuncError + 120)
#define InvalidPathFunctionID (FuncError + 121)
#define SysBufAllocateFailed (FuncError + 122)
#define SpeedFordFunNotSpported (FuncError + 123)
#define InvalidNormVector (FuncError + 124)//zhaocui add
#define InvalidCmpTimeTableCount (FuncError + 125)
#define InvalidCmpTime (FuncError + 126)
#define FWDownLoading (FuncError + 127)//zhaocui add 20131209
#define FWVersionNotMatch (FuncError + 128)//zhaocui add 20131209
#define InvalidAxParHomeVelLow (FuncError + 129)//yangkai add 20140707
#define InvalidAxParHomeVelHigh (FuncError + 130)//yangkai add 20140707
#define InvalidAxParHomeAcc (FuncError + 131)//yangkai add 20140707
#define InvalidAxParHomeDec (FuncError + 132)//yangkai add 20140707
#define InvalidAxParHomeJerk (FuncError + 133)//yangkai add 20140707
#define InvalidAxCfgJogVelLow (FuncError + 134)//yangkai add 20140707
#define InvalidAxCfgJogVelHigh (FuncError + 135)//yangkai add 20140707
#define InvalidAxCfgJogAcc (FuncError + 136)//yangkai add 20140707
#define InvalidAxCfgJogDec (FuncError + 137)//yangkai add 20140707
#define InvalidAxCfgJogJerk (FuncError + 138)//yangkai add 20140707
#define InvalidAxCfgKillDec (FuncError + 139)//yangkai add 20140707
#define NotOpenAllAxes (FuncError + 140)//yangkai add 20140707
#define NotSetServoComPort (FuncError + 141)//yangkai add 20140707
#define OpenComPortFailed (FuncError + 142)//yangkai add 20140707
#define ReadComPortTimeOut (FuncError + 143)//yangkai add 20140707
#define SetComPortStateFailed (FuncError + 144)//yangkai add 20140707
#define SevroTypeNotSupport (FuncError + 145)//yangkai add 20140707
#define ReadComBufFailed (FuncError + 146)//yangkai add 20140707
#define InvalidAxMaxErrorCnt (FuncError + 147)//yangkai add 20141015
#define MoveModeNosupportBlend (FuncError + 148)
#define CmpModeCannotGenDO (FuncError + 149)
//AMONet Communication error
#define SlaveIOUpdateError (FuncError + 150)
#define NoSlaveDevFound (FuncError + 151)
#define MasterDevNotOpen (FuncError + 152)
#define MasterRingNotOpen (FuncError + 153)
#define CannotFindCenterby3P (FuncError + 154)
#define InvalidAxCfgJogPAssign (FuncError + 155)//andy.wang add 20150508
#define InvalidAxCfgJogNAssign (FuncError + 156)//andy.wang add 20150508
#define InvalidAxCfgCamDOAssign (FuncError + 157)//andy.wang add 20150508
#define InvalidAxCfgDIStopAssign (FuncError + 158)//andy.wang add 20150512
//DAQ function [1/24/2008 Dean] -----------------------------------
#define InvalidDIPort (FuncError + 200)
#define InvalidDOPort (FuncError + 201)
#define InvalidDOValue (FuncError + 202)
//EVT function
#define CreateEventFailed (FuncError + 203)
#define CreateThreadFailed (FuncError + 204)
#define InvalidHomeModeEx (FuncError + 205)
#define InvalidDirMode (FuncError + 206)
#define AxHomeMotionFailed (FuncError + 207)
#define ReadFileFailed (FuncError + 208)
#define PathBufIsFull (FuncError + 209)
#define PathBufIsEmpty (FuncError + 210)
#define GetAuthorityFailed (FuncError + 211) // [3/17/2011 dan.yang]
#define GpIDAllocatedFailed (FuncError + 212) // [04/15/2011 dan.yang]
#define FirmWareDown (FuncError + 213) // [4/26/2011 dan.yang] todo
#define InvalidGpRadius (FuncError + 214) // [4/28/2011 dan.yang]
#define InvalidAxCmd (FuncError + 215) // [4/28/2011 dan.yang]
#define InvalidaxExtDrv (FuncError + 216) // [4/29/2011 dan.yang]
#define InvalidGpMovCmd (FuncError + 217) // [5/4/2011 dan.yang]
#define SpeedCurveNotSupported (FuncError + 218) // [5/20/2011 dan.yang]
#define InvalidCounterNo (FuncError + 219) // [5/24/2011 dan.yang]
#define InvalidPathMoveMode (FuncError + 220) // [6/2/2011 dan.yang]
#define PathSelStartCantRunInSpeedForwareMode (FuncError + 221) // [6/21/2011 dan.yang]
#define InvalidCamTableID (FuncError + 222) // [6/23/2011 dan.yang]
#define InvalidCamPointRange (FuncError + 223) // [6/23/2011 dan.yang]
#define CamTableIsEmpty (FuncError + 224) // [6/23/2011 dan.yang]
#define InvalidPlaneVector (FuncError + 225) // [6/24/2011 dan.yang]
#define MasAxIDSameSlvAxID (FuncError + 226) // [6/24/2011 dan.yang]
#define InvalidGpRefPlane (FuncError + 227) // [7/4/2011 dan.yang]
#define InvalidAxModuleRange (FuncError + 228) // [7/8/2011 dan.yang]
#define DownloadFileFailed (FuncError + 229) // [7/12/2011 dan.yang]
#define InvalidFileLength (FuncError + 230) // [7/12/2011 dan.yang]
#define InvalidCmpCnt (FuncError + 231) // [8/10/2011 dan.yang]
#define JerkExceededMaxValue (FuncError + 232) // [12/9/2011 dan.yang]
#define AbsMotionNotSupport (FuncError + 233) // [1/17/2012 dan.yang]
#define invalidAiRange (FuncError + 234) // [4/18/2012 dan.yang]
#define AIScaleFailed (FuncError + 235) // [4/18/2012 dan.yang]
#define AxInRobot (FuncError + 236) // [7/31/2013 zhaocui]
#define Invalid3DArcFlat (FuncError + 237) // [7/31/2013 zhaocui]
#define InvalidIpoMap (FuncError + 238)
#define DataSizeNotCorrect (FuncError + 239) // [10/28/2013 dan.yang]
#define AxisNotFound (FuncError + 240) // [10/30/2013 dan.yang]
#define InvalidPathVelHigh (FuncError + 241) // [12/10/2013 dan.yang]
#define InvalidRbParVelLow (FuncError + 250) // [8/5/2014 kai.yang]
#define InvalidRbParVelHigh (FuncError + 251) // [8/5/2014 kai.yang]
#define InvalidRbParAcc (FuncError + 252) // [8/5/2014 kai.yang]
#define InvalidRbParDec (FuncError + 253) // [8/5/2014 kai.yang]
#define InvalidRbParJerk (FuncError + 254) // [8/5/2014 kai.yang]
#define InvalidRbState (FuncError + 255) // [8/5/2014 kai.yang]
#define InvalidRbHandle (FuncError + 256) // [8/5/2014 kai.yang]
#define InvalidRbRadius (FuncError + 257) // [8/5/2014 kai.yang]
#define InvalidRbMovCmd (FuncError + 258) // [8/5/2014 kai.yang]
#define NotOpenRobot (FuncError + 259) // [8/5/2014 kai.yang]
#define InvalidRbPoint (FuncError + 260)//yangkai add 20150128
#define RbAngleExceeded (FuncError + 261)//yangkai add 20150128
#define GetDIOFalied (FuncError + 300) // [11/16/2014 dan]
#define InvalidRingBufferCmd (FuncError + 301) // [12/10/2014 dan]
#define InvalidAoRange (FuncError + 302) // [12/17/2014 dan]
#define RingBufferOverFlow (FuncError + 303) // [12/18/2014 dan]
#define RbAreaExceeded (FuncError + 304)
#define InvalidAiValue (FuncError + 305)
#define InvalidAoValue (FuncError + 306)
#define NoPreScanData (FuncError + 307) // [2/17/2016 dandan.yang]
#define GroupNotAssigned (FuncError + 308) // [2/17/2016 dandan.yang]
#define HLmtPExceeded (MotionError + 0)
#define HLmtNExceeded (MotionError + 1)
#define SLmtPExceeded (MotionError + 2)
#define SLmtNExceeded (MotionError + 3)
#define AlarmHappened (MotionError + 4)
#define EmgHappened (MotionError + 5)
#define TimeLmtExceeded (MotionError + 6)
#define DistLmtExceeded (MotionError + 7)
#define InvalidPositionOverride (MotionError + 8) //[Dean 2008.2.18]
#define OperationErrorHappened (MotionError + 9)
#define SimultaneousStopHappened (MotionError + 10)
#define OverflowInPAPB (MotionError + 11)
#define OverflowInIPO (MotionError + 12)
#define STPHappened (MotionError + 13)
#define SDHappened (MotionError + 14)
#define AxisNoCmpDataLeft (MotionError + 15)
#define DevEvtTimeOut (DevEvtError + 1)
#define DevNoEvt (DevEvtError + 2)
//*************************************************************
#define Warning_AxWasInGp (Warning + 1)
//inconsistent rate of PPU setting
#define Warning_GpInconsistRate (Warning + 2)
#define Warning_GpInconsistPPU (Warning + 3)
#define Warning_GpMoveDistanceCanntBeZero (Warning + 4)
// Dsp Error // [9/26/2011 dan.yang]
// ----------------------------------------------------------------------------
#define ERR_SYS_TIME_OUT (DspError + 0x01)
#define Dsp_PropertyIDNotSupport (DspError + 0x02)
#define Dsp_PropertyIDReadOnly (DspError + 0x03)
#define Dsp_InvalidParameter (DspError + 0x04)
#define Dsp_DataOutBufExceeded (DspError + 0x05)
#define Dsp_FunctionNotSupport (DspError + 0x06)
#define Dsp_InvalidConfigFile (DspError + 0x07)
#define Dsp_InvalidIntervalData (DspError + 0x08)
#define Dsp_InvalidTableSize (DspError + 0x09)
#define Dsp_InvalidTableID (DspError + 0x0a)
#define Dsp_DataIndexExceedBufSize (DspError + 0x0b)
#define Dsp_InvalidCompareInterval (DspError + 0x0c)
#define Dsp_InvalidCompareRange (DspError + 0x0d)
#define Dsp_PropertyIDWriteOnly (DspError + 0x0e)
#define Dsp_NcError (DspError + 0x0f)
#define Dsp_CamTableIsInUse (DspError + 0x10)
#define Dsp_EraseBlockFailed (DspError + 0x11)
#define Dsp_ProgramFlashFailed (DspError + 0x12)
#define Dsp_WatchdogError (DspError + 0x13)
#define Dsp_ReadPrivateOverMaxTimes (DspError + 0x14) //[v1.0.8.4]
#define Dsp_InvalidPrivateID (DspError + 0x15) //[v1.0.8.4]
#define Dsp_DataNotReady (DspError + 0x16) //[v1.0.8.4]
#define Dsp_LastOperationNotOver (DspError + 0x17)
#define Dsp_WritePrivateTimeout (DspError + 0x18)
#define Dsp_FwIsDownloading (DspError + 0x19)
#define Dsp_FwDownloadStepError (DspError + 0x20)
#define Dsp_InvalidDiLtcChanelID (DspError + 0x21)
#define Dsp_InvalidDoCmpChanelID (DspError + 0x22)
#define Dsp_InvalidDevPptValue (DspError + 0x23)
#define Dsp_CmpCannotLinkMultiLtc (DspError + 0x24)
#define Dsp_SDIOLinkError (DspError + 0x25)
#define InvalidVerScanTable (DspError + 0x26)
#define InvalidVerEnablePos (DspError + 0x27)
#define VerMovLimitExceeded (DspError + 0x28)
#define Dsp_InvalidTableName (DspError + 0x29)
// Axis Error
// ----------------------------------------------------------------------------
#define Dsp_InvalidAxCfgVel (DspAxError + 0x01)
#define Dsp_InvalidAxCfgAcc (DspAxError + 0x02)
#define Dsp_InvalidAxCfgDec (DspAxError + 0x03)
#define Dsp_InvalidAxCfgJerk (DspAxError + 0x04)
#define Dsp_InvalidAxParVelLow (DspAxError + 0x05)
#define Dsp_InvalidAxParVelHigh (DspAxError + 0x06)
#define Dsp_InvalidAxParAcc (DspAxError + 0x07)
#define Dsp_InvalidAxParDec (DspAxError + 0x08)
#define Dsp_InvalidAxParJerk (DspAxError + 0x09)
#define Dsp_InvalidAxPptValue (DspAxError + 0x0a)
#define Dsp_InvalidAxState (DspAxError + 0x0b)
#define Dsp_InvalidAxSvOnOff (DspAxError + 0x0c)
#define Dsp_InvalidAxDistance (DspAxError + 0x0d)
#define Dsp_InvalidAxPosition (DspAxError + 0x0e)
#define Dsp_InvalidAxHomeMode (DspAxError + 0x0f)
#define Dsp_InvalidPhysicalAxis (DspAxError + 0x10)
#define Dsp_HLmtPExceeded (DspAxError + 0x11)
#define Dsp_HLmtNExceeded (DspAxError + 0x12)
#define Dsp_SLmtPExceeded (DspAxError + 0x13)
#define Dsp_SLmtNExceeded (DspAxError + 0x14)
#define Dsp_AlarmHappened (DspAxError + 0x15)
#define Dsp_EmgHappened (DspAxError + 0x16)
#define Dsp_CmdValidOnlyInConstSec (DspAxError + 0x17) // Command valid only in the constant section
#define Dsp_InvalidAxCmd (DspAxError + 0x18)
#define Dsp_InvalidAxHomeDirMode (DspAxError + 0x19)
#define Dsp_AxisMustBeModuloAxis (DspAxError + 0x1a)
#define Dsp_AxIdCantSameAsMasId (DspAxError + 0x1b)
#define Dsp_CantResetPosiOfMasAxis (DspAxError + 0x1c)
#define Dsp_InvalidAxExtDrvOperation (DspAxError + 0x1d)
#define Dsp_AxAccExceededMaxAcc (DspAxError + 0x1e)
#define Dsp_AxVelExceededMaxVel (DspAxError + 0x1f)
#define Dsp_NotEnoughPulseForChgV (DspAxError + 0x20)
#define Dsp_NewVelMustGreaterThanVelLow (DspAxError + 0x21)
#define Dsp_InvalidAxGearMode (DspAxError + 0x22)
#define Dsp_InvalidGearRatio (DspAxError + 0x23)
#define Dsp_InvalidPWMDataCount (DspAxError + 0x24)
#define Dsp_InvalidAxPWMFreq (DspAxError + 0x25)
#define Dsp_InvalidAxPWMDuty (DspAxError + 0x26)
#define Dsp_AxGantryExceedMaxDiffValue (DspAxError + 0x27)
#define Dsp_ChanelIsDisable (DspAxError + 0x28)
#define Dsp_ChanelBufferIsFull (DspAxError + 0x29)
#define Dsp_ChanelBufferIsEmpty (DspAxError + 0x30)
#define Dsp_InvalidDoChanelID (DspAxError + 0x31)
#define Dsp_LatchHappened (DspAxError + 0x32)
#define Dsp_InvalidAxKillDec (DspAxError + 0x33)
#define Dsp_InvalidAxJogVelLow (DspAxError + 0x34)
#define Dsp_InvalidAxJogVelHigh (DspAxError + 0x35)
#define Dsp_InvalidAxJogAcc (DspAxError + 0x36)
#define Dsp_InvalidAxJogDec (DspAxError + 0x37)
#define Dsp_InvalidAxJogJerk (DspAxError + 0x38)
#define Dsp_InvalidAxHomeVelLow (DspAxError + 0x39)
#define Dsp_InvalidAxHomeVelHigh (DspAxError + 0x40)
#define Dsp_InvalidAxHomeAcc (DspAxError + 0x41)
#define Dsp_InvalidAxHomeDec (DspAxError + 0x42)
#define Dsp_InvalidAxHomeJerk (DspAxError + 0x43)
#define Dsp_PosErrorCntExceed (DspAxError + 0x44)
#define Dsp_InvalidAxCounterMax (DspAxError + 0x45) //ring counter
#define Dsp_InvalidAxOverflowMode (DspAxError + 0x46)
#define Dsp_ImposeTimeLongerPTP (DspAxError + 0x47)
#define Dsp_AxAngExceededMaxRotationAng (DspAxError + 0x48)
#define Dsp_AxAreaExceeded (DspAxError + 0x49)
#define Dsp_AxDiStopAct (DspAxError + 0x50) //dan.yang 2015.5.11 For guanghaojie
// Group Error // [9/26/2011 dan.yang]
// ----------------------------------------------------------------------------
#define Dsp_InvalidAxCntInGp (DspGpError + 0x01)
#define Dsp_AxInGpNotFound (DspGpError + 0x02)
#define Dsp_AxIsInOtherGp (DspGpError + 0x03)
#define Dsp_AxCannotIntoGp (DspGpError + 0x04)
#define Dsp_GpInDevNotFound (DspGpError + 0x05)
#define Dsp_InvalidGpCfgVel (DspGpError + 0x06)
#define Dsp_InvalidGpCfgAcc (DspGpError + 0x07)
#define Dsp_InvalidGpCfgDec (DspGpError + 0x08)
#define Dsp_InvalidGpCfgJerk (DspGpError + 0x09)
#define Dsp_InvalidGpParVelLow (DspGpError + 0x0a)
#define Dsp_InvalidGpParVelHigh (DspGpError + 0x0b)
#define Dsp_InvalidGpParAcc (DspGpError + 0x0c)
#define Dsp_InvalidGpParDec (DspGpError + 0x0d)
#define Dsp_InvalidGpParJerk (DspGpError + 0x0e)
#define Dsp_JerkNotSupport (DspGpError + 0x0f)
#define Dsp_ThreeAxNotSupport (DspGpError + 0x10)
#define Dsp_DevIpoNotFinished (DspGpError + 0x11)
#define Dsp_InvalidGpState (DspGpError + 0x12)
#define Dsp_OpenFileFailed (DspGpError + 0x13)
#define Dsp_InvalidPathCnt (DspGpError + 0x14)
#define Dsp_InvalidPathHandle (DspGpError + 0x15)
#define Dsp_InvalidPath (DspGpError + 0x16)
#define Dsp_GpSlavePositionOverMaster (DspGpError + 0x17)
#define Dsp_GpPathBufferOverflow (DspGpError + 0x19)
#define Dsp_InvalidPathFunctionID (DspGpError + 0x1a)
#define Dsp_SysBufAllocateFailed (DspGpError + 0x1b)
#define Dsp_InvalidGpCenterPosition (DspGpError + 0x1c)
#define Dsp_InvalidGpEndPosition (DspGpError + 0x1d)
#define Dsp_InvalidGpCmd (DspGpError + 0x1e)
#define Dsp_AxHasBeenInInGp (DspGpError + 0x1f)
#define Dsp_InvalidPathRange (DspGpError + 0x20)
#define Dsp_InvalidNormVector (DspGpError + 0x21)
// [1/22/2014 deng]
#define Dsp_RbInvalidGpid (DspRbError + 0x01)
#define Dsp_RbInvalidMode (DspRbError + 0x01)
#define Dsp_RbInvalidArmLength (DspRbError + 0x02)
#define Dsp_RbInvalidAxesNum (DspRbError + 0x03)
#define Dsp_RbInvalidHandDir (DspRbError + 0x04)
#define Dsp_RbAreaExceeded (DspRbError + 0x05)
#define Dsp_RbAngleExceeded (DspRbError + 0x06)
#define Dsp_RbSwLmtNotEnabled (DspRbError + 0x07)
#define Dsp_RbVectorDistExceededZTargetDist (DspRbError + 0x08)
#define Dsp_RbInvalidPoint (DspRbError + 0x09)
#define Dsp_RbInvalidCurrentHandDir (DspRbError + 0x0a)
#define Dsp_RbInvalidCoordinateSystem (DspRbError + 0x0b)
#define Dsp_RbInvalidCoordinateAxis (DspRbError + 0x0c)
#define Dsp_RbSpeedTooHigh (DspRbError + 0x0d)
#define Dsp_RbInvalidState (DspRbError + 0x0e)
#define Dsp_RbEmgHappened (DspRbError + 0x0f)
#define Dsp_RbAlmHappened (DspRbError + 0x10)
#define Dsp_RbSLmtPExceeded (DspRbError + 0x11)
#define Dsp_RbSLmtNExceeded (DspRbError + 0x12)
//add by dujunling 2012.11.23
#define Gm_CodeError (GmError + 0x100)
#define Gm_SystemError (GmError + 0x200)
/////////////Gm_CodeError
#define Gm_InvalidCharacter (Gm_CodeError + 1)
#define Gm_InvalidCode (Gm_CodeError + 2)
#define Gm_InvalidGCode (Gm_CodeError + 3)
#define Gm_InvalidMCode (Gm_CodeError + 4)
#define Gm_GroupCodeAlreadyExist (Gm_CodeError + 5)
#define Gm_MissingNumber (Gm_CodeError + 6)
//
#define Gm_MissingFWord (Gm_CodeError + 7)
#define Gm_MissingSWord (Gm_CodeError + 8)
#define Gm_MissingOWord (Gm_CodeError + 9)
#define Gm_MissingNWord (Gm_CodeError + 10)
#define Gm_MissingLWord (Gm_CodeError + 11)
#define Gm_MissingPWord (Gm_CodeError + 12)
#define Gm_MissingQWord (Gm_CodeError + 13)
#define Gm_MissingRWord (Gm_CodeError + 14)
#define Gm_MissingEWord (Gm_CodeError + 15)
#define Gm_MissingHWord (Gm_CodeError + 16)
#define Gm_MissingDWord (Gm_CodeError + 17)
#define Gm_MissingTWord (Gm_CodeError + 18)
#define Gm_MissingAxisWord (Gm_CodeError + 19)
#define Gm_MissingSubAxisWord (Gm_CodeError + 20)
//
#define Gm_InvalidFValue (Gm_CodeError + 21)
#define Gm_InvalidSValue (Gm_CodeError + 22)
#define Gm_InvalidOValue (Gm_CodeError + 23)
#define Gm_InvalidNValue (Gm_CodeError + 24)
#define Gm_InvalidLValue (Gm_CodeError + 25)
#define Gm_InvalidPValue (Gm_CodeError + 26)
#define Gm_InvalidQValue (Gm_CodeError + 27)
#define Gm_InvalidRValue (Gm_CodeError + 28)
#define Gm_InvalidEValue (Gm_CodeError + 29)
#define Gm_InvalidHValue (Gm_CodeError + 31)
#define Gm_InvalidDValue (Gm_CodeError + 32)
#define Gm_InvalidTValue (Gm_CodeError + 33)
#define Gm_InvalidAxisValue (Gm_CodeError + 34)
#define Gm_InvalidSubAxisValue (Gm_CodeError + 35)
#define Gm_OverloadAxisNum (Gm_CodeError + 36)
#define Gm_InvalidAxisNumber (Gm_CodeError + 37)
#define Gm_MacroNotFound (Gm_CodeError + 38)
//////////////Gm_SystemError
#define Gm_InvalidGMSHandle (Gm_SystemError + 1)
#define Gm_InvalidThreadHandle (Gm_SystemError + 2)
#define Gm_SystemNotReady (Gm_SystemError + 3)
#define Gm_NotEnoughMemory (Gm_SystemError + 4)
#define Gm_InvalidPatternId (Gm_SystemError + 5)
#define Gm_InvalidBreakPoint (Gm_SystemError + 6)
#define Gm_InvalidMacroNumber (Gm_SystemError + 7)
#define Gm_CodeOverload (Gm_SystemError + 8)
#define Gm_MacroOverload (Gm_SystemError + 9)
#define Gm_InvalidFeedRate (Gm_SystemError + 10)
#define Gm_InvalidModuleRange (Gm_SystemError + 11)
#define Gm_RadiusCompensationAlreadyOn (Gm_SystemError + 12)
#define Gm_OverCut (Gm_SystemError + 13)
#define Gm_WrongRefPlane (Gm_SystemError + 14)
#define Gm_DllNotFound (Gm_SystemError + 15)
#define Gm_Ax_ErrorStop (Gm_SystemError + 16)
#define Gm_OverrunDwell (Gm_SystemError + 17)
#define Gm_InvalidSetCoordinate (Gm_SystemError + 18)
#define Gm_OverrunAxisNum (Gm_SystemError + 19)
#define Gm_InvalidG29 (Gm_SystemError + 20)//Updated by W.Y.Z 10-->20
#define Gm_BothOfGCodeUseAxisWords (Gm_SystemError + 21)
#define Gm_NotFoundNext (Gm_SystemError + 22)
#define Gm_ArcAxisNumError (Gm_SystemError + 23)
#define Gm_OverrunContiAxis (Gm_SystemError + 24)
#define Gm_ContiArcAxisError (Gm_SystemError + 25)
#define Gm_G272829CanNotBeConti (Gm_SystemError + 26)
#define Gm_CheckHomeFailed (Gm_SystemError + 27)
#define Gm_StackOverflow (Gm_SystemError + 28)
#define Gm_StackUnderflow (Gm_SystemError + 29)
#define Gm_InvalidAxHomeMode (Gm_SystemError + 30)
#define Gm_OverrunFilePath (Gm_SystemError + 31)
#define Gm_OverrunLineText (Gm_SystemError + 32)
#define Gm_InvalidSSTA (Gm_SystemError + 33) //Added by W.Y.Z on 2012.08.22 modify by dujunling on 2012.10.26
#define Gm_InfineLoop (Gm_SystemError + 34) //Added bydujunling on 2012.9.27 for loadjob,uploadjob,
////do error added by dujunling 2012.10.26
#define Gm_InvalidDoDevice (Gm_SystemError + 35)
#define Gm_InvalidDoChannel (Gm_SystemError + 36)
#define Gm_InvalidDoLevel (Gm_SystemError + 37)
//di
#define Gm_InvalidDiDevice (Gm_SystemError + 38)
#define Gm_InvalidDiChannel (Gm_SystemError + 39)
#define Gm_InvalidDiLevel (Gm_SystemError + 40)
//custom m code
#define Gm_RunCustomMcodeError (Gm_SystemError + 41)
#define Gm_ZeroVector (Gm_SystemError + 42)
#define Gm_LineParallel (Gm_SystemError + 43)
//
#define Gm_InvalidBufferLength (Gm_SystemError + 44)
#define GmInvalidOptionPauseParam (Gm_SystemError + 45)
#define GmInvalidOptionSkip (Gm_SystemError + 46)
#define GmWaitDiTimeOut (Gm_SystemError + 47)
#define GmCannotInvokeMacroInMacro (Gm_SystemError + 48)
#define GmThreadTimeOut (Gm_SystemError + 49)
#define Gm_InvalidDiValue (Gm_SystemError + 50)//Added by W.Y.Z on 2014.04.09
#define Gm_BeOverCutted (Gm_SystemError + 51)//Added by W.Y.Z on 2014.06.12
//for P point function by W.Y.Z on 2014.08.28
#define Gm_RadiusCompensationCannotWithG2G3 (Gm_SystemError + 52)
#define Gm_InvalidPpointID (Gm_SystemError + 53)
#define Gm_InvalidFilePath (Gm_SystemError + 54)
#define Gm_InvalidFileFormat (Gm_SystemError + 55)
#define Gm_PpointHasNotSet (Gm_SystemError + 56)
#define Gm_PpointLenNotEqualWithAxesNum (Gm_SystemError + 57)
#define Gm_PpointAndNonPCannotBeMixed (Gm_SystemError + 58)
#define Gm_StartPosCannotEqualWithEndPos (Gm_SystemError + 59)
// [3/24/2015 yang.kai]
#define Gm_InvalidBoolID (Gm_SystemError + 60)
#define Gm_BoolHasNotSet (Gm_SystemError + 61)
#define Gm_IfBlockNotCorrect (Gm_SystemError + 62)
#define Gm_IfBlockFlowError (Gm_SystemError + 63)
#define Gm_InvalidParameter (Gm_SystemError + 64)
//Error Code
#define EC_GetNICNumberFailed (ECTError + 0x0)
#define EC_GetNICInfoFailed (ECTError + 0x1)
#define EC_OpenMasterDevFailed (ECTError + 0x2)
#define EC_GetSlaveFailed (ECTError + 0x3)
#define EC_StartOpModeFailed (ECTError + 0x4)
#define EC_CloseDeviceFailed (ECTError + 0x5)
#define EC_MemAllocateFailed (ECTError + 0x6)
#define EC_InvalidNicIndex (ECTError + 0x7)
#define EC_OpenDevFailed (ECTError + 0x8)
#define EC_ReadFileFailed (ECTError + 0x9)
#define EC_GetNicInfoFailed (ECTError + 0xa)
#define EC_GetSDOFailed (ECTError + 0xb)
#define EC_InvalidParameter (ECTError + 0xc)
#define EC_GetPDOOffsetFailed (ECTError + 0xd)
#define EC_InitialMappingInfoFalied (ECTError + 0xe)
#define EC_InitResourceFailed (ECTError + 0xf)
#define EC_SetSDOFailed (ECTError + 0x10)
#define EC_InvalidPortType (ECTError + 0x11)
#define EC_SetCycleTimeFailed (ECTError + 0x12)
#define EC_InvalidAoRange (ECTError + 0x13)
#define EC_InvalidAiRange (ECTError + 0x14)
#define EC_GetSlaveInfoFaied (ECTError + 0x15)
#define EC_GetNetWorkStateFaied (ECTError + 0x16)
#define EC_RegisterEventFailed (ECTError + 0x17)
#define EC_InvalidIntegrationTime (ECTError + 0x18)
#define EC_InvalidAIEnable (ECTError + 0x19)
#define EC_InvalidDIFilter (ECTError + 0x1a)
#define EC_SetSlaveStateFailed (ECTError + 0x1b)
#define EC_ZeroCalibrationFailed (ECTError + 0x1c)
#define EC_InvalidMasterHandle (ECTError + 0x1d)
#define EC_InvalidENIFile (ECTError + 0x1e)
#define EC_InvalidCaliType (ECTError + 0x1f)
#define EC_SetCaliValueFailed (ECTError + 0x20)
#define EC_AOCalibrationFailed (ECTError + 0x21)
#define EC_InvalidIOMapping (ECTError + 0x22)
#define EC_PortIndexGreaterThanPortNum (ECTError + 0x23)
#define EC_ChannelIDGreaterThanChannelNum (ECTError + 0x24)
#define EC_InputIndexGreaterThanInputNum (ECTError + 0x25)
#define EC_OutputIndexGreaterThanOutputNum (ECTError + 0x26)
#define EC_SetEnableFailed (ECTError + 0x27)
#define EC_SetAIRangeFailed (ECTError + 0x28)
#define EC_SetIntegrationTimeFailed (ECTError + 0x29)
#define EC_PropertyNotSupported (ECTError + 0x2a)
#define EC_SlaveIDConflicted (ECTError + 0x2b)
#define EC_SpanCalibrationFailed (ECTError + 0x2c)
#define EC_InvalidAiValue (ECTError + 0x2d)
#define EC_InvalidAoValue (ECTError + 0x2e)
#define EC_GetModuleFailed (ECTError + 0x2f)
#define EC_InvalidCntEnable (ECTError + 0x30)
#define EC_InvalidCntPulseInMode (ECTError + 0x31)
#define EC_InvalidCntInitValue (ECTError + 0x32)
#define EC_InvalidCntMaxValue (ECTError + 0x33)
#define EC_InvalidCntOverflowMode (ECTError + 0x34)
#define EC_InvalidCntLatchEnable (ECTError + 0x35)
#define EC_InvalidCntLatchEdge (ECTError + 0x36)
#define EC_InvalidCntCmpEnable (ECTError + 0x37)
#define EC_InvalidCntCmpMethod (ECTError + 0x38)
#define EC_InvalidCntCmpPulseEnable (ECTError + 0x39)
#define EC_InvalidCntCmpPulseMode (ECTError + 0x3a)
#define EC_InvalidCntCmpPulseLogic (ECTError + 0x3b)
#define EC_InvalidCntCmpPulseWidth (ECTError + 0x3c)
#define EC_AxCntExceeded (ECTError + 0x3d)
#define EC_FWUpgraded (ECTError + 0x3e)
#define ECAT_MasterEcatError (ECTDevError + 0x01)
#define ECAT_SlaveDisconnect_R0 (ECTDevError + 0x02)
#define ECAT_SlaveDisconnect_R1 (ECTDevError + 0x03)
#define ECAT_AxRetryError (ECTAxError + 0x01)
#define ECAT_AxResetCounterError (ECTAxError + 0x02)
#define ECAT_AxCmdErrorProtection (ECTAxError + 0x03)
#define ECAT_AxSlaveALM (ECTAxError + 0x04)
#define ECAT_AxFollowError (ECTAxError + 0x05)
#define ECAT_AxHomeError (ECTAxError + 0x06)
#define ECAT_MOTION_MASTER_NULL (ECTMotionError + 0x01)
#define ECAT_MOTION_SCAN_BUSY (ECTMotionError + 0x02)
#define ECAT_MOTION_DOMAIN_FAILED (ECTMotionError + 0x03)
#define ECAT_MOTION_SLAVE_NOT_SUPPORT (ECTMotionError + 0x04)
#define ECAT_MOTION_SLAVE_CONFIG_FAILED (ECTMotionError + 0x05)
#define ECAT_MOTION_ACTIVE_FAILED (ECTMotionError + 0x06)
#define ECAT_MOTION_DOMAN_DATA_FAILED (ECTMotionError + 0x07)
#define ECAT_IO_MASTER_NULL (ECTIOError + 0x01)
#define ECAT_IO_SCAN_BUSY (ECTIOError + 0x02)
#define ECAT_IO_DOMAIN_FAILED (ECTIOError + 0x03)
#define ECAT_IO_SLAVE_NOT_SUPPORT (ECTIOError + 0x04)
#define ECAT_IO_SLAVE_CONFIG_FAILED (ECTIOError + 0x05)
#define ECAT_IO_ACTIVE_FAILED (ECTIOError + 0x06)
#define ECAT_IO_DOMAN_DATA_FAILED (ECTIOError + 0x07)
#define ECTAxOPERATIONMODE (ECTAxError + 0x10) //Error from CiA402 ecat driver
#define ECTAxHOMEOFFSET (ECTAxError + 0x20) //Error from CiA402 ecat driver
#define ECTAxHOMEMODE (ECTAxError + 0x30) //Error from CiA402 ecat driver
#define ECAT_HM_OPMODE_ProtocolTimeout (ECTAxOPERATIONMODE + 0x01)
#define ECAT_HM_OPMODE_ObjectNotExist (ECTAxOPERATIONMODE + 0x02)
#define ECAT_HM_OPMODE_SubindexNotExist (ECTAxOPERATIONMODE + 0x03)
#define ECAT_HM_OPMODE_ValueRangeExceeded (ECTAxOPERATIONMODE + 0x04)
#define ECAT_HM_OPMODE_WrittenTooHigh (ECTAxOPERATIONMODE + 0x05)
#define ECAT_HM_OPMODE_WrittenTooLow (ECTAxOPERATIONMODE + 0x06)
#define ECAT_HM_OPMODE_MaximumLessMinimum (ECTAxOPERATIONMODE + 0x07)
#define ECAT_HM_OPMODE_OTHER (ECTAxOPERATIONMODE + 0x08)
#define ECAT_HM_OFFSET_ProtocolTimeout (ECTAxHOMEOFFSET + 0x01)
#define ECAT_HM_OFFSET_ObjectNotExist (ECTAxHOMEOFFSET + 0x02)
#define ECAT_HM_OFFSET_SubindexNotExist (ECTAxHOMEOFFSET + 0x03)
#define ECAT_HM_OFFSET_ValueRangeExceeded (ECTAxHOMEOFFSET + 0x04)
#define ECAT_HM_OFFSET_WrittenTooHigh (ECTAxHOMEOFFSET + 0x05)
#define ECAT_HM_OFFSET_WrittenTooLow (ECTAxHOMEOFFSET + 0x06)
#define ECAT_HM_OFFSET_MaximumLessMinimum (ECTAxHOMEOFFSET + 0x07)
#define ECAT_HM_OFFSET_OTHER (ECTAxHOMEOFFSET + 0x08)
#define ECAT_HM_MODE_ProtocolTimeout (ECTAxHOMEMODE + 0x01)
#define ECAT_HM_MODE_ObjectNotExist (ECTAxHOMEMODE + 0x02)
#define ECAT_HM_MODE_SubindexNotExist (ECTAxHOMEMODE + 0x03)
#define ECAT_HM_MODE_ValueRangeExceeded (ECTAxHOMEMODE + 0x04)
#define ECAT_HM_MODE_WrittenTooHigh (ECTAxHOMEMODE + 0x05)
#define ECAT_HM_MODE_WrittenTooLow (ECTAxHOMEMODE + 0x06)
#define ECAT_HM_MODE_MaximumLessMinimum (ECTAxHOMEMODE + 0x07)
#define ECAT_HM_MODE_OTHER (ECTAxHOMEMODE + 0x08)
#define ECAT_SDO_ToggleBitNotChanged (ECTDevSDOError + 0x5300) //0x05030000,Toggle bit not changed
#define ECAT_SDO_ProtocolTimeout (ECTDevSDOError + 0x5400) //0x05040000,SDO protocol timeout
#define ECAT_SDO_CommandNotValidOrUnknown (ECTDevSDOError + 0x5401) //0x05040001,Client/Server command specifier not valid or unknown
#define ECAT_SDO_OutOfMemory (ECTDevSDOError + 0x5405) //0x05040005,Out of memory
#define ECAT_SDO_UnsupportedAccess (ECTDevSDOError + 0x6100) //0x06010000,Unsupported access to an object
#define ECAT_SDO_WriteOnlyObject (ECTDevSDOError + 0x6101) //0x06010001,Attempt to read a write-only object
#define ECAT_SDO_ReadOnlyObject (ECTDevSDOError + 0x6102) //0x06010002,Attempt to write a read-only object
#define ECAT_SDO_ObjectNotExist (ECTDevSDOError + 0x6200) //0x06020000, This object does not exist in the object directory
#define ECAT_SDO_MappedToPDOFailed (ECTDevSDOError + 0x6441) //0x06040041,The object cannot be mapped into the PDO
#define ECAT_SDO_ExceedPdoLength (ECTDevSDOError + 0x6442) //0x06040042,The number and length of the objects to be mapped would exceed the PDO length
#define ECAT_SDO_ParameterIncompatibility (ECTDevSDOError + 0x6443) //0x06040043,General parameter incompatibility reason
#define ECAT_SDO_InternalIncompatibility (ECTDevSDOError + 0x6447) //0x06040047,"General internal incompatibility in device
#define ECAT_SDO_HardwareError (ECTDevSDOError + 0x6600) //0x06060000,Access failure due to a hardware error
#define ECAT_SDO_LengthNotMatch (ECTDevSDOError + 0x6710) //0x06070010,Data type does not match, length of service parameter does not match
#define ECAT_SDO_LengthTooHigh (ECTDevSDOError + 0x6712) //0x06070012,Data type does not match, length of service parameter too high
#define ECAT_SDO_LengthTooLow (ECTDevSDOError + 0x6713) //0x06070013,Data type does not match, length of service parameter too low
#define ECAT_SDO_SubindexNotExist (ECTDevSDOError + 0x6911) //0x06090011,Subindex does not exist
#define ECAT_SDO_ValueRangeExceeded (ECTDevSDOError + 0x6930) //0x06090030,Value range of parameter exceeded
#define ECAT_SDO_WrittenTooHigh (ECTDevSDOError + 0x6931) //0x06090031,Value of parameter written too high
#define ECAT_SDO_WrittenTooLow (ECTDevSDOError + 0x6932) //0x06090032,Value of parameter written too low
#define ECAT_SDO_MaximumLessMinimum (ECTDevSDOError + 0x6936) //0x06090036,Maximum value is less than minimum value
#define ECAT_SDO_GeneralError (ECTDevSDOError + 0x8000) //0x08000000,General error
#define ECAT_SDO_ErrorStoredToApplication (ECTDevSDOError + 0x8020) //0x08000020,Data cannot be transferred or stored to the application
#define ECAT_SDO_ErrorStoredOfLocalControl (ECTDevSDOError + 0x8021) //0x08000021,Data cannot be transferred or stored to the application because of local control
#define ECAT_SDO_ErrorStoredOfPresentDeviceState (ECTDevSDOError + 0x8022) //0x08000022,Data cannot be transferred or stored to the application because of the present device state
#define ECAT_SDO_DynamicGenerationFails (ECTDevSDOError + 0x8023) //0x08000023,Object dictionary dynamic generation fails or no object
#endif // __ADV_MOT_ERR_H__

@ -0,0 +1,502 @@
//
// Copyright (c) Advantech Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Advantech end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
#ifndef __ADV_MOT_PROP_ID_H__
#define __ADV_MOT_PROP_ID_H__
/*
+-----------------------------------------------------------------------------+
| ************ Advantech Motion Property ID Definition ********************** |
+-----------------------------------------------------------------------------+
*/
///////////////////////////////////////////////////////////////////////////////
//
// Property ID Define
//
///////////////////////////////////////////////////////////////////////////////
#define FT_Dev_ID 0
#define PAR_Dev_ID 101
#define CFG_Dev_ID 201
#define FT_Ax_ID 301
#define PAR_Ax_ID 401
#define CFG_Ax_ID 501
#define FT_Gp_ID 601
#define PAR_Gp_ID 701
#define CFG_Gp_ID 801
// [9/24/2013 dan.yang]
#define PAR_RB_ID 1000
#define CFG_RB_ID 1200
#define CFG_CH_ID 1500 // [11/18/2014 dan]
///////////////////////////////////////////////////////////////////////////////
// Device Feature
///////////////////////////////////////////////////////////////////////////////
#define FT_DevIpoTypeMap (FT_Dev_ID + 0)
#define FT_DevAxesCount (FT_Dev_ID + 1)
#define FT_DevFunctionMap (FT_Dev_ID + 2)
#define FT_DevOverflowCntr (FT_Dev_ID + 3)
//Master device config
#define FT_MasCyclicCnt_R0 (FT_Dev_ID + 4)
#define FT_MasCyclicCnt_R1 (FT_Dev_ID + 5)
#define FT_DevMDAQTypeMap (FT_Dev_ID + 6)// [6/13/2012 dan.yang]
#define FT_DevMDAQTrigMap (FT_Dev_ID + 7)// [6/13/2012 dan.yang]
#define FT_DevMDAQMaxChan (FT_Dev_ID + 8)// [6/13/2012 dan.yang]
#define FT_DevMDAQMaxBufCount (FT_Dev_ID + 9)// [6/13/2012 dan.yang]
#define FT_DevLTCBufMaxCount (FT_Dev_ID + 10)
#define FT_DevVersion (FT_Dev_ID + 11) // [6/4/2013 dan.yang]
#define FT_DevEmgMap (FT_Dev_ID + 12) // [1/8/2014 deng]
#define FT_DevSupportAxesCount (FT_Dev_ID + 13) // [9/30/2015 Andy]
#define FT_AresVariableCount (FT_Dev_ID + 14) // [1/14/2016 Andy]
//DAQ function [1/24/2008 Dean]
#define FT_DaqDiMaxChan (FT_Dev_ID + 50)
#define FT_DaqDoMaxChan (FT_Dev_ID + 51)
#define FT_DaqAiRangeMap (FT_Dev_ID + 52)
#define FT_DaqAoRangeMap (FT_Dev_ID + 53)
#define FT_DaqAiMaxSingleChan (FT_Dev_ID + 54)
#define FT_DaqAiMaxDiffChan (FT_Dev_ID + 55)
#define FT_DaqAiResolution (FT_Dev_ID + 56)
#define FT_DaqAoMaxChan (FT_Dev_ID + 57)
#define FT_DaqAoResolution (FT_Dev_ID + 58)
#define FT_DaqCntMaxChan (FT_Dev_ID + 59)
///////////////////////////////////////////////////////////////////////////////
// Device Config
///////////////////////////////////////////////////////////////////////////////
#define CFG_DevBoardID (CFG_Dev_ID + 0)
#define CFG_DevRingID (CFG_Dev_ID + 1)
#define CFG_DevBaseAddress (CFG_Dev_ID + 2)
#define CFG_DevInterrupt (CFG_Dev_ID + 3)
#define CFG_DevBusNumber (CFG_Dev_ID + 4)
#define CFG_DevSlotNumber (CFG_Dev_ID + 5)
#define CFG_DevDriverVersion (CFG_Dev_ID + 6)
#define CFG_DevDllVersion (CFG_Dev_ID + 7)
#define CFG_DevComQualityContiErr (CFG_Dev_ID + 8)
#define CFG_DevComQualityErrRate (CFG_Dev_ID + 9)
#define CFG_DevComWdgMode (CFG_Dev_ID + 10)
#define CFG_DevFwMemory (CFG_Dev_ID + 11)
#define CFG_DevEmgReact (CFG_Dev_ID + 12)
#define CFG_DevFwVersion (CFG_Dev_ID + 13)
#define CFG_DevBelongsTo (CFG_Dev_ID + 14)
#define CFG_DevMasterDev (CFG_Dev_ID + 15)
#define CFG_DevSlaveDevs (CFG_Dev_ID + 16)
#define CFG_DevCPLDVersion (CFG_Dev_ID + 17)
#define CFG_DevCPLD_1Version (CFG_Dev_ID + 18)
#define CFG_DevEmgLogic (CFG_Dev_ID + 19)
#define CFG_DevLatestFwVersion (CFG_Dev_ID + 20) // [5/30/2013 dan.yang]
#define CFG_DevEmgFilterTime (CFG_Dev_ID + 21) //20140107 zhaocui add
#define CFG_DevMultiCmpAxisEnable (CFG_Dev_ID + 22) // [1/14/2014 deng]
#define CFG_DevMultiCmpOutChannel (CFG_Dev_ID + 23) // [1/14/2014 deng]
#define CFG_DevMultiCmpPulseLogic (CFG_Dev_ID + 24) // [1/14/2014 deng]
#define CFG_DevMultiCmpPulseWidth (CFG_Dev_ID + 25) // [1/14/2014 deng]
#define CFG_DevKillDec (CFG_Dev_ID + 26)// [2/28/2014 deng]
#define CFG_DevFuncDiFltSmpRate (CFG_Dev_ID + 27) // [10/18/2013 dan.yang]
#define CFG_DevLogMsg (CFG_Dev_ID + 28) // [06/26/2015 andy.wang]
//DAQ function [1/24/2008 Dean]
#define CFG_DaqAiChanType (CFG_Dev_ID + 50)
#define CFG_DaqAiRanges (CFG_Dev_ID + 51)
#define CFG_DaqMaiRanges (CFG_Dev_ID + 52)
#define CFG_DaqAoRanges_C0 (CFG_Dev_ID + 53)
#define CFG_DaqAoRanges_C1 (CFG_Dev_ID + 54)
#define CFG_DaqAoRanges_C2 (CFG_Dev_ID + 55)
#define CFG_DaqAoRanges_C3 (CFG_Dev_ID + 56)
#define CFG_DaqAiGain (CFG_Dev_ID + 57) // [4/19/2012 dan.yang]
//Master device config
#define CFG_MasBaudRate_R0 (CFG_Dev_ID + 31)
#define CFG_MasBaudRate_R1 (CFG_Dev_ID + 32)
#define CFG_MasComErrRate_R0 (CFG_Dev_ID + 33)
#define CFG_MasComErrRate_R1 (CFG_Dev_ID + 34)
#define CFG_MasComContiErr_R0 (CFG_Dev_ID + 35)
#define CFG_MasComContiErr_R1 (CFG_Dev_ID + 36)
#define CFG_MasIoComContiErr_R0 (CFG_Dev_ID + 37)
#define CFG_MasIoComContiErr_R1 (CFG_Dev_ID + 38)
#define CFG_MasDataComContiErr_R0 (CFG_Dev_ID + 39)
#define CFG_MasDataComContiErr_R1 (CFG_Dev_ID + 40)
#define CFG_MasCycleTime (CFG_Dev_ID + 60) // [11/10/2014 dan]
#define CFG_IoCycleTime (CFG_Dev_ID + 61)
#define CFG_DevMultiTrigPulseMode (CFG_Dev_ID + 65)
#define CFG_DevMultiTrigAutoEmptyEn (CFG_Dev_ID + 68)
#define CFG_DevMultiTrigForcePWMCount (CFG_Dev_ID + 69)
///////////////////////////////////////////////////////////////////////////////
// Axis Feature
///////////////////////////////////////////////////////////////////////////////
#define FT_AxFunctionMap (FT_Ax_ID + 0)
#define FT_AxMaxVel (FT_Ax_ID + 1)
#define FT_AxMaxAcc (FT_Ax_ID + 2)
#define FT_AxMaxDec (FT_Ax_ID + 3)
#define FT_AxMaxJerk (FT_Ax_ID + 4)
#define FT_AxPulseInMap (FT_Ax_ID + 5)
#define FT_AxPulseInModeMap (FT_Ax_ID + 6)
#define FT_AxPulseOutMap (FT_Ax_ID + 7)
#define FT_AxPulseOutModeMap (FT_Ax_ID + 8)
#define FT_AxAlmMap (FT_Ax_ID + 9)
#define FT_AxInpMap (FT_Ax_ID + 10)
#define FT_AxErcMap (FT_Ax_ID + 11)
#define FT_AxErcEnableModeMap (FT_Ax_ID + 12)
#define FT_AxErcOnTimeMap (FT_Ax_ID + 13)
#define FT_AxErcOffTimeMap (FT_Ax_ID + 14)
#define FT_AxSdMap (FT_Ax_ID + 15)
#define FT_AxElMap (FT_Ax_ID + 16)
#define FT_AxSwMelMap (FT_Ax_ID + 17)
#define FT_AxSwPelMap (FT_Ax_ID + 18)
#define FT_AxHomeMap (FT_Ax_ID + 19)
#define FT_AxBackLashMap (FT_Ax_ID + 20)
#define FT_AxVibrationMap (FT_Ax_ID + 21)
#define FT_AxAlarmMap (FT_Ax_ID + 22)
#define FT_AxCompareMap (FT_Ax_ID + 23) // [9/14/2011 dan.yang]
#define FT_AxLatchMap (FT_Ax_ID + 24) // [9/14/2011 dan.yang]
#define FT_AxCamDOMap (FT_Ax_ID + 25) // [9/14/2011 dan.yang]
#define FT_AxExtDriveMap (FT_Ax_ID + 26) // [9/14/2011 dan.yang]
#define FT_AxExtMasterSrcMap (FT_Ax_ID + 27) // [9/14/2011 dan.yang]
#define FT_AxGenDOMap (FT_Ax_ID + 28) // [9/14/2011 dan.yang]
#define FT_AxGenDIMap (FT_Ax_ID + 29) // [9/14/2011 dan.yang]
#define FT_AxSimStartSourceMap (FT_Ax_ID + 30) // [9/19/2011 dan.yang]
#define FT_AxHomeModeMap (FT_Ax_ID + 31) // [6/14/2012 dan.yang]
#define FT_AxIN1Map (FT_Ax_ID + 32) // [12/15/2012 dan.yang]
#define FT_AxIN2Map (FT_Ax_ID + 33) // [12/15/2012 dan.yang]
#define FT_AxIN3Map (FT_Ax_ID + 34) // [12/15/2012 dan.yang]
#define FT_AxIN4Map (FT_Ax_ID + 35) // [12/15/2012 dan.yang]
#define FT_AxIN5Map (FT_Ax_ID + 36) // [12/15/2012 dan.yang]
#define FT_AxDIFilterMap (FT_Ax_ID + 37) // [1/8/2014 deng]
#define FT_AxJogMap (FT_Ax_ID + 38) // [5/8/2014 dan.yang]
///////////////////////////////////////////////////////////////////////////////
// Axis Parameter
///////////////////////////////////////////////////////////////////////////////
#define PAR_AxVelLow (PAR_Ax_ID + 0)
#define PAR_AxVelHigh (PAR_Ax_ID + 1)
#define PAR_AxAcc (PAR_Ax_ID + 2)
#define PAR_AxDec (PAR_Ax_ID + 3)
#define PAR_AxJerk (PAR_Ax_ID + 4)
#define PAR_AxHomeExMode (PAR_Ax_ID + 5)
#define PAR_AxHomeExSwitchMode (PAR_Ax_ID + 6)
//#define PAR_AxHomeExCrossDistance (PAR_Ax_ID + 7)
#define PAR_AxHomeCrossDistance (PAR_Ax_ID + 7)
#define PAR_AxJerkL (PAR_Ax_ID + 8)
//#define PAR_AxJogVelLow (PAR_Ax_ID + 9)
//#define PAR_AxJogVelHigh (PAR_Ax_ID + 10)
//#define PAR_AxJogAcc (PAR_Ax_ID + 11)
//#define PAR_AxJogDec (PAR_Ax_ID + 12)
//#define PAR_AxJogJerk (PAR_Ax_ID + 13)
#define PAR_AxHomeVelLow (PAR_Ax_ID + 14)
#define PAR_AxHomeVelHigh (PAR_Ax_ID + 15)
#define PAR_AxHomeAcc (PAR_Ax_ID + 16)
#define PAR_AxHomeDec (PAR_Ax_ID + 17)
#define PAR_AxHomeJerk (PAR_Ax_ID + 18)
//YDD. 2015.3.6 Add for panasonic driver parameter getting/setting on PCI-1203
#define PAR_AxHistoryNumber (PAR_Ax_ID + 20)
#define PAR_AxHistoryIndex1 (PAR_Ax_ID + 21)
#define PAR_AxHistoryIndex2 (PAR_Ax_ID + 22)
#define PAR_AxHistoryIndex3 (PAR_Ax_ID + 23)
#define PAR_AxHistoryIndex4 (PAR_Ax_ID + 24)
#define PAR_AxHistoryIndex5 (PAR_Ax_ID + 25)
#define PAR_AxHistoryIndex6 (PAR_Ax_ID + 26)
#define PAR_AxHistoryIndex7 (PAR_Ax_ID + 27)
#define PAR_AxHistoryIndex8 (PAR_Ax_ID + 28)
#define PAR_AxHistoryIndex9 (PAR_Ax_ID + 29)
#define PAR_AxHistoryIndex10 (PAR_Ax_ID + 30)
#define PAR_AxHistoryIndex11 (PAR_Ax_ID + 31)
#define PAR_AxHistoryIndex12 (PAR_Ax_ID + 32)
#define PAR_AxHistoryIndex13 (PAR_Ax_ID + 33)
#define PAR_AxHistoryIndex14 (PAR_Ax_ID + 34)
#define PAR_AxDriverSWVersion (PAR_Ax_ID + 35)
#define PAR_AxDriverStatus (PAR_Ax_ID + 36)
#define PAR_AxDriverModelNumber (PAR_Ax_ID + 37)
#define PAR_AxDriverSerialNumber (PAR_Ax_ID + 38)
#define PAR_AxDriverActualTor (PAR_Ax_ID + 39)
#define PAR_AxDriverVendorID (PAR_Ax_ID + 40)
#define PAR_AxDriverReserved2 (PAR_Ax_ID + 41)
///////////////////////////////////////////////////////////////////////////////
// Axis Config
///////////////////////////////////////////////////////////////////////////////
#define CFG_AxPPU (CFG_Ax_ID + 50)
#define CFG_AxPhyID (CFG_Ax_ID + 51)
#define CFG_AxMaxVel (CFG_Ax_ID + 52)
#define CFG_AxMaxAcc (CFG_Ax_ID + 53)
#define CFG_AxMaxDec (CFG_Ax_ID + 54)
#define CFG_AxMaxJerk (CFG_Ax_ID + 55)
#define CFG_AxPulseInMode (CFG_Ax_ID + 56)
#define CFG_AxPulseInLogic (CFG_Ax_ID + 57)
#define CFG_AxPulseInSource (CFG_Ax_ID + 58)
#define CFG_AxPulseOutMode (CFG_Ax_ID + 59)
#define CFG_AxAlmEnable (CFG_Ax_ID + 60)
#define CFG_AxAlmLogic (CFG_Ax_ID + 61)
#define CFG_AxAlmReact (CFG_Ax_ID + 62)
#define CFG_AxInpEnable (CFG_Ax_ID + 63)
#define CFG_AxInpLogic (CFG_Ax_ID + 64)
#define CFG_AxErcLogic (CFG_Ax_ID + 65)
#define CFG_AxErcOnTime (CFG_Ax_ID + 66)
#define CFG_AxErcOffTime (CFG_Ax_ID + 67)
#define CFG_AxErcEnableMode (CFG_Ax_ID + 68)
#define CFG_AxSdEnable (CFG_Ax_ID + 69)
#define CFG_AxSdLogic (CFG_Ax_ID + 70)
#define CFG_AxSdReact (CFG_Ax_ID + 71)
#define CFG_AxSdLatch (CFG_Ax_ID + 72)
#define CFG_AxElEnable (CFG_Ax_ID + 73)
#define CFG_AxElLogic (CFG_Ax_ID + 74)
#define CFG_AxElReact (CFG_Ax_ID + 75)
#define CFG_AxSwMelEnable (CFG_Ax_ID + 76)
#define CFG_AxSwPelEnable (CFG_Ax_ID + 77)
#define CFG_AxSwMelReact (CFG_Ax_ID + 78)
#define CFG_AxSwPelReact (CFG_Ax_ID + 79)
#define CFG_AxSwMelValue (CFG_Ax_ID + 80)
#define CFG_AxSwPelValue (CFG_Ax_ID + 81)
#define CFG_AxHomeMode (CFG_Ax_ID + 82)
#define CFG_AxHomeDir (PAR_Ax_ID + 83)
#define CFG_AxHomeSwitchMode (PAR_Ax_ID + 84)
#define CFG_AxHomePosition (PAR_Ax_ID + 85)
#define CFG_AxHomeCrossDistance (PAR_Ax_ID + 86)
#define CFG_AxOrgEnable (CFG_Ax_ID + 87)
#define CFG_AxOrgLogic (CFG_Ax_ID + 88)
#define CFG_AxEzEnable (CFG_Ax_ID + 89)
#define CFG_AxEzLogic (CFG_Ax_ID + 90)
#define CFG_AxEzCount (CFG_Ax_ID + 91)
#define CFG_AxBacklashEnable (CFG_Ax_ID + 92)
#define CFG_AxBacklashPulses (CFG_Ax_ID + 93)
#define CFG_AxVibrationEnable (CFG_Ax_ID + 94)
#define CFG_AxVibrationReverseTime (CFG_Ax_ID + 95)
#define CFG_AxVibrationForwardTime (CFG_Ax_ID + 96)
#define CFG_AxPositionLagEn (CFG_Ax_ID + 97)
#define CFG_AxMaxPositionLag (CFG_Ax_ID + 98)
#define CFG_AxEmgReaction (CFG_Ax_ID + 99)
#define CFG_AxLatchLogic (CFG_Ax_ID + 100)
#define CFG_AxHomeResetEnable (CFG_Ax_ID + 101)
#define CFG_AxCmpSrc (CFG_Ax_ID + 102)
#define CFG_AxCmpMethod (CFG_Ax_ID + 103)
#define CFG_AxCmpPulseMode (CFG_Ax_ID + 104)
#define CFG_AxCmpPulseLogic (CFG_Ax_ID + 105)
#define CFG_AxCmpPulseWidth (CFG_Ax_ID + 106)
#define CFG_AxCmpEnable (CFG_Ax_ID + 107)
#define CFG_AxRange (CFG_Ax_ID + 108)
#define CFG_AxGenDoEnable (CFG_Ax_ID + 109)
#define CFG_AxExtMasterSrc (CFG_Ax_ID + 110)
#define CFG_AxExtSelEnable (CFG_Ax_ID + 111)
#define CFG_AxExtPulseNum (CFG_Ax_ID + 112)
#define CFG_AxOrgLatch (CFG_Ax_ID + 113)
#define CFG_AxOutLogic (CFG_Ax_ID + 114)
#define CFG_AxDirLogic (CFG_Ax_ID + 115)
#define CFG_AxExtPulseInMode (CFG_Ax_ID + 116)
#define CFG_AxExtPresetNum (CFG_Ax_ID + 117)
#define CFG_AxErcOffTmEnable (CFG_Ax_ID + 118)
#define CFG_AxAuxOutEnable (CFG_Ax_ID + 119)
#define CFG_AxAuxOutTime (CFG_Ax_ID + 120)
/*ydd add for pci1245 and pci1265 2011-03-08 */
#define CFG_AxCamDOEnable (CFG_Ax_ID + 121)
#define CFG_AxCamDOLoLimit (CFG_Ax_ID + 122)
#define CFG_AxCamDOHiLimit (CFG_Ax_ID + 123)
#define CFG_AxCamDOMode (CFG_Ax_ID + 124)
#define CFG_AxCamDODir (CFG_Ax_ID + 125)
#define CFG_AxCamDOCmpSrc (CFG_Ax_ID + 126)
#define CFG_AxCamDOLogic (CFG_Ax_ID + 127)
#define CFG_AxModuleRange (CFG_Ax_ID + 128)
#define CFG_AxBacklashVel (CFG_Ax_ID + 129)
#define CFG_AxLatchEnable (CFG_Ax_ID + 130)
#define CFG_AxPulseInMaxFreq (CFG_Ax_ID + 131) // [6/20/2011 dan.yang]
#define CFG_AxSimStartSource (CFG_Ax_ID + 132) // [9/19/2011 dan.yang]
#define CFG_AxOrgReact (CFG_Ax_ID + 133) // [12/26/2011 dan.yang]
#define CFG_AxIN1StopEnable (CFG_Ax_ID + 134) // [12/14/2012 dan.yang]
#define CFG_AxIN1StopReact (CFG_Ax_ID + 135) // [12/14/2012 dan.yang]
#define CFG_AxIN1StopLogic (CFG_Ax_ID + 136) // [12/14/2012 dan.yang]
#define CFG_AxIN2StopEnable (CFG_Ax_ID + 137) // [12/14/2012 dan.yang]
#define CFG_AxIN2StopReact (CFG_Ax_ID + 138) // [12/14/2012 dan.yang]
#define CFG_AxIN2StopLogic (CFG_Ax_ID + 139) // [12/14/2012 dan.yang]
#define CFG_AxIN4StopEnable (CFG_Ax_ID + 140) // [12/14/2012 dan.yang]
#define CFG_AxIN4StopReact (CFG_Ax_ID + 141) // [12/14/2012 dan.yang]
#define CFG_AxIN4StopLogic (CFG_Ax_ID + 142) // [12/14/2012 dan.yang]
#define CFG_AxIN5StopEnable (CFG_Ax_ID + 143) // [12/14/2012 dan.yang]
#define CFG_AxIN5StopReact (CFG_Ax_ID + 144) // [12/14/2012 dan.yang]
#define CFG_AxIN5StopLogic (CFG_Ax_ID + 145) // [12/14/2012 dan.yang]
//latch buffer:// [3/6/2013 dan.yang]
#define CFG_AxLatchBufEnable (CFG_Ax_ID + 146)
#define CFG_AxLatchBufMinDist (CFG_Ax_ID + 147)
#define CFG_AxLatchBufEventNum (CFG_Ax_ID + 148)
#define CFG_AxLatchBufSource (CFG_Ax_ID + 149)
#define CFG_AxLatchBufAxisID (CFG_Ax_ID + 150)
#define CFG_AxLatchBufEdge (CFG_Ax_ID + 151)
#define CFG_AxHomeOffsetDistance (CFG_Ax_ID + 152)
#define CFG_AxHomeOffsetVel (CFG_Ax_ID + 153)
//pwm //[7/15/2013]zhaocui add
#define CFG_AxPWMFreq (CFG_Ax_ID + 154)
#define CFG_AxPWMDuty (CFG_Ax_ID + 155)
#define CFG_AxPPUDenominator (CFG_Ax_ID + 156) // [8/31/2013 dan.yang]
#define CFG_AxGantryMaxDiffValue (CFG_Ax_ID + 157) // [9/3/2013 dan.yang]
// [10/29/2013 dan.yang]:Add channel
#define CFG_AxCh1CmpEnable (CFG_Ax_ID + 159)
#define CFG_AxCh1CmpPulseLogic (CFG_Ax_ID + 160)
#define CFG_AxCh2CmpEnable (CFG_Ax_ID + 161)
#define CFG_AxCh2CmpPulseLogic (CFG_Ax_ID + 162)
#define CFG_AxCh3CmpEnable (CFG_Ax_ID + 163)
#define CFG_AxCh3CmpPulseLogic (CFG_Ax_ID + 164)
//20131120 zhaocui add
#define CFG_AxPelToleranceEnable (CFG_Ax_ID + 165)
#define CFG_AxPelToleranceValue (CFG_Ax_ID + 166)
#define CFG_AxSwPelToleranceEnable (CFG_Ax_ID + 167)
#define CFG_AxSwPelToleranceValue (CFG_Ax_ID + 168)
#define CFG_AxCmpPulseWidthEx (CFG_Ax_ID + 169)
#define CFG_AxMelToleranceEnable (CFG_Ax_ID + 170)
#define CFG_AxMelToleranceValue (CFG_Ax_ID + 171)
#define CFG_AxSwMelToleranceEnable (CFG_Ax_ID + 172)
#define CFG_AxSwMelToleranceValue (CFG_Ax_ID + 173)
//20140107 zhaocui add
#define CFG_AxALMFilterTime (CFG_Ax_ID + 174)
#define CFG_AxLMTPFilterTime (CFG_Ax_ID + 175)
#define CFG_AxLMTNFilterTime (CFG_Ax_ID + 176)
#define CFG_AxIN1FilterTime (CFG_Ax_ID + 177)
#define CFG_AxIN2FilterTime (CFG_Ax_ID + 178)
#define CFG_AxORGFilterTime (CFG_Ax_ID + 179)
#define CFG_AxIN4FilterTime (CFG_Ax_ID + 180)
#define CFG_AxIN5FilterTime (CFG_Ax_ID + 181)
#define CFG_AxEncoderRatio (CFG_Ax_ID + 182)//20131203 zhaocui add
#define CFG_AxMaxErrCount (CFG_Ax_ID + 183)//20131203 zhaocui add
#define CFG_AxResponseTime (CFG_Ax_ID + 184)//20131203 zhaocui add
#define CFG_AxMaxCorrectTimes (CFG_Ax_ID + 185)//20131203 zhaocui add
// [1/16/2014 deng]
#define CFG_AxisMultiCmpDeviation (CFG_Ax_ID + 186)
#define CFG_AxForcePWMOutTime (CFG_Ax_ID + 187)
// [4/29/2014 deng]
#define CFG_AxLatchStopEnable (CFG_Ax_ID + 188)
#define CFG_AxLatchStopReact (CFG_Ax_ID + 189)
#define CFG_AxPulseStopSrc (CFG_Ax_ID + 190)
#define CFG_AxJogVLTime (CFG_Ax_ID + 191)
#define CFG_AxPulseOutReverse (CFG_Ax_ID + 192) // [3/31/2014 dan.yang]: Reverse Pulse/Dir and CW/CCW pulse out mode for fucai
#define CFG_AxKillDec (CFG_Ax_ID + 193) // [5/9/2014 kai.yang] added for DIStop dec
#define CFG_AxJogVelLow (CFG_Ax_ID + 194) //[7/10/2014 kai.yang]
#define CFG_AxJogVelHigh (CFG_Ax_ID + 195) //[7/10/2014 kai.yang]
#define CFG_AxJogAcc (CFG_Ax_ID + 196) //[7/10/2014 kai.yang]
#define CFG_AxJogDec (CFG_Ax_ID + 197) //[7/10/2014 kai.yang]
#define CFG_AxJogJerk (CFG_Ax_ID + 198) //[7/10/2014 kai.yang]
#define CFG_AxMaxErrorCnt (CFG_Ax_ID + 199) //[10/13/2014 kai.yang]
#define CFG_AxCounterMax (CFG_Ax_ID + 200) //[10/15/2014 kai.yang]
#define CFG_AxOverflowMode (CFG_Ax_ID + 201) //[10/15/2014 kai.yang]
#define CFG_AxGantryActDiffValue (CFG_Ax_ID + 202) //[11/11/2014 kai.yang]
#define CFG_AxPelLogic (CFG_Ax_ID + 203)// [11/21/2014 deng]
#define CFG_AxMelLogic (CFG_Ax_ID + 204)// [11/21/2014 deng]
#define CFG_AxSetCmpDO (CFG_Ax_ID + 205)// [12/2/2014 deng]
#define CFG_AxJogPAssign (CFG_Ax_ID + 220) //[5/8/2015 Andy.Wang]
#define CFG_AxJogNAssign (CFG_Ax_ID + 221) //[5/8/2015 Andy.Wang]
#define CFG_AxCamDOAssign (CFG_Ax_ID + 222) //[5/8/2015 Andy.Wang]
#define CFG_AxIN1StopAssign (CFG_Ax_ID + 223) //[5/12/2015 Andy.Wang]
#define CFG_AxCmdErrorProtection (CFG_Ax_ID + 224) //[7/29/2015 Andy.Wang]
#define CFG_AxTorqueEnable (CFG_Ax_ID + 225) //[8/6/2015 Andy.Wang]
#define CFG_AxJogJerkFactor (CFG_Ax_ID + 226) //[2/22/2016 Andy.Wang]
/************************************************************************/
/* dan.yang 2014.11.22 Add for etherCAT */
/************************************************************************/
#define CFG_CH_DaqDiInvertEnable CFG_CH_ID + 0
#define CFG_CH_DaqDiLowFilter CFG_CH_ID + 1
#define CFG_CH_DaqDiHighFilter CFG_CH_ID + 2
#define CFG_CH_DaqDoFsvEnable CFG_CH_ID + 3
#define CFG_CH_DaqAoRange CFG_CH_ID + 4
#define CFG_CH_DaqAiRange CFG_CH_ID + 5
#define CFG_CH_DaqAiEnable CFG_CH_ID + 6
#define CFG_CH_DaqAiIntegrationTime CFG_CH_ID + 7
#define CFG_CH_DaqAoFsv CFG_CH_ID + 8
#define CFG_CH_DaqAoStartup CFG_CH_ID + 9
/************************************************************************/
/* andy.wang 2015.04.21 Add for EtherCAT Counter */
/************************************************************************/
#define CFG_CH_DaqCntEnable CFG_CH_ID + 10
#define CFG_CH_DaqCntPulseInMode CFG_CH_ID + 11
#define CFG_CH_DaqCntInitValue CFG_CH_ID + 12
#define CFG_CH_DaqCntMaxValue CFG_CH_ID + 13
#define CFG_CH_DaqCntOverflowMode CFG_CH_ID + 14
#define CFG_CH_DaqCntLatchEnable CFG_CH_ID + 15
#define CFG_CH_DaqCntLatchEdge CFG_CH_ID + 16
#define CFG_CH_DaqCntCmpEnable CFG_CH_ID + 17
#define CFG_CH_DaqCntCmpMethod CFG_CH_ID + 18
#define CFG_CH_DaqCntCmpPulseEnable CFG_CH_ID + 19
#define CFG_CH_DaqCntCmpPulseMode CFG_CH_ID + 20
#define CFG_CH_DaqCntCmpPulseLogic CFG_CH_ID + 21
#define CFG_CH_DaqCntCmpPulseWidth CFG_CH_ID + 22
//////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Group Parameter
///////////////////////////////////////////////////////////////////////////////
#define PAR_GpVelLow (PAR_Gp_ID + 0)
#define PAR_GpVelHigh (PAR_Gp_ID + 1)
#define PAR_GpAcc (PAR_Gp_ID + 2)
#define PAR_GpDec (PAR_Gp_ID + 3)
#define PAR_GpJerk (PAR_Gp_ID + 4)
#define PAR_GpGroupID (PAR_Gp_ID + 5)
#define PAR_GpJerkL (PAR_Gp_ID + 6)
#define PAR_GpIsPathDec (PAR_Gp_ID + 7)
#define PAR_GpRefPlane (PAR_Gp_ID + 8) // [6/20/2011 dan.yang]
#define PAR_GpJerkFactor (PAR_Gp_ID + 9)
///////////////////////////////////////////////////////////////////////////////
// Group Config
///////////////////////////////////////////////////////////////////////////////
#define CFG_GpMaxVel (CFG_Gp_ID + 0)
#define CFG_GpMaxAcc (CFG_Gp_ID + 1)
#define CFG_GpMaxDec (CFG_Gp_ID + 2)
#define CFG_GpMaxJerk (CFG_Gp_ID + 3)
#define CFG_GpPPU (CFG_Gp_ID + 4)
#define CFG_GpAxesInGroup (CFG_Gp_ID + 5)
#define CFG_GpGroupID (CFG_Gp_ID + 6)
#define CFG_GpBldTime (CFG_Gp_ID + 7) // [6/2/2011 dan.yang]
#define CFG_GpSFEnable (CFG_Gp_ID + 8) // [6/2/2011 dan.yang]
#define CFG_GpVectorEnable (CFG_Gp_ID + 13) // [6/5/2013 dan.yang]
#define CFG_GpSpdFwdVelEn (CFG_Gp_ID + 14) // [6/22/2013 dan.yang]
//by dujunling 2012.11.23
typedef enum
{
GM_PATTERN_ID_RefPlane=1,
GM_PATTERN_ID_UNIT,
GM_PATTERN_ID_Coordinate,
GM_PATTERN_ID_PathControl,
GM_PATTERN_ID_DistanceMode
}GM_PATTERN_ID;
//Robot zhaocui add 201307
#define CFG_RbLengthArm1 (CFG_RB_ID + 0)
#define CFG_RbLengthArm2 (CFG_RB_ID + 1)
#define CFG_RbLengthArm3 (CFG_RB_ID + 2)
#define CFG_RbHandMode (CFG_RB_ID + 3)
#define CFG_RbSFEnable (CFG_RB_ID + 4)
#define CFG_RbLengthArm4 (CFG_RB_ID + 5)
#define CFG_RbLengthArm5 (CFG_RB_ID + 6)
#define CFG_RbCsys (CFG_RB_ID + 7)
#define CFG_RbJogAxis (CFG_RB_ID + 8)
#define CFG_RbRZCOUPLING (CFG_RB_ID + 9)
#define CFG_RbRZCFNumerator (CFG_RB_ID + 10)
#define CFG_RbRZCFDenominator (CFG_RB_ID + 11)
#define PAR_RbVelLow (PAR_RB_ID + 0)
#define PAR_RbVelHigh (PAR_RB_ID + 1)
#define PAR_RbAcc (PAR_RB_ID + 2)
#define PAR_RbDec (PAR_RB_ID + 3)
#define PAR_RbJerk (PAR_RB_ID + 4)
#define PAR_RbRefPlane (PAR_RB_ID + 5)
#endif // __ADV_MOT_PROP_ID_H__

@ -0,0 +1,78 @@
#include "StdAfx.h"
#include "ApplicationPriority.h"
#include "PropertieMgr.h"
#include "Propertie.h"
#include "LogMgr.h"
#include "AuthorityMgr.h"
CAppPriorityMgr *gAppPriorityMgr = new CAppPriorityMgr;
CAppPriorityMgr::CAppPriorityMgr(void)
{
m_bGetHighestPriority = false;//是否在打开软件时获取最高优先级
}
CAppPriorityMgr::~CAppPriorityMgr(void)
{
}
CMFCPropertyGridProperty *CAppPriorityMgr::CreatGridProperty()
{
CString PropertyName;//属性名称
CString Description;//描述
CString Path = _T("AppPriority");//存储路径
CString Name;
//-------------------------------------------------------------------------------//
PropertyName = _T("程序优先级");
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
//-------------------------------------------------------------------------------//
if(gAuthorityMgr->CheckAuthority(_FACTORY))
{
//添加属性变量映射
Name = _T("m_bGetHighestPriority");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bGetHighestPriority);
pPropertie->SetType(_PROP_TYPE_BOOL);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("最高优先级");
Description = _T("是否将程序优先级提升致系统最高级别,设置后需要重启软件");
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bGetHighestPriority, Description);
pGroup->AddSubItem(p);
gDevicePropertieMgr.Insert(p, pPropertie);
}
//-------------------------------------------------------------------------------//
return pGroup;
}
void CAppPriorityMgr::ExportPar(ofstream *pFile)
{
(*pFile)<<"[模块] [CAppPriorityMgr]------------------------------------------------"<<endl;
(*pFile)<<"[最高优先级][m_bGetHighestPriority] = "<<m_bGetHighestPriority<<endl;
}
void CAppPriorityMgr::Ini()
{
if(m_bGetHighestPriority)
{
//获取最高权限
GetHighestPriority();
}
}
//获取最高权限
void CAppPriorityMgr::GetHighestPriority()
{
CString str = "[result] [进程获取系统最高优先级OK]";
//提升当前程序的优先级
if(SetPriorityClass( GetCurrentProcess(), REALTIME_PRIORITY_CLASS ))
{
str += "成功";
gLogMgr->WriteDebugLog(str);
}
else
{
str += "失败";
gLogMgr->WriteDebugLog(str,_LOG_ERROR);
}
}

@ -0,0 +1,21 @@
#pragma once
#include "module.h"
#include "EnumPropertieType.h"
//程序的优先级管理
class CAppPriorityMgr :public CModule
{
public:
CAppPriorityMgr(void);
~CAppPriorityMgr(void);
virtual void Ini();
virtual MODULE GetModuleType(){return _APP_PRIORITY_PROP;};
virtual CMFCPropertyGridProperty *CreatGridProperty();
virtual void ExportPar(ofstream *pFile);
private:
void GetHighestPriority();
private:
bool m_bGetHighestPriority;//是否在打开软件时获取最高优先级
};
extern CAppPriorityMgr *gAppPriorityMgr;

@ -0,0 +1,155 @@
#include "StdAfx.h"
#include "ArrayMgr.h"
#include "GlobalFunction.h"
#include "CommandArray.h"
#include "CommandMgr.h"
CArrayMgr::CArrayMgr(void)
{
}
CArrayMgr::~CArrayMgr(void)
{
}
void CArrayMgr::Creat(SArrayPar &ArrayPar)
{
//初始化
m_ObjContainer.Clear();
if(ArrayPar.m_bRectArray)
{
RectCreat(ArrayPar);
}
else if(ArrayPar.m_bCircleArray)
{
CircleCreat(ArrayPar);
}
else
{
FillCreat(ArrayPar);
}
//创建指令
CreatCmd();
}
//矩形阵列方式
void CArrayMgr::RectCreat(SArrayPar &ArrayPar)
{
//按照指定个数每次克隆一个obj 到m_ObjContainer 中
for(int i=0;i<ArrayPar.m_ArrayCntV;i++)
{
for(int j=0;j<ArrayPar.m_ArrayCntH;j++)
{
//导入当前选择的obj (此时为选择状态)
GetLayerInstance().CloneObj(m_ObjContainer,true);
//移动到阵列的位置--------------------------------------
SObjOperatePar par;
par.OpType = _OP_MOVE;
par.MoveX = ArrayPar.m_ArrayOffsetV*i;
par.MoveY = ArrayPar.m_ArrayOffsetH*j;
m_ObjContainer.OperateObj(par,true);
//操作完成后变为非选择状态
m_ObjContainer.NotSelAllObj();
}
}
}
//圆形阵列方式
void CArrayMgr::CircleCreat(SArrayPar &ArrayPar)
{
//先X 方向阵列,在偏移旋转成圆形-----------------------------------------------------
//计算圆的周长
double Perimeter = 2*PI*ArrayPar.m_Radius;
//计算阵列间隔
ArrayPar.m_ArrayCntH = 1;//1行
ArrayPar.m_ArrayCntV = ArrayPar.m_ArrayCnt;//1行
ArrayPar.m_ArrayOffsetV = Perimeter*(ArrayPar.m_GapAngle/360);
ArrayPar.m_ArrayOffsetH = 0;
RectCreat(ArrayPar);
//计算出圆心点
DbRect AllCharRect = m_ObjContainer.GetObjRect(false);//所有obj 的范围
//底部中心点
Dbxy BottomCenterPt = AllCharRect.GetBottomCenterPt();
Dbxy CenterPt;//圆心点
CenterPt.x = BottomCenterPt.x;
CenterPt.y = BottomCenterPt.y - ArrayPar.m_Radius;
//依次旋转偏移到合适的位置
int size = m_ObjContainer.GetSize();
for(int i=0;i<size;i++)
{
DbRect ObjRect = m_ObjContainer.GetObjRect(i);
Dbxy pt = ObjRect.GetBottomCenterPt();
//旋转角度(360)
double angle = 360*(BottomCenterPt.x-pt.x)/Perimeter;
//旋转后的点
Dbxy pt2 = RotatoPt(BottomCenterPt,_360ToAngle(angle),CenterPt);
//计算偏移量
double OffsetX = pt2.x-pt.x;
double OffsetY = pt2.y-pt.y;
//旋转字符
SObjOperatePar par;
par.OpType = _OP_ROTATO;
par.BasePt = ObjRect.GetCenterPt();
par.Angle = angle;
m_ObjContainer.Operate(par,i);
//偏移字符
par.OpType = _OP_MOVE;
par.MoveX = OffsetX;
par.MoveY = OffsetY;
m_ObjContainer.Operate(par,i);
}
}
void CArrayMgr::FillCreat(SArrayPar &ArrayPar)
{
for(int k=0;k<=ArrayPar.m_FillCnt;k++)
{
bool flg = false;
//导入当前选择的obj (此时为选择状态)
GetLayerInstance().CloneObj(m_ObjContainer,true);
DbRect Rect = m_ObjContainer.GetObjRect(false);//所有obj 的范围
double w = Rect.Width();
{
SObjOperatePar par;
par.OpType = _OP_STRETCH;
par.BasePt = Rect.GetCenterPt();
par.OldSize = Rect.Width();
par.Diff = ArrayPar.m_FillOffset*k;
par.NewSize = par.OldSize + par.Diff;
if(par.NewSize < ArrayPar.m_FillOffset)
flg = true;
par.xy = _X;
m_ObjContainer.OperateObj(par,true);
}
{
SObjOperatePar par;
par.OpType = _OP_STRETCH;
par.BasePt = Rect.GetCenterPt();
par.OldSize = Rect.Height();
par.Diff = ArrayPar.m_FillOffset*k;
par.NewSize = par.OldSize + par.Diff;
if(par.NewSize < ArrayPar.m_FillOffset)
flg = true;
par.xy = _Y;
m_ObjContainer.OperateObj(par,true);
}
//操作完成后变为非选择状态
m_ObjContainer.NotSelAllObj();
if(flg)
break;
}
}
//创建指令
void CArrayMgr::CreatCmd()
{
if(!m_ObjContainer.Empty())
{
//创建撤销指令-------start
CCommandArray *pCmd = new CCommandArray;
gCommandMgr.AddUndoCommand(pCmd,m_ObjContainer.GetObjVec());
CLayer &layer = GetLayerInstance();
pCmd->SaveBaseObj(layer.GetObjContainer());
//创建撤销指令-------end
pCmd->Excute();
}
}

@ -0,0 +1,56 @@
#pragma once
#include "ObjContainer.h"
//阵列用参数
struct SArrayPar{
public:
SArrayPar()
{
m_bRectArray = true;//是否为矩形阵列
m_bCircleArray = false;
m_bFillArray = false;
m_ArrayCntH = 10;//阵列行数
m_ArrayCntV = 10;//阵列行数
m_ArrayOffsetH = 1;//横向间距
m_ArrayOffsetV = 1;//纵向间距
m_ArrayCnt = 36;//圆形阵列的数量
m_Radius = 10;//阵列半径
m_StartAngle = 90;//阵列开始角度
m_GapAngle = 10;//阵列间隔角度(360 度角)
m_FillOffset = -0.1;
m_FillCnt = 1000;
}
public:
bool m_bRectArray;//是否为矩形阵列
bool m_bCircleArray;
bool m_bFillArray;
int m_ArrayCntH;//阵列行数
int m_ArrayCntV;//阵列列数
double m_ArrayOffsetH;//横向间距
double m_ArrayOffsetV;//纵向间距
int m_ArrayCnt;//圆形阵列的数量
double m_Radius;//阵列半径
double m_StartAngle;//阵列开始角度(360 度角)
double m_GapAngle;//阵列间隔角度(360 度角)
double m_FillOffset;
int m_FillCnt;
};
class CArrayMgr
{
public:
CArrayMgr(void);
~CArrayMgr(void);
void Creat(SArrayPar &par);
private:
void RectCreat(SArrayPar &ArrayPar);
void CircleCreat(SArrayPar &ArrayPar);
void FillCreat(SArrayPar &ArrayPar);
void CreatCmd();
private:
CObjContainer m_ObjContainer;
};

@ -0,0 +1,285 @@
#include "StdAfx.h"
#include "AuthorityMgr.h"
#include "MsgBox.h"
#include "FileMgr.h"
#include "LogMgr.h"
#include "PropertieMgr.h"
#include "Propertie.h"
#define LAIPU_NAME "laipu"
#define LAIPU_PASSWORD "laipu"
#define FILE_PATH _T("\\Parameter\\Authority\\Authority.par")
bool CompareUser(CAccount Account1,CAccount Account2)
{
return Account1.m_Authority>Account2.m_Authority;
}
CAuthorityMgr *gAuthorityMgr = new CAuthorityMgr;
CAuthorityMgr::CAuthorityMgr(void)
{
m_CurAuthority = _USER;//当前权限
m_AutoFactory = false;//打开软件自动升级到管理员权限
}
CAuthorityMgr::~CAuthorityMgr(void)
{
}
CMFCPropertyGridProperty *CAuthorityMgr::CreatGridProperty()
{
CString PropertyName;//属性名称
CString Description;//描述
CString Path = _T("AuthorityMgr");//存储路径
CString Name;
//-------------------------------------------------------------------------------//
PropertyName = _T("程序权限");
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
//-------------------------------------------------------------------------------//
if(gAuthorityMgr->CheckAuthority(_FACTORY))
{
//添加属性变量映射
Name = _T("m_AutoFactory");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_AutoFactory);
pPropertie->SetType(_PROP_TYPE_BOOL);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("厂家权限");
Description = _T("打开软件时自动获得厂家权限,调试用");
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_AutoFactory, Description);
pGroup->AddSubItem(p);
gDevicePropertieMgr.Insert(p, pPropertie);
}
//-------------------------------------------------------------------------------//
return pGroup;
}
void CAuthorityMgr::Ini()
{
SaveOrLoad(false);//读取文件
if(m_AutoFactory)
m_CurAuthority = _FACTORY;
}
//检查当前权限
bool CAuthorityMgr::CheckAuthority(AUTHORITY_TYPE authority,bool bShowMsgbox)
{
if((int)m_CurAuthority >= (int)authority)
{
return true;
}
else
{
if(bShowMsgbox)
{
CMsgBox MsgBox;
CString str = "需要["+GetAccountName(authority) + "]权限!";
MsgBox.Show(str, true);
}
return false;
}
}
//是否登录
bool CAuthorityMgr::IsLogin()
{
return m_CurAuthority != _NO_LOGIN;
}
//锁定用户,权限变成未登录
void CAuthorityMgr::Lock()
{
SetAuthority(_NO_LOGIN);
m_CurUserName = "";
}
//登录
bool CAuthorityMgr::Login(CString name,CString PassWord)
{
bool ret = false;
AUTHORITY_TYPE authority = GetCurAuthority();
if(name == LAIPU_NAME && PassWord == LAIPU_PASSWORD)
{
ret = true;
authority = _FACTORY;
}
else
{
vector<CAccount>::iterator iter = m_UserVec.begin();
vector<CAccount>::iterator iter_end = m_UserVec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).m_Name == name)
{
if((*iter).m_PassWord == PassWord)
{
ret = true;
authority = (*iter).m_Authority;
break;
}
else
{
CMsgBox MsgBox;
MsgBox.Show("密码和账号不匹配");
break;
}
}
}
if(iter==iter_end)
{
CMsgBox MsgBox;
MsgBox.Show("账号或密码错误!");
}
}
if(ret)
{
SetAuthority(authority);
m_CurUserName = name;
CMsgBox MsgBox;
CString str("登录成功---->");
str += ("[Type:") + GetCurAccountName() + "]";
str += ("[Name:") + m_CurUserName + "]";
MsgBox.Show(str);
}
return ret;
}
CString CAuthorityMgr::GetAccountName(AUTHORITY_TYPE authority)
{
if(authority==_FACTORY)
return ACCOUNT_FACTORY;
if(authority==_ADMIN)
return ACCOUNT_ADMIN;
if(authority==_USER)
return ACCOUNT_USER;
return ACCOUNT_NO_LOGIN;
}
//当前账户类型
CString CAuthorityMgr::GetCurAccountName()
{
return GetAccountName(GetCurAuthority());
}
//保存或者读取
void CAuthorityMgr::SaveOrLoad(bool bSave)
{
CFileMgr FileMgr;
char filepath[1024];
FileMgr.GetFullFilePath(filepath,FILE_PATH);//获取完整路径
if(bSave)
{
CFile file(filepath,CFile::modeReadWrite|CFile::modeCreate);
CArchive ar(&file,CArchive::store);
SaveOrLoadExt(ar);
}
else
{
CFile file;
if(file.Open(filepath,CFile::modeRead))
{
CArchive ar(&file,CArchive::load);
SaveOrLoadExt(ar);
}
else
{
gLogMgr->WriteDebugLog("权限文件读取失败", _LOG_ERROR);
}
}
}
void CAuthorityMgr::SaveOrLoadExt(CArchive &ar)
{
int size = 0;
if(ar.IsStoring())
{
size = m_UserVec.size();//area 的数量
ar<<size;
}
else
{
ar>>size;
for(int i=0;i<size;i++)
{
CAccount Area;
m_UserVec.push_back(Area);
}
}
for(int i=0;i<size;i++)
{
m_UserVec[i].Serialize(ar);
}
if(!ar.IsStoring())
{
//重新排序
SortUserVec();
}
}
void CAuthorityMgr::AddAccount(CAccount Account)
{
//检查是否有重复的用户名
vector<CAccount>::iterator iter = m_UserVec.begin();
vector<CAccount>::iterator iter_end = m_UserVec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).m_Name == Account.m_Name)
{
CMsgBox MsgBox;
CString str(_T("用户:"));
str += Account.m_Name + "已存在!";
MsgBox.Show(str);
return;
}
}
m_UserVec.push_back(Account);
//重新排序
SortUserVec();
SaveOrLoad(true);
CMsgBox MsgBox;
MsgBox.Show("创建成功!");
}
//删除指定的用户
void CAuthorityMgr::DelUser(int idx)
{
if(gAuthorityMgr->CheckAuthority(_ADMIN,true)==false)
{
return;
}
vector<CAccount>::iterator iter = m_UserVec.begin();
vector<CAccount>::iterator iter_end = m_UserVec.end();
for(int i=0;iter!=iter_end;iter++,i++)
{
if(i==idx)
{
CMsgBox MsgBox;
if((*iter).m_Authority>m_CurAuthority)
{
MsgBox.Show(_T("不能删除更高级的用户!"));
return;
}
CString str(_T("删除"));
str += (*iter).m_Name + "?";
if(MsgBox.ConfirmOkCancel(str))
{
m_UserVec.erase(iter);
SortUserVec();
SaveOrLoad(true);
}
return;
}
}
}
void CAuthorityMgr::InsertToList(CListCtrl &List)
{
int size = m_UserVec.size();
for(int i=0;i<size;i++)
{
int idx = 0;
List.InsertItem(i," ");//插入一行
List.SetItemText(i,idx++,GetAccountName(m_UserVec[i].m_Authority));//权限类型
List.SetItemText(i,idx++,(m_UserVec[i].m_Name));//用户名
}
}
//重新排序
void CAuthorityMgr::SortUserVec()
{
sort(m_UserVec.begin(),m_UserVec.end(),CompareUser);
}

@ -0,0 +1,82 @@
#pragma once
#include "GlobalDefine.h"
#include "module.h"
#define ACCOUNT_NO_LOGIN "未登录"
#define ACCOUNT_USER "操作员"
#define ACCOUNT_ADMIN "管理员"
#define ACCOUNT_FACTORY "厂家"
enum AUTHORITY_TYPE
{
_NO_LOGIN = 0,//未登录
_USER,//操作员
_ADMIN,//管理员
_FACTORY,//厂家
};
//账号
class CAccount
{
public:
CAccount()
{
m_Authority = _NO_LOGIN;
}
void Serialize(CArchive& ar)
{
if(ar.IsStoring())
{
ar<<(int)m_Authority;
ar<<m_Name;
ar<<m_PassWord;
}
else
{
int tmp;
ar>>tmp;
m_Authority = (AUTHORITY_TYPE)tmp;
ar>>m_Name;
ar>>m_PassWord;
}
}
public:
AUTHORITY_TYPE m_Authority;//权限
CString m_Name;//用户名
CString m_PassWord;//密码
};
//权限管理
class CAuthorityMgr:public CModule
{
public:
CAuthorityMgr(void);
~CAuthorityMgr(void);
virtual void Ini();
virtual MODULE GetModuleType(){return _AUTHORITY_PROP;};
virtual CMFCPropertyGridProperty *CreatGridProperty();
void SetAuthority(AUTHORITY_TYPE authority){m_CurAuthority = authority;};//设置当前权限
bool CheckAuthority(AUTHORITY_TYPE authority,bool bShowMsgbox = false);//检查当前权限
AUTHORITY_TYPE GetCurAuthority(){return m_CurAuthority;};
void AddAccount(CAccount Account);
bool Login(CString name,CString PassWord);
CString GetAccountName(AUTHORITY_TYPE authority);
void SaveOrLoad(bool bSave);
void InsertToList(CListCtrl &List);
void DelUser(int idx);
CString GetCurAccountName();
CString GetCurUserName(){return m_CurUserName;};
bool IsAutoFactory(){return m_AutoFactory;};
void Lock();
bool IsLogin();
private:
void SaveOrLoadExt(CArchive &ar);
void SortUserVec();
private:
AUTHORITY_TYPE m_CurAuthority;//当前权限
CString m_CurUserName;//当前用户名
vector<CAccount> m_UserVec;//所有的用户
bool m_AutoFactory;//打开软件自动升级到管理员权限
};
extern CAuthorityMgr *gAuthorityMgr;

@ -0,0 +1,2 @@
#include "StdAfx.h"
#include "BarCodeModule.h"

@ -0,0 +1,13 @@
#pragma once
//管理条码或者二位码的一个小块
class CBarCodeModule{
public:
CBarCodeModule(bool bBlack)
{
m_bBlack = bBlack;//是否是黑色的
}
bool IsBlack(){return m_bBlack;};
private:
bool m_bBlack;//是否是黑色的
};

@ -0,0 +1,30 @@
#pragma once
//位运算函数
//PortVal 的PortIdx 位设置为1
inline long SetBitOn(long PortVal,int PortIdx)
{
PortVal= PortVal |(1<<PortIdx);
return PortVal;
}
//PortVal 的PortIdx 位设置为0
inline BYTE SetBitOff(BYTE PortVal,int PortIdx)
{
PortVal = (PortVal)&(~(1<<PortIdx));
return PortVal;
}
//判断某位是否为1,PortIdx 从右到左
inline BOOL IsBitOn(BYTE PortVal,int PortIdx)
{
if((PortVal>>PortIdx)&1)
return TRUE;
else
return FALSE;
}
inline long SetBitByBool(BYTE PortVal,int PortIdx,bool b)
{
if(b)
return SetBitOn(PortVal,PortIdx);
return SetBitOff(PortVal,PortIdx);
}

@ -0,0 +1,558 @@
// 2003.09.10
// 2003.12.08 V1.2
// 2004.05.08 V1.3
// 2004.12.10 V1.5
//****************************************
//** Copyright (C) W.ch 1999-2004 **
//** Web: http://www.winchiphead.com **
//****************************************
//** DLL for PCI interface chip CH365 **
//** C, VC5.0 **
//****************************************
//
// PCI总线接口芯片CH365的应用层接口库 V1.5
// 南京沁恒电子有限公司 作者: W.ch 2004.12
// CH365-DLL V1.5 , Support: IO/MEM/INT
// 运行环境: Windows 98/ME, Windows 2000/XP
#ifndef _CH365_DLL_H
#define _CH365_DLL_H
#ifdef __cplusplus
extern "C" {
#endif
#define mOFFSET( s, m ) ( (ULONG) & ( ( ( s * ) 0 ) -> m ) ) // 定义获取结构成员相对偏移地址的宏
#ifndef max
#define max( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) // 较大值
#endif
#ifndef min
#define min( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) // 较小值
#endif
#ifdef ExAllocatePool
#undef ExAllocatePool // 删除带TAG的内存分配
#endif
#ifndef NTSTATUS
typedef LONG NTSTATUS; // 返回状态
#endif
typedef struct _PCI_CONFIG { // 定义PCI配置空间数据结构
USHORT mPcVendorId; // 00H 供应商标识
USHORT mPcDeviceId; // 02H 设备标识
USHORT mPcCommandReg; // 04H 命令寄存器
USHORT mPcStatusReg; // 06H 状态寄存器
UCHAR mPcRevisionId; // 08H 修改标识
UCHAR mPcProgramIf; // 09H 寄存器级编程接口
UCHAR mPcSubClass; // 0AH 子类代码
UCHAR mPcBaseClass; // 0BH 基本分类代码
UCHAR mPcCacheLine; // 0CH 缓存行长度
UCHAR mPcLatenTimer; // 0DH 延迟计数器
UCHAR mPcHeaderType; // 0EH 头标类型
UCHAR mPcBistReg; // 0FH 内含自测试寄存器
ULONG mPcBaseAddr0; // 10H 基址寄存器0
ULONG mPcBaseAddr1; // 14H 基址寄存器1
ULONG mPcBaseAddr2; // 18H 基址寄存器2
ULONG mPcBaseAddr3; // 1CH 基址寄存器3
ULONG mPcBaseAddr4; // 20H 基址寄存器4
ULONG mPcBaseAddr5; // 24H 基址寄存器5
ULONG mPcCardCis; // 28H
USHORT mPcSubSysVen; // 2CH 子系统供应商标识
USHORT mPcSubSysDev; // 2EH 子系统设备标识
ULONG mPcExpansRom; // 30H 扩展ROM基址寄存器
UCHAR mPcCapPtr; // 34H
UCHAR mPcReserved1[3]; // 35H
ULONG mPcReserved2; // 38H
UCHAR mPcInterLine; // 3CH 中断线寄存器
UCHAR mPcInterPin; // 3DH 中断引脚寄存器
UCHAR mPcMinGrant; // 3EH
UCHAR mPcMaxLatency; // 3FH
} mPCI_CONFIG, *mPPCI_CONFIG;
typedef struct _PCI_EXP_ROM { // PCI扩展ROM的数据结构
UCHAR mPerRomSig[4]; // 00H PCI扩展ROM签名字符串'PCIR'
USHORT mPerVendorId; // 04H 供应商标识
USHORT mPerDeviceId; // 06H 设备标识
USHORT mPerVpdPtr; // 08H 重要产品数据指针
USHORT mPerStrucLen; // 0AH PCI扩展ROM数据结构的长度
UCHAR mPerRevision; // 0CH PCI扩展ROM数据结构的修改版本
UCHAR mPerProgramIf; // 0DH 寄存器级编程接口
UCHAR mPerSubClass; // 0EH 子类代码
UCHAR mPerBaseClass; // 0FH 基本分类代码
USHORT mPerImageLen; // 10H 映像长度
USHORT mPerImageRev; // 12H 映像中代码/数据的修改版本
UCHAR mPerCodeType; // 14H 代码类型
UCHAR mPerIndicator; // 15H 映像指示标志
USHORT mPerReserved; // 16H
} mPCI_EXP_ROM, *mPPCI_EXP_ROM;
typedef struct _CH365_CFG_REG { // CH365芯片的配置寄存器
mPCI_CONFIG mCh365CfgPci; // 00H-3FH,共64字节为标准PCI配置空间
UCHAR mCh365CfgCtrl; // 40H 芯片控制寄存器,高5位只读
UCHAR mCh365CfgDin; // 41H 8位总线输入端口,只读
UCHAR mCh365CfgState; // 42H 芯片状态寄存器,只读
UCHAR mCh365CfgResv; // 43H
} mCH365_CFG_REG, *mPCH365_CFG_REG;
typedef struct _CH365_IO_REG { // CH365芯片的I/O空间
UCHAR mCh365IoPort[0xf0]; // 00H-EFH,共240字节为标准的I/O端口
union { // 以字或者以字节为单位进行存取
USHORT mCh365MemAddr; // F0H 存储器接口: A15-A0地址设定寄存器
struct { // 以字节为单位进行存取
UCHAR mCh365MemAddrL; // F0H 存储器接口: A7-A0地址设定寄存器
UCHAR mCh365MemAddrH; // F1H 存储器接口: A15-A8地址设定寄存器
};
};
UCHAR mCh365IoResv2; // F2H
UCHAR mCh365MemData; // F3H 存储器接口: 存储器数据存取寄存器
UCHAR mCh365I2cData; // F4H I2C串行接口: I2C数据存取寄存器
UCHAR mCh365I2cCtrl; // F5H I2C串行接口: I2C控制和状态寄存器
UCHAR mCh365I2cAddr; // F6H I2C串行接口: I2C地址设定寄存器
UCHAR mCh365I2cDev; // F7H I2C串行接口: I2C设备地址和命令寄存器
UCHAR mCh365IoCtrl; // F8H 芯片控制寄存器,高5位只读
UCHAR mCh365IoBuf; // F9H 本地数据输入缓存寄存器
UCHAR mCh365Speed; // FAH 芯片速度控制寄存器
UCHAR mCh365IoResv3; // FBH
UCHAR mCh365IoTime; // FCH 硬件循环计数寄存器
UCHAR mCh365IoResv4[3]; // FDH
} mCH365_IO_REG, *mPCH365_IO_REG;
typedef struct _CH365_MEM_REG { // CH365芯片的存储器空间
UCHAR mCh365MemPort[0x8000]; // 0000H-7FFFH,共32768字节为标准的存储器单元
} mCH365_MEM_REG, *mPCH365_MEM_REG;
typedef struct _WIN32_COMMAND { // 定义WIN32命令接口结构
union {
ULONG mFunction; // 输入时指定功能代码
NTSTATUS mStatus; // 输出时返回操作状态
};
PVOID mAddress; // 起始地址,返回地址
ULONG mLength; // 存取长度,返回后续数据的长度
UCHAR mBuffer[4]; // 数据缓冲区,长度为0至32KB
} mWIN32_COMMAND, *mPWIN32_COMMAND;
// WIN32应用层接口命令
#define IOCTL_CH365_COMMAND ( FILE_DEVICE_UNKNOWN << 16 | FILE_ANY_ACCESS << 14 | 0x0f36 << 2 | METHOD_BUFFERED ) // 专用接口
#define mWIN32_COMMAND_HEAD mOFFSET( mWIN32_COMMAND, mBuffer ) // WIN32命令接口的头长度
#define mCH365_MAX_NUMBER 16 // 最多同时连接的CH365数
#define mMAX_BUFFER_LENGTH max( sizeof( mCH365_IO_REG ), sizeof( mCH365_MEM_REG ) ) // 数据缓冲区最大长度
#define mMAX_COMMAND_LENGTH ( mWIN32_COMMAND_HEAD + mMAX_BUFFER_LENGTH ) // 最大数据长度加上命令结构头的长度
#define mCH365_MEM_BASE_AUTO ( (PVOID)0xffffffff ) // 自动设定CH365的存储器基址
#define mCH365_INT_TOOL_LINE_AUTO 0xffffffff // 自动检测CH365的中断号
// 寄存器的位定义
#define mBitAddr15Out 0x01 // 设定A15输出值,1*:high,0:low
#define mBitSysExtOut 0x02 // 设定SYS_EX输出值,1:high,0*:low
#define mBitIntAction 0x04 // 设定中断激活状态,1:action,0*:inaction
#define mBitPciIdDef 0x01 // 只读,PCI设备标识的当前选择,1*:default,0:external
#define mBitPortHit 0x04 // 只读,本地硬件定址功能的启用状态,1:启用,0*:禁用
#define mBitInterRom 0x10 // 只读,内部Mini-ROM功能的启用状态,1:启用,0*:禁用
#define mBitSysExtOe 0x40 // 只读,SYS_EX输出三态控制/输出使能,1*:启用,0:禁用
#define mBitIntEnable 0x80 // 只读,中断功能的启用状态,1:启用,0*:禁用
#define mBitI2cStatus 0x01 // I2C接口的操作控制和状态,1:开始/正在操作,0*:空闲/操作完成
#define mBitI2cSclOut 0x80 // 选择I2C接口的SCL输出,1:SYS_EX,0*:A15
#define mBitSpeedAct 0x07 // 速度控制,激活状态的脉冲宽度,实际宽度为该值乘以30nS
#define mBitSpeedInact 0x10 // 速度控制,非激活状态的空闲宽度,1:前45nS/后15nS,0:前15nS/后15nS
#define mBitSpeedPreft 0x80 // 速度控制,预取状态控制位,1:预取位有效,0:预取位无效
// 应用层接口的功能代码
#define mFuncNoOperation 0x00000000 // 无操作
#define mFuncGetVersion 0x00000001 // 获取驱动程序版本号
#define mFuncGetIoBaseAddr 0x00000004 // 读取I/O端口基址
#define mFuncSetIoBaseAddr 0x00000005 // 设置I/O端口基址
#define mFuncGetMemBaseAddr 0x00000006 // 读取存储器基址
#define mFuncSetMemBaseAddr 0x00000007 // 设置存储器基址,自动设定存储器基址
#define mFuncGetInterLine 0x00000008 // 读取中断号
#define mFuncSetInterLine 0x00000009 // 设置中断号,自动检测中断号
#define mFuncWaitInterrupt 0x0000000a // 等待中断,直到CH365产生中断
#define mFuncAbortWaitInter 0x0000000b // 放弃等待中断,终止等待
#define mFuncSetExclusive 0x0000000c // 设置独占使用
#define mFuncReadIoByte 0x00000010 // 读取输入输出端口,在同一个端口地址以字节为单位连续读取
#define mFuncReadIoWord 0x00000011 // 读取输入输出端口,在同一个端口地址以字为单位连续读取
#define mFuncReadIoDword 0x00000012 // 读取输入输出端口,在同一个端口地址以双字为单位连续读取
#define mFuncReadIoBlock 0x00000013 // 读取输入输出端口,每读取一个字节,端口地址加一
#define mFuncWriteIoByte 0x00000014 // 写入输入输出端口,在同一个端口地址以字节为单位连续写入
#define mFuncWriteIoWord 0x00000015 // 写入输入输出端口,在同一个端口地址以字为单位连续写入
#define mFuncWriteIoDword 0x00000016 // 写入输入输出端口,在同一个端口地址以双字为单位连续写入
#define mFuncWriteIoBlock 0x00000017 // 写入输入输出端口,每写入一个字节,端口地址加一
#define mFuncReadMemByte 0x00000018 // 读取存储器/寄存器
#define mFuncReadMemWord 0x00000019 // 读取存储器/寄存器
#define mFuncReadMemDword 0x0000001a // 读取存储器/寄存器
#define mFuncWriteMemByte 0x0000001c // 写入存储器/寄存器
#define mFuncWriteMemWord 0x0000001d // 写入存储器/寄存器
#define mFuncWriteMemDword 0x0000001e // 写入存储器/寄存器
#define mFuncReadConfig 0x00000020 // 读取PCI配置空间
#define mFuncWriteConfig 0x00000021 // 写入PCI配置空间
#define mFuncReadBuffer1 0x00000024 // 读取中断命令缓冲区1
#define mFuncWriteBuffer1 0x00000025 // 写入中断命令缓冲区1
#define mFuncReadBuffer2 0x00000026 // 读取中断命令缓冲区2
#define mFuncWriteBuffer2 0x00000027 // 写入中断命令缓冲区2
typedef VOID ( CALLBACK * mPCH365_INT_ROUTINE ) ( VOID ); // 中断服务程序
HANDLE WINAPI CH365OpenDevice( // 打开CH365设备,返回句柄,出错则无效
BOOL iEnableMemory, // 是否需要支持存储器
BOOL iEnableInterrupt ); // 是否需要支持中断
VOID WINAPI CH365CloseDevice( ); // 关闭CH365设备
ULONG WINAPI CH365GetVersion( ); // 获得DLL版本号,返回版本号
ULONG WINAPI CH365DriverCommand( // 直接传递命令给驱动程序,出错则返回0,否则返回数据长度
mPWIN32_COMMAND ioCommand ); // 命令结构的指针
// 该程序在调用后返回数据长度,并且仍然返回命令结构,如果是读操作,则数据返回在命令结构中,
// 返回的数据长度在操作失败时为0,操作成功时为整个命令结构的长度,例如读一个字节,则返回mWIN32_COMMAND_HEAD+1,
// 命令结构在调用前,分别提供:命令功能代码,起始地址(可选),存取数据的长度(可选),
// 命令结构在调用后,分别返回:操作状态代码,返回的基址(可选),后续数据的长度(可选),
// 操作状态代码是由WINDOWS定义的代码,可以参考NTSTATUS.H,
// 返回的基址只适用于下列命令:获取I/O基址,获取存储器基址,获取中断号,对于其它命令则保持输入时的起始地址
// 后续数据的长度是指读操作返回的数据长度,数据存放在随后的缓冲区中,对于写操作一般为0
ULONG WINAPI CH365GetDrvVersion( ); // 获得驱动程序版本号,返回版本号,出错则返回0
BOOL WINAPI CH365GetIoBaseAddr( // 获取I/O端口的基址
mPCH365_IO_REG *oIoBaseAddr ); // 保存I/O端口基址的单元地址
BOOL WINAPI CH365SetIoBaseAddr( // 设定I/O端口的基址
mPCH365_IO_REG iIoBaseAddr ); // 指定I/O端口基址
BOOL WINAPI CH365GetMemBaseAddr( // 获取存储器的基址
mPCH365_MEM_REG *oMemBaseAddr ); // 保存存储器基址的单元地址
BOOL WINAPI CH365SetMemBaseAddr( // 设定存储器的基址
mPCH365_MEM_REG iMemBaseAddr ); // 指定存储器基址,为0则关闭存储器,为-1则自动设定
BOOL WINAPI CH365GetIntLine( // 获取中断号
PULONG oIntLine ); // 保存中断号的单元地址
BOOL WINAPI CH365SetIntLine( // 设定中断号
ULONG iIntLine ); // 指定中断号,为0则关闭中断,为-1则自动检测并设定
BOOL WINAPI CH365WaitInterrupt( ); // 等待中断事件
BOOL WINAPI CH365AbortWaitInt( ); // 放弃等待中断
BOOL WINAPI CH365SetIntRoutine( // 设定中断服务程序
mPCH365_INT_ROUTINE iIntRoutine ); // 指定中断服务程序,为NULL则取消中断服务,否则在中断时调用该程序
BOOL WINAPI CH365ReadIntCommand( // 读取中断命令缓冲区
mPWIN32_COMMAND oCommand, // 指向一个足够大的缓冲区,用于保存读取的命令结构
ULONG iCmdIndex ); // 中断命令序号,为1或者2
BOOL WINAPI CH365WriteIntCommand( // 写入中断命令缓冲区
mPWIN32_COMMAND iCommand, // 指向作为中断命令的命令结构
ULONG iCmdIndex ); // 中断命令序号,为1或者2
BOOL WINAPI CH365ReadIoByte( // 从I/O端口读取一个字节
PVOID iAddr, // 指定I/O端口的地址
PUCHAR oByte ); // 指向一个字节单元,用于保存读取的字节数据
BOOL WINAPI CH365ReadIoWord( // 从I/O端口读取一个字
PVOID iAddr, // 指定I/O端口的地址
PUSHORT oWord ); // 指向一个字单元,用于保存读取的字数据
BOOL WINAPI CH365ReadIoDword( // 从I/O端口读取一个双字
PVOID iAddr, // 指定I/O端口的地址
PULONG oDword ); // 指向一个双字单元,用于保存读取的双字数据
BOOL WINAPI CH365WriteIoByte( // 向I/O端口写入一个字节
PVOID iAddr, // 指定I/O端口的地址
UCHAR iByte ); // 待写入的字节数据
BOOL WINAPI CH365WriteIoWord( // 向I/O端口写入一个字
PVOID iAddr, // 指定I/O端口的地址
USHORT iWord ); // 待写入的字数据
BOOL WINAPI CH365WriteIoDword( // 向I/O端口写入一个双字
PVOID iAddr, // 指定I/O端口的地址
ULONG iDword ); // 待写入的双字数据
BOOL WINAPI CH365ReadMemByte( // 从存储器读取一个字节
PVOID iAddr, // 指定存储器的地址,虚拟地址
PUCHAR oByte ); // 指向一个字节单元,用于保存读取的字节数据
BOOL WINAPI CH365ReadMemDword( // 从存储器读取一个双字
PVOID iAddr, // 指定存储器的地址,虚拟地址
PULONG oDword ); // 指向一个双字单元,用于保存读取的双字数据
BOOL WINAPI CH365WriteMemByte( // 向存储器写入一个字节
PVOID iAddr, // 指定存储器的地址,虚拟地址
UCHAR iByte ); // 待写入的字节数据
BOOL WINAPI CH365WriteMemDword( // 向存储器写入一个双字
PVOID iAddr, // 指定存储器的地址,虚拟地址
ULONG iDword ); // 待写入的双字数据
BOOL WINAPI CH365ReadConfig( // 从配置空间读取一个字节数据
PVOID iOffset, // 指定偏移地址
PUCHAR oByte ); // 指向一个字节单元,用于保存读取的字节数据
BOOL WINAPI CH365WriteConfig( // 向配置空间写入一个字节数据
PVOID iOffset, // 指定偏移地址
UCHAR iByte ); // 待写入的字节数据
BOOL WINAPI CH365SetA15_A8( // 设置高地址,即设置A15-A8的输出
UCHAR iA15_A8 ); // 位7-位0对应A15-A8的输出,1为高电平,0为低电平
BOOL WINAPI CH365ReadI2C( // 从I2C接口读取一个字节数据
UCHAR iDevice, // 低7位指定I2C设备地址
UCHAR iAddr, // 指定数据单元的地址
PUCHAR oByte ); // 指向一个字节单元,用于保存读取的字节数据
BOOL WINAPI CH365WriteI2C( // 向I2C接口写入一个字节数据
UCHAR iDevice, // 低7位指定I2C设备地址
UCHAR iAddr, // 指定数据单元的地址
UCHAR iByte ); // 待写入的字节数据
HANDLE WINAPI CH365mOpenDevice( // 打开CH365设备,返回句柄,出错则无效
ULONG iIndex, // 指定CH365设备序号,0对应第一个设备
BOOL iEnableMemory, // 是否需要支持存储器
BOOL iEnableInterrupt ); // 是否需要支持中断
VOID WINAPI CH365mCloseDevice( // 关闭CH365设备
ULONG iIndex ); // 指定CH365设备序号
ULONG WINAPI CH365mDriverCommand( // 直接传递命令给驱动程序,出错则返回0,否则返回数据长度
ULONG iIndex, // 指定CH365设备序号
mPWIN32_COMMAND ioCommand ); // 命令结构的指针
// 该程序在调用后返回数据长度,并且仍然返回命令结构,如果是读操作,则数据返回在命令结构中,
// 返回的数据长度在操作失败时为0,操作成功时为整个命令结构的长度,例如读一个字节,则返回mWIN32_COMMAND_HEAD+1,
// 命令结构在调用前,分别提供:命令功能代码,起始地址(可选),存取数据的长度(可选),
// 命令结构在调用后,分别返回:操作状态代码,返回的基址(可选),后续数据的长度(可选),
// 操作状态代码是由WINDOWS定义的代码,可以参考NTSTATUS.H,
// 返回的基址只适用于下列命令:获取I/O基址,获取存储器基址,获取中断号,对于其它命令则保持输入时的起始地址
// 后续数据的长度是指读操作返回的数据长度,数据存放在随后的缓冲区中,对于写操作一般为0
BOOL WINAPI CH365mGetIoBaseAddr( // 获取I/O端口的基址
ULONG iIndex, // 指定CH365设备序号
mPCH365_IO_REG *oIoBaseAddr ); // 保存I/O端口基址的单元地址
BOOL WINAPI CH365mSetIoBaseAddr( // 设定I/O端口的基址
ULONG iIndex, // 指定CH365设备序号
mPCH365_IO_REG iIoBaseAddr ); // 指定I/O端口基址
BOOL WINAPI CH365mGetMemBaseAddr( // 获取存储器的基址
ULONG iIndex, // 指定CH365设备序号
mPCH365_MEM_REG *oMemBaseAddr ); // 保存存储器基址的单元地址
BOOL WINAPI CH365mSetMemBaseAddr( // 设定存储器的基址
ULONG iIndex, // 指定CH365设备序号
mPCH365_MEM_REG iMemBaseAddr ); // 指定存储器基址,为0则关闭存储器,为-1则自动设定
BOOL WINAPI CH365mGetIntLine( // 获取中断号
ULONG iIndex, // 指定CH365设备序号
PULONG oIntLine ); // 保存中断号的单元地址
BOOL WINAPI CH365mSetIntLine( // 设定中断号
ULONG iIndex, // 指定CH365设备序号
ULONG iIntLine ); // 指定中断号,为0则关闭中断,为-1则自动检测并设定
BOOL WINAPI CH365mWaitInterrupt( // 等待中断事件
ULONG iIndex ); // 指定CH365设备序号
BOOL WINAPI CH365mAbortWaitInt( // 放弃等待中断
ULONG iIndex ); // 指定CH365设备序号
BOOL WINAPI CH365mSetIntRoutine( // 设定中断服务程序
ULONG iIndex, // 指定CH365设备序号
mPCH365_INT_ROUTINE iIntRoutine ); // 指定中断服务程序,为NULL则取消中断服务,否则在中断时调用该程序
BOOL WINAPI CH365mReadIntCommand( // 读取中断命令缓冲区
ULONG iIndex, // 指定CH365设备序号
mPWIN32_COMMAND oCommand, // 指向一个足够大的缓冲区,用于保存读取的命令结构
ULONG iCmdIndex ); // 中断命令序号,为1或者2
BOOL WINAPI CH365mWriteIntCommand( // 写入中断命令缓冲区
ULONG iIndex, // 指定CH365设备序号
mPWIN32_COMMAND iCommand, // 指向作为中断命令的命令结构
ULONG iCmdIndex ); // 中断命令序号,为1或者2
BOOL WINAPI CH365mReadIoByte( // 从I/O端口读取一个字节
ULONG iIndex, // 指定CH365设备序号
PVOID iAddr, // 指定I/O端口的地址
PUCHAR oByte ); // 指向一个字节单元,用于保存读取的字节数据
BOOL WINAPI CH365mReadIoWord( // 从I/O端口读取一个字
ULONG iIndex, // 指定CH365设备序号
PVOID iAddr, // 指定I/O端口的地址
PUSHORT oWord ); // 指向一个字单元,用于保存读取的字数据
BOOL WINAPI CH365mReadIoDword( // 从I/O端口读取一个双字
ULONG iIndex, // 指定CH365设备序号
PVOID iAddr, // 指定I/O端口的地址
PULONG oDword ); // 指向一个双字单元,用于保存读取的双字数据
BOOL WINAPI CH365mWriteIoByte( // 向I/O端口写入一个字节
ULONG iIndex, // 指定CH365设备序号
PVOID iAddr, // 指定I/O端口的地址
UCHAR iByte ); // 待写入的字节数据
BOOL WINAPI CH365mWriteIoWord( // 向I/O端口写入一个字
ULONG iIndex, // 指定CH365设备序号
PVOID iAddr, // 指定I/O端口的地址
USHORT iWord ); // 待写入的字数据
BOOL WINAPI CH365mWriteIoDword( // 向I/O端口写入一个双字
ULONG iIndex, // 指定CH365设备序号
PVOID iAddr, // 指定I/O端口的地址
ULONG iDword ); // 待写入的双字数据
BOOL WINAPI CH365mReadMemByte( // 从存储器读取一个字节
ULONG iIndex, // 指定CH365设备序号
PVOID iAddr, // 指定存储器的地址,虚拟地址
PUCHAR oByte ); // 指向一个字节单元,用于保存读取的字节数据
BOOL WINAPI CH365mReadMemDword( // 从存储器读取一个双字
ULONG iIndex, // 指定CH365设备序号
PVOID iAddr, // 指定存储器的地址,虚拟地址
PULONG oDword ); // 指向一个双字单元,用于保存读取的双字数据
BOOL WINAPI CH365mWriteMemByte( // 向存储器写入一个字节
ULONG iIndex, // 指定CH365设备序号
PVOID iAddr, // 指定存储器的地址,虚拟地址
UCHAR iByte ); // 待写入的字节数据
BOOL WINAPI CH365mWriteMemDword( // 向存储器写入一个双字
ULONG iIndex, // 指定CH365设备序号
PVOID iAddr, // 指定存储器的地址,虚拟地址
ULONG iDword ); // 待写入的双字数据
BOOL WINAPI CH365mReadConfig( // 从配置空间读取一个字节数据
ULONG iIndex, // 指定CH365设备序号
PVOID iOffset, // 指定偏移地址
PUCHAR oByte ); // 指向一个字节单元,用于保存读取的字节数据
BOOL WINAPI CH365mWriteConfig( // 向配置空间写入一个字节数据
ULONG iIndex, // 指定CH365设备序号
PVOID iOffset, // 指定偏移地址
UCHAR iByte ); // 待写入的字节数据
BOOL WINAPI CH365mSetA15_A8( // 设置高地址,即设置A15-A8的输出
ULONG iIndex, // 指定CH365设备序号
UCHAR iA15_A8 ); // 位7-位0对应A15-A8的输出,1为高电平,0为低电平
BOOL WINAPI CH365mReadI2C( // 从I2C接口读取一个字节数据
ULONG iIndex, // 指定CH365设备序号
UCHAR iDevice, // 低7位指定I2C设备地址
UCHAR iAddr, // 指定数据单元的地址
PUCHAR oByte ); // 指向一个字节单元,用于保存读取的字节数据
BOOL WINAPI CH365mWriteI2C( // 向I2C接口写入一个字节数据
ULONG iIndex, // 指定CH365设备序号
UCHAR iDevice, // 低7位指定I2C设备地址
UCHAR iAddr, // 指定数据单元的地址
UCHAR iByte ); // 待写入的字节数据
BOOL WINAPI CH365DelayUS( // 延时指定微秒
ULONG iDelay ); // 指定要延时的微秒数,如果延时小于10则误差较大
BOOL WINAPI CH365mAccessBlock( // 读取或者写入数据块
ULONG iIndex, // 指定CH365设备序号
ULONG iAccessMode, // 参考下面的说明
PVOID iAddr, // 指定I/O端口或者存储器的地址
PVOID ioBuffer, // 指向输入或者输出的缓冲区
ULONG iLength ); // 数据块长度,也就是读取或者写入的字节数,长度不超过32KB
// iAccessMode 定义如下
// #define mFuncReadIoByte 0x00000010 // 读取输入输出端口,在同一个端口地址以字节为单位连续读取,最大长度32KB
// #define mFuncReadIoWord 0x00000011 // 读取输入输出端口,在同一个端口地址以字为单位连续读取,最大长度32KB
// #define mFuncReadIoDword 0x00000012 // 读取输入输出端口,在同一个端口地址以双字为单位连续读取,最大长度32KB
// #define mFuncReadIoBlock 0x00000013 // 读取输入输出端口,每读取一个字节,端口地址加一,最大长度240B(从偏移地址00H读到EFH)
// #define mFuncWriteIoByte 0x00000014 // 写入输入输出端口,在同一个端口地址以字节为单位连续写入,最大长度32KB
// #define mFuncWriteIoWord 0x00000015 // 写入输入输出端口,在同一个端口地址以字为单位连续写入,最大长度32KB
// #define mFuncWriteIoDword 0x00000016 // 写入输入输出端口,在同一个端口地址以双字为单位连续写入,最大长度32KB
// #define mFuncWriteIoBlock 0x00000017 // 写入输入输出端口,每写入一个字节,端口地址加一,最大长度240B(从偏移地址00H写到EFH)
// #define mFuncReadMemByte 0x00000018 // 读取存储器/寄存器,以字节为单位连续读,每读取一个字节,地址加一,最大长度32KB(从偏移地址0000H读到7FFFH)
// #define mFuncReadMemWord 0x00000019 // 读取存储器/寄存器,以字为单位连续读,每读取一个字,地址加二,最大长度32KB(从偏移地址0000H读到7FFFH)
// #define mFuncReadMemDword 0x0000001a // 读取存储器/寄存器,以双字为单位连续读,每读取一个字节,地址加四,最大长度32KB(从偏移地址0000H读到7FFFH)
// #define mFuncWriteMemByte 0x0000001c // 写入存储器/寄存器,以字节为单位连续写,每读取一个字节,地址加一,最大长度32KB(从偏移地址0000H写到7FFFH)
// #define mFuncWriteMemWord 0x0000001d // 写入存储器/寄存器,以字为单位连续写,每读取一个字,地址加二,最大长度32KB(从偏移地址0000H写到7FFFH)
// #define mFuncWriteMemDword 0x0000001e // 写入存储器/寄存器,以双字为单位连续写,每读取一个双字,地址加四,最大长度32KB(从偏移地址0000H写到7FFFH)
// 其它方式不支持,上述定义在文件CH365DLL.H中
BOOL WINAPI CH365mSetExclusive( // 设置独占使用当前CH365设备
ULONG iIndex, // 指定CH365设备序号
ULONG iExclusive ); // 为0则设备可以共享使用,非0则独占使用
#ifdef __cplusplus
}
#endif
#endif // _CH365_DLL_H

@ -0,0 +1,99 @@
#pragma once
#include "GlobalDefine.h"
#define TRUE_STR _T("TRUE")
#define FALSE_STR _T("FALSE")
//和MFC CString 相关的一些函数
//去掉小数点后面不要的0
inline void DeleteZero(CString &s)
{
int nIndex;
nIndex=s.Find('.');
if (nIndex>=0)
{
s.TrimRight('0');
if (s.GetLength()==nIndex+1)
{
s=s.Left(nIndex);
if (s.IsEmpty())
s='0';
}
}
}
//double 转换为CString
inline CString Db2CString(double n)
{
CString s;
s.Format("%lf",n);
DeleteZero(s);
return s;
}
//int 转换为CString
inline CString Int2CString(int n)
{
CString s;
s.Format("%ld",n);
return s;
}
//获取bool 类型的str
inline CString GetBoolValStr(bool b)
{
if(b)
return TRUE_STR;
else
return FALSE_STR;
}
//在str 中查找SubStr ,找到返回true
inline bool FindSubStr(CString &str,CString &SubStr)
{
return (str.Find(SubStr) != -1);
}
//删除子串,并返回剩余右边的部分
inline CString DelSubStr(CString str,CString &SubStr)
{
int pos = str.Find(SubStr);
if(pos != -1)
{
str = str.Right(str.GetLength()-(pos+SubStr.GetLength()));
}
return str;
}
inline int CStringToInt(CString &str)
{
return _tstoi(LPCTSTR(str));
}
inline double CStringToDouble(CString &str)
{
return _tstof(LPCTSTR(str));
}
inline bool CStringToBool(CString &str)
{
if(str == TRUE_STR)
return true;
return false;
}
inline CString Bool2Str(bool b)
{
if(b)
return "TRUE";
else
return "FALSE";
}
inline bool Str2Bool(CString &str)
{
if(str == _T("TRUE"))
return true;
else
return false;
}
inline CString Time2Str(int n)
{
CString s;
if(n<10)
s.Format("0%ld",n);//左边补0
else
s.Format("%ld",n);
return s;
}

@ -0,0 +1,422 @@
#include "StdAfx.h"
#include "Camera.h"
#include "Propertie.h"
#include "PropertieMgr.h"
#include "LogMgr.h"
#include "AuthorityMgr.h"
#include "GlobalDrawMgr.h"
#include "DrawSimpleShape.h"
#include "PlatformXY.h"
#include "ExceptionMsg.h"
CCamera::CCamera(void)
{
m_OnePixDis = 1;//一个像素对应的实际尺寸(mm/pix)
m_bIni = false;//是否初始化成功
m_bRotatoPtByAngle = false;//是否根据相机的安装角度修正抓取结果
m_Angle = 0;
m_bUse = true;//是否使用
m_bLeftTop = true;//基准点是否为左上角(false 为左下角)
m_bPixCoord = true;//相机抓取的是否为像素坐标(基恩士返回的是mm 单位的值)
m_bCatch = true;//实际抓取
m_CatchFrontDelay = 100;//抓取前延时ms
m_CatchWaitDelay = 200;//抓取等待延时ms
}
CCamera::~CCamera(void)
{
}
CMFCPropertyGridProperty *CCamera::CreatGridProperty()
{
CString PropertyName;//属性名称
CString Description;//描述
CString Path = _T("Camera");;//存储路径
CString Name;
//-------------------------------------------------------------------------------//
PropertyName = _T("共通设定");
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
//-------------------------------------------------------------------------------//
if(gAuthorityMgr->CheckAuthority(_FACTORY))
{
{
//添加属性变量映射
Name = _T("m_bUse");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bUse);
pPropertie->SetType(_PROP_TYPE_BOOL );
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("是否使用");
Description = _T("是否使用camera");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bUse, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_bCatch");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bCatch);
pPropertie->SetType(_PROP_TYPE_BOOL );
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("是否抓取");
Description = _T("FALSE 的时候返回0,但是不报错");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bCatch, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_CatchFrontDelay");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_CatchFrontDelay);
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("抓取前延时");
Description = _T("相机抓取前的延时ms");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_CatchFrontDelay, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_CatchWaitDelay");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_CatchWaitDelay);
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("抓取等待延时");
Description = _T("识别触发后等待数据传到ocx 的延时ms");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_CatchWaitDelay, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_bRotatoPtByAngle");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bRotatoPtByAngle);
pPropertie->SetType(_PROP_TYPE_BOOL );
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("角度修正");
Description = _T("是否根据相机的安装角度修正抓取结果");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bRotatoPtByAngle, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_Angle");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_Angle);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("安装角度");
Description = _T("CCD X 方向相对于电机X 轴的角度");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Angle, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_bLeftTop");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bLeftTop);
pPropertie->SetType(_PROP_TYPE_BOOL );
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("左上角基准");
Description = _T("基准点是否为左上角(false 为左下角)");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bLeftTop, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_bPixCoord");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bPixCoord);
pPropertie->SetType(_PROP_TYPE_BOOL );
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("像素坐标");
Description = _T("相机抓取的是否为像素坐标");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bPixCoord, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_OnePixDis");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_OnePixDis);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("像素尺寸");
Description = _T("一个像素对应的实际尺寸单位是(mm/像素)");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_OnePixDis, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_Coord_x");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_Coord.x);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("视场基准坐标x");
Description = _T("CCD 的视场基准点相对于平台原点的坐标(单位:mm)");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Coord.x, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_Coord_y");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_Coord.y);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("视场基准坐标y");
Description = _T("CCD 的视场基准点相对于平台原点的坐标(单位:mm)");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Coord.y, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_Size_w");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_Size.w);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("视场宽度");
Description = _T("CCD 视场的实际宽度(单位:mm)");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Size.w, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_Size_h");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_Size.h);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("视场高度");
Description = _T("CCD 视场的实际高度(单位:mm)");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Size.h, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
}
//-------------------------------------------------------------------------------//
return pGroup;
}
void CCamera::ExportPar(ofstream *pFile)
{
(*pFile)<<"[模块] [Camera]------------------------------------------------"<<endl;
(*pFile)<<"[CCD 坐标x][m_Coord.x] = "<<m_Coord.x<<endl;
(*pFile)<<"[CCD 坐标y][m_Coord.y] = "<<m_Coord.y<<endl;
(*pFile)<<"[像素尺寸(mm/pix) ][m_OnePixDis] = "<<m_OnePixDis<<endl;
}
void CCamera::Draw(CDC* pDC)
{
if(gDraw->IsShowPlatformPos())
{
DbRect Rect(m_Coord,gDraw->GetCatchNodeSize());
DrawCrossX(pDC,gDraw->GetMarkPointPen(),Rect);
}
}
//设置CCD 的坐标
void CCamera::SetCoord(Dbxy pt)
{
m_Coord = pt;
//强制保存所有的属性到文件
gDevicePropertieMgr.SaveAllPropertie();
}
//获取CCD 的中心点坐标(一般用来移动到CCD 观察)
Dbxy CCamera::GetCenterPt()
{
Dbxy CenterPt;
CenterPt.x = m_Coord.x + m_Size.w/2;
if(m_bLeftTop)
{
CenterPt.y = m_Coord.y - m_Size.h/2;
}
else
{
CenterPt.y = m_Coord.y + m_Size.h/2;
}
return CenterPt;
}
Dbxy CCamera::CCDpt2Platcoord(Dbxy CCDpt)
{
Dbxy pt;
pt.x = m_Coord.x + CCDpt.x;
if(m_bLeftTop)//根据CCD 的基准点,y 值不一样
pt.y = m_Coord.y - CCDpt.y;
else
pt.y = m_Coord.y + CCDpt.y;
return pt;
}
//将CCD 抓取坐标转换为相对于平台原点的坐标
//CCDpt 是CCD 抓取的坐标(相对于CCD 原点的值)
Dbxy CCamera::CCDcoord2Platformcoord(Dbxy CCDpt)
{
CString LogStr;
LogStr.Format(_T("CCDcoord2Platformcoord : CCD 返回值[x] = [%0.3f] ,[y] = [%0.3f]"),CCDpt.x,CCDpt.y);
gLogMgr->WriteDebugLog(LogStr);
//像素坐标转换为mm 单位坐标-----------------------
if(m_bPixCoord)
{
CCDpt.x *= m_OnePixDis;
CCDpt.y *= m_OnePixDis;
}
if(((CCDpt.x<0)||(CCDpt.x>m_Size.w))||((CCDpt.y<0)||(CCDpt.y>m_Size.h)))//避免错误的返回值
{
CString str = _T("定位抓取失败");
CExceptionMsg Msg;
Msg.SetMsg(str);
throw Msg;
}
LogStr.Format(_T("[MM_Coordx] = [%0.3f] ,[MM_Coordy] = [%0.3f]"),CCDpt.x,CCDpt.y);
gLogMgr->WriteDebugLog(LogStr);
//换算为平台 坐标-------------------------------------------
#if 0
Dbxy pt = CCDpt2Platcoord(CCDpt);
LogStr.Format(_T("[m_Coordx] = [%0.3f] ,[m_Coordy] = [%0.3f]"),m_Coord.x,m_Coord.y);
gLogMgr->WriteDebugLog(LogStr);
//结果抵消平台当前的移动量,才是实际测量点的坐标
Dbxy PlatformPt = gPlatformXY->GetCoord();
LogStr.Format(_T("[PlatformPtx] = [%0.3f] ,[PlatformPty] = [%0.3f]"),PlatformPt.x,PlatformPt.y);
gLogMgr->WriteDebugLog(LogStr);
pt.x -= PlatformPt.x;
pt.y -= PlatformPt.y;
#else
Dbxy CameraCoord = m_Coord;
LogStr.Format(_T("[CameraCoord.x] = [%0.3f] ,[CameraCoord.y] = [%0.3f]"),CameraCoord.x,CameraCoord.y);
gLogMgr->WriteDebugLog(LogStr);
Dbxy PlatformPt = gPlatformXY->GetCoord();
LogStr.Format(_T("[PlatformCoord.x] = [%0.3f] ,[PlatformCoord.y] = [%0.3f]"),PlatformPt.x,PlatformPt.y);
gLogMgr->WriteDebugLog(LogStr);
CameraCoord.x = CameraCoord.x - PlatformPt.x;
CameraCoord.y = CameraCoord.y + PlatformPt.y;
LogStr.Format(_T("[CameraCoord_Now.x] = [%0.3f] ,[CameraCoord_Now.y] = [%0.3f]"),CameraCoord.x,CameraCoord.y);
gLogMgr->WriteDebugLog(LogStr);
Dbxy pt;
pt.x = CameraCoord.x + CCDpt.x;
pt.y = CameraCoord.y - CCDpt.y;
LogStr.Format(_T("[CatchPt.x] = [%0.3f] ,[CatchPt.y] = [%0.3f]"),pt.x,pt.y);
gLogMgr->WriteDebugLog(LogStr);
#endif
return pt;
}
//抓取点, 并转换为平台坐标(pt 保存抓取的结果)
bool CCamera::CatchPtToPlatformcoord(Dbxy &pt)
{
Dbxy CatchPt;
bool ret;
if(!m_bCatch)//不实际抓取
{
ret = true;
CatchPt.x = CatchPt.y = 10;
}
else
{
ret = CatchPoint(CatchPt);
}
if(IsDbxyZero(CatchPt))
return false;
if(ret)
{
pt = CCDcoord2Platformcoord(CatchPt);
}
return ret;
}

@ -0,0 +1,41 @@
#pragma once
#include "GlobalDefine.h"
#include "module.h"
class CCamera:public CModule
{
public:
CCamera(void);
virtual ~CCamera(void);
virtual CMFCPropertyGridProperty *CreatGridProperty();
virtual void ExportPar(ofstream *pFile);
virtual void Draw(CDC* pDC);
virtual bool CatchPoint(Dbxy &pt){return false;};
virtual Dbxy GetCoord(){return m_Coord;};
virtual Dbxy CCDpt2Platcoord(Dbxy CCDpt);
virtual Dbxy GetCenterPt();
void SetCoord(Dbxy pt);
Dbxy CCDcoord2Platformcoord(Dbxy CCDpt);
bool CatchPtToPlatformcoord(Dbxy &pt);
double GetOnePixDis(){return m_OnePixDis;};
double GetAngle(){return m_Angle;};
int GetCatchFrontDelay(){return m_CatchFrontDelay;};
protected:
bool m_bUse;//是否使用
bool m_bIni;//是否初始化成功
double m_OnePixDis;//一个像素对应的实际尺寸(mm/pix) ,通常需要定标得到这个值,不是所有的CCD 都会使用这个值,像基恩士的就是在其内部处理的
bool m_bLeftTop;//基准点是否为左上角(false 为左下角)
bool m_bPixCoord;//相机抓取的是否为像素坐标(基恩士返回的是mm 单位的值)
Dbxy m_Coord;//CCD 视场基准点相对于平台原点的坐标值(一般是左上角,或者左下角)
DbSize m_Size;//CCD 视场范围的实际尺寸(用来计算抓取定位的坐标值)
bool m_bRotatoPtByAngle;//是否根据相机的安装角度修正抓取结果
double m_Angle;//安装角度,相对于电机的X 轴(360 度角)
bool m_bCatch;//实际抓取
int m_CatchFrontDelay;//抓取前延时ms
int m_CatchWaitDelay;//抓取等待延时ms
};

@ -0,0 +1,281 @@
#include "StdAfx.h"
#include "CameraHawkvis.h"
#include "Propertie.h"
#include "PropertieMgr.h"
#include "LogMgr.h"
#include "AuthorityMgr.h"
#include "GlobalFunction.h"
#include "ExceptionMsg.h"
#include "FileMgr.h"
#include "CStringFuc.h"
#define RESULT_CNT 10 //抓取最多的模板个数
CCameraHawkvis *gCameraHawkvis = new CCameraHawkvis;
CCameraHawkvis::CCameraHawkvis(void)
{
m_nExpore = 80000;//曝光值
m_bOpen = false;//相机是否打开
m_bRotate180 = true;//画面是否旋转180度
m_bMirrorH = false;//水平镜像
m_bMirrorV = false;//垂直镜像
}
CCameraHawkvis::~CCameraHawkvis(void)
{
}
CMFCPropertyGridProperty *CCameraHawkvis::CreatGridProperty()
{
CString PropertyName;//属性名称
CString Description;//描述
CString Path = _T("HawkvisCCD");;//存储路径
CString Name;
//-------------------------------------------------------------------------------//
PropertyName = _T("CCD ");
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
//先把共同设定加进来
CMFCPropertyGridProperty* pBase = CCamera::CreatGridProperty();
pGroup->AddSubItem(pBase);
PropertyName = _T("特殊设定");
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(PropertyName);
if(gAuthorityMgr->CheckAuthority(_FACTORY))
{
{
//添加属性变量映射
Name = _T("m_bRotate180");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bRotate180);
pPropertie->SetType(_PROP_TYPE_BOOL);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("旋转180 度");
Description = _T("相机的画面是否旋转180 度");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bRotate180, Description);
pGroup1->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_nExpore");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_nExpore);
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("曝光值");
Description = _T("相机的曝光值(0~2000000)");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_nExpore, Description);
pGroup1->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_bMirrorH");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bMirrorH);
pPropertie->SetType(_PROP_TYPE_BOOL);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("水平镜像");
Description = _T("水平镜像");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bMirrorH, Description);
pGroup1->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_bMirrorV");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bMirrorV);
pPropertie->SetType(_PROP_TYPE_BOOL);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("垂直镜像");
Description = _T("垂直镜像");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bMirrorV, Description);
pGroup1->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
pGroup->AddSubItem(pGroup1);
}
return pGroup;
}
void CCameraHawkvis::ExportPar(ofstream *pFile)
{
CCamera::ExportPar(pFile);
(*pFile)<<"[模块] [CCameraHawkvis]------------------------------------------------"<<endl;
}
void CCameraHawkvis::Ini()
{
//绑定霍克视觉的ocx 控件
//m_HawkvisCtrl = &(GetFrame()->m_DlgHawkvisCamera.m_HawkvisCtrl);
#if 0//def __HAWKVIS_MINDVISION_CCD__
//相机镜像
m_HawkvisCtrl->MV_SetReversal(0,m_bMirrorH);//水平方向
m_HawkvisCtrl->MV_SetReversal(1,m_bMirrorV);//垂直方向
//检查设置成功了没有
BOOL bMirrorH,bMirrorV;
m_HawkvisCtrl->MV_GetReversal(0,&bMirrorH);
m_HawkvisCtrl->MV_GetReversal(1,&bMirrorV);
gLogMgr->WriteDebugLog("Hawkvis : MV_GetReversal : bMirrorH = "+Bool2Str(bMirrorH));
gLogMgr->WriteDebugLog("Hawkvis : MV_GetReversal : bMirrorV = "+Bool2Str(bMirrorV));
#endif
}
//打开相机
bool CCameraHawkvis::OpenCamera()
{
if(gLogMgr->IsDebuging())//调试状态
return true;
return true;
/*
#ifdef __HAWKVIS_MINDVISION_CCD__
//m_HawkvisCtrl->MV_CloseCamera();
#else
m_HawkvisCtrl->HV_CloseCamera();
#endif
//gLogMgr->WriteDebugLog("Hawkvis : Close Cam");
#ifdef __HAWKVIS_MINDVISION_CCD__
if(m_HawkvisCtrl->MV_OpenCamera())
#else
if(m_HawkvisCtrl->HV_OpenCamera())
#endif
{
gLogMgr->WriteDebugLog("Hawkvis : Open Cam ---->OK");
m_bOpen = true;
OpenTemp();//读取模板
//设置曝光值
#ifdef __HAWKVIS_MINDVISION_CCD__
m_HawkvisCtrl->MV_SetCameraExpTime(m_nExpore);
#else
m_HawkvisCtrl->HV_SetCameraExpTime(m_nExpore);
#endif
return true;
}
else
{
gLogMgr->WriteDebugLog("Hawkvis : Open Cam ---->ERR");
return false;
}*/
}
//抓取(返回像素坐标) (一次只抓取一个mark 图形)
bool CCameraHawkvis::CatchPoint(Dbxy &pt)
{
if(!m_bUse)
return false;
//清除之前绘制的圆
m_HawkvisCtrl->ClearGraphicObject();
//抓取一帧
#ifdef __HAWKVIS_MINDVISION_CCD__
if(!m_HawkvisCtrl->MV_GetOneFrame())
#else
if(!m_HawkvisCtrl->HV_GetOneFrame())
#endif
{
CString str = _T("func : Hawkvis Get One Frame----->Error");
CExceptionMsg Msg;
Msg.SetMsg(str);
throw Msg;
}
Sleep(m_CatchWaitDelay);//等待数据结果输出到ocx 控件上
//模板查找
double pdbX[10], pdbY[10], pdbAngles[10], pdbScale[10], pdbSore[10];
long nCount[1] = { 1 };
//FindShapeMode 控件的模板查找函数。
//第一个参数金字塔层数取值范围15
//第二个参数,输出查找到的目标列坐标
//第三个参数,输出查找到的目标行坐标
//第四个参数,输出查找到的目标角度
//第五个参数,输出查找到的目标伸缩度
//第六个参数,输出查找到的目标分数
//第七个参数,输出查找到的目标个数
//第八个参数输入查找模板的ID号
VARIANT *v_pdbX = new VARIANT[1];
VARIANT *v_pdbY = new VARIANT[1];
VARIANT *v_pdbAngles = new VARIANT[1];
VARIANT *v_pdbScale = new VARIANT[1];
VARIANT *v_pdbSore = new VARIANT[1];
bool ret = m_HawkvisCtrl->FindShapeModel(0, v_pdbY, v_pdbX, v_pdbAngles, v_pdbScale, v_pdbSore, nCount);
if(!ret)//2018-01-15 增加保护,否则下面可能会报错
{
CString str = _T("func : Hawkvis Find Shape Model----->Error");
CExceptionMsg Msg;
Msg.SetMsg(str);
throw Msg;
}
//pdbX
for (long index = 0; index < ::SafeArrayGetElemsize(v_pdbX->parray); ++index){
::SafeArrayGetElement(v_pdbX->parray, &index, pdbX + index);
}
//pdbY
for (long index = 0; index < ::SafeArrayGetElemsize(v_pdbY->parray); ++index){
::SafeArrayGetElement(v_pdbY->parray, &index, pdbY + index);
}
//pdbAngles
for (long index = 0; index < ::SafeArrayGetElemsize(v_pdbAngles->parray); ++index){
::SafeArrayGetElement(v_pdbAngles->parray, &index, pdbAngles + index);
}
//pdbScale
for (long index = 0; index < ::SafeArrayGetElemsize(v_pdbScale->parray); ++index){
::SafeArrayGetElement(v_pdbScale->parray, &index, pdbScale + index);
}
//pdbSore
for (long index = 0; index < ::SafeArrayGetElemsize(v_pdbSore->parray); ++index){
::SafeArrayGetElement(v_pdbSore->parray, &index, pdbSore + index);
}
//显示查找到的模板的位置
#if 1
CString str;
str.Format("X: %0.3f, Y:%0.f", pdbX[0], pdbY[0]);
pt.x = pdbX[0];
pt.y = pdbY[0];
str.Format("X: %0.3f, Y:%0.3f",pt.x,pt.y);
gLogMgr->WriteDebugLog(str);
#endif
if(!IsDbxyZero(pt))
{
m_HawkvisCtrl->SetCrossShow(1,30,30,-1,-1,true);
m_HawkvisCtrl->ZoomFitWindow();
}
return true;
}
//调用模板
void CCameraHawkvis::OpenTemp()
{
CFileMgr FileMgr;
CString path = FileMgr.GetWorkPath();
m_HawkvisCtrl->LoadShapeModel((LPCTSTR)path);
gLogMgr->WriteDebugLog("Hawkvis : LoadCatchTemp");
}
#if 0
Dbxy CCameraHawkvis::CCDpt2Platcoord(Dbxy CCDpt)
{
Dbxy pt;
pt.x = m_Coord.x - CCDpt.x;
pt.y = m_Coord.y + CCDpt.y;
return pt;
}
#endif

@ -0,0 +1,29 @@
#pragma once
#include "Camera.h"
#include "EnumPropertieType.h"
#include "hawkvisctrlctrl1.h"
//霍克视觉(CCD 坐标的基准点是左上角)
class CCameraHawkvis :public CCamera
{
public:
CCameraHawkvis(void);
~CCameraHawkvis(void);
virtual CMFCPropertyGridProperty *CreatGridProperty();
virtual MODULE GetModuleType(){return _HAWKVIS_CCD_PROP;};
virtual void Ini();
virtual void ExportPar(ofstream *pFile);
virtual bool CatchPoint(Dbxy &pt);
//virtual Dbxy CCDpt2Platcoord(Dbxy CCDpt);
bool OpenCamera();
void OpenTemp();
private:
CHawkvisctrlctrl1 *m_HawkvisCtrl;//霍克视觉的ocx 控件
int m_nExpore;//曝光值
bool m_bOpen;//相机是否打开
bool m_bRotate180;//画面是否旋转180度
bool m_bMirrorH;//水平镜像
bool m_bMirrorV;//垂直镜像
};
extern CCameraHawkvis *gCameraHawkvis;

@ -0,0 +1,213 @@
#include "StdAfx.h"
#include "CameraKeyence.h"
#include "SocketMgr.h"
#include "LogMgr.h"
#include "Propertie.h"
#include "PropertieMgr.h"
#include "AuthorityMgr.h"
#include "GlobalFunction.h"
#define SEND_MASSAGE_TO_CCD_DELAYE_TIME 500//发送消息给CCD ,接收反馈的等待延时
CCameraKeyence *gCameraKeyence = new CCameraKeyence;
CCameraKeyence::CCameraKeyence(void)
:m_IPAddrStr("192.168.0.10")//CCD 主机的IP地址
{
}
CCameraKeyence::~CCameraKeyence(void)
{
}
#if 1
CMFCPropertyGridProperty *CCameraKeyence::CreatGridProperty()
{
CString PropertyName;//属性名称
CString Description;//描述
CString Path = _T("DaHenCCD");;//存储路径
CString Name;
//-------------------------------------------------------------------------------//
PropertyName = _T("CCD ");
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
//先把共同设定加进来
CMFCPropertyGridProperty* pBase = CCamera::CreatGridProperty();
pGroup->AddSubItem(pBase);
//-------------------------------------------------------------------------------//
PropertyName = _T("特殊设定");
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(PropertyName);
if(gAuthorityMgr->CheckAuthority(_FACTORY))
{
//添加属性变量映射
Name = _T("m_IPAddrStr");//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_IPAddrStr);
pPropertie->SetType(_PROP_TYPE_STRING);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
PropertyName = _T("CCD 主机IP 地址");
Description = _T("CCD 主机的IP 地址,用来和电脑通信");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_IPAddrStr, Description);
pGroup1->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
pGroup->AddSubItem(pGroup1);
return pGroup;
}
void CCameraKeyence::ExportPar(ofstream *pFile)
{
CCamera::ExportPar(pFile);
(*pFile)<<"[模块] [CCameraKeyence]------------------------------------------------"<<endl;
(*pFile)<<"[CCD 主机IP 地址][m_IPAddrStr] = "<<m_IPAddrStr<<endl;
}
//返回视场中心
Dbxy CCameraKeyence::GetCoord()
{
Dbxy pt;
pt.x = m_Coord.x + m_Size.w/2;
pt.y = m_Coord.y - m_Size.h/2;
return pt;
}
#endif
#if 1
bool CCameraKeyence::CatchPoint(Dbxy &pt)
{
if(gSocketMgr->Connect(m_IPAddrStr,8500))
{
gSocketMgr->Send("T1\r",strlen("T1\r")+1);
Sleep(SEND_MASSAGE_TO_CCD_DELAYE_TIME);
char recvBuf[100];//返回结果
gSocketMgr->Receive(recvBuf,sizeof(recvBuf));
CString str = recvBuf;
gLogMgr->WriteDebugLog(str);
gSocketMgr->Close();
//提取CCD 返回结果中的数值
double arr[20];
if(GetNumFromRecvBuf(recvBuf,arr))
{
Dbxy CCDpt(arr[0],arr[1]);
if(IsDbxyZero(CCDpt))
return false;
return true;
}
}
return false;
}
//提取CCD 返回结果中的数值
BOOL CCameraKeyence::GetNumFromRecvBuf(char* recvBuf,double *arr)
{
CString Str = recvBuf;
int CommaPosPer;//第一个逗号的位置
CommaPosPer = Str.Find(",",0);
if(CommaPosPer == -1)//没找到直接返回
{
return FALSE;
}
int idx = 0;
int CommaPosNext = CommaPosPer;
do
{
CommaPosNext = Str.Find(",",CommaPosPer+1);//下一个逗号的位置
if(CommaPosNext==-1)//最后一个
{
CString Str1(recvBuf+CommaPosPer+1);
arr[idx] = atof(Str1);
}
else
{
CString Str1(recvBuf+CommaPosPer+1,CommaPosNext-CommaPosPer);
arr[idx] = atof(Str1);
}
CommaPosPer = CommaPosNext;
idx++;
}while(CommaPosNext!=-1);
//未检测到mark 点
if((Str[0]!= 'T' && Str[1]!='1'))
{
return FALSE;
}
else
{
return TRUE;
}
}
#endif
#if 1
//打开CCD 光源
void CCameraKeyence::OpenCCDLight()
{
if(gSocketMgr->Connect(m_IPAddrStr,8500))
{
gSocketMgr->Send("CLV,2,100\r",strlen("CLV,1,100\r")+1);
Sleep(SEND_MASSAGE_TO_CCD_DELAYE_TIME);
gSocketMgr->Close();
}
}
//关闭CCD 光源
void CCameraKeyence::CloseCCDLight()
{
if(gSocketMgr->Connect(m_IPAddrStr,8500))
{
gSocketMgr->Send("CLV,2,0\r",strlen("CLV,1,0\r")+1);
Sleep(SEND_MASSAGE_TO_CCD_DELAYE_TIME);
gSocketMgr->Close();
}
}
//切换CCD 的场景"PW," & CStr(sd) & "," & nnn & Chr(13) & Chr(10)
void CCameraKeyence::ChangeCCDScene()
{
#if 0
CGraphSoftView* pView= m_pView;
if(pView->GetDocument()->m_CurrOpenFileName=="")
return;
DEBUG_LOG_START
pView->m_DebugLogFile<< "Function :[ChangeCCDScene][自动切换CCD 场景]"<<endl;
DEBUG_LOG_END
pView->m_CommunicationManager.SocketConnect();
CString str1 = "PW,1,";
CString str2 = str1 + pView->GetDocument()->m_CurrOpenFileName+"\r";
pView->m_CommunicationManager.m_SocketClient.Send(str2,str2.GetLength()+1,0);
DEBUG_LOG_START
pView->m_DebugLogFile<< "发送命令: "<<str2<<endl;
DEBUG_LOG_END
Sleep(SEND_MASSAGE_TO_CCD_DELAYE_TIME);
pView->m_CommunicationManager.SocketClose();
#endif
}
//切换当前显示的CCD 画面idx(1~4) 为0 表示显示全部
bool CCameraKeyence::ChangeCCDScreen(int idx)
{
if(gSocketMgr->Connect(m_IPAddrStr,8500))
{
if(idx == 1)
{
gLogMgr->WriteDebugLog("ChangeCCDScreen id = 1");
gSocketMgr->Send("VW,0,1\r",strlen("VW,0,1\r")+1);
}
if(idx == 2)
{
gLogMgr->WriteDebugLog("ChangeCCDScreen id = 2");
gSocketMgr->Send("VW,0,2\r",strlen("VW,0,1\r")+1);
}
Sleep(SEND_MASSAGE_TO_CCD_DELAYE_TIME);
char recvBuf[100];//返回结果
gSocketMgr->Receive(recvBuf,sizeof(recvBuf));
CString str = recvBuf;
gLogMgr->WriteDebugLog(str);
gSocketMgr->Close();
}
return true;
}
#endif

@ -0,0 +1,25 @@
#pragma once
#include "Camera.h"
//基恩士CCD 的管理类
class CCameraKeyence:public CCamera
{
public:
CCameraKeyence(void);
~CCameraKeyence(void);
virtual CMFCPropertyGridProperty *CreatGridProperty();
virtual MODULE GetModuleType(){return _KEYENCE_CCD_PROP;};
virtual void ExportPar(ofstream *pFile);
virtual bool CatchPoint(Dbxy &pt);
virtual Dbxy GetCoord();
void OpenCCDLight();
void CloseCCDLight();
void ChangeCCDScene();
BOOL GetNumFromRecvBuf(char* recvBuf,double *arr);
bool ChangeCCDScreen(int idx);
private:
CString m_IPAddrStr;//CCD 主机的IP地址
};
extern CCameraKeyence *gCameraKeyence;

@ -0,0 +1,301 @@
#include "StdAfx.h"
#include "CatchMgr.h"
#include "GlobalDrawMgr.h"
#include "GlobalFunction.h"
#include "LogMgr.h"
#include "DrawSimpleShape.h"
#include "ObjComponentMgr.h"
#include "MouseToolmgr.h"
CCatchMgr gCatchMgr;//捕捉管理
CCatchMgr::CCatchMgr()
{
ResetCatchNode();
}
CCatchMgr::~CCatchMgr(void)
{
}
#if 1//捕捉基础函数
void CCatchMgr::DrawCatchPoint(CCatchPoint CatchPt,CDC* pDC)
{
if(m_CatchPointVec.empty())
{
ResetCatchPoint(pDC);
}
else
{
//擦除之前的
if(!CatchPt.Equal(m_CatchNode))
{
ResetCatchPoint(pDC);
}
if(!CatchPt.Equal(m_CatchNode))
{
DrawCatchPointExt(CatchPt,pDC);
//保存当前的捕获
m_CatchNode = CatchPt;
}
}
}
void CCatchMgr::DrawCatchPointExt(CCatchPoint pt,CDC* pDC)
{
DbRect NodeRect(pt,gDraw->GetCatchNodeSize());
switch(pt.GetType())
{
case _CATCH_NODE:
DrawRect(pDC,gDraw->GetCatchNodePen(),NodeRect);
break;
case _CATCH_INTERSECT:
case _CATCH_ORTHO:
case _CATCH_CUT_TRACK:
XorDrawCrossX(pDC,gDraw->GetCatchNodePen(),NodeRect);
break;
default:
break;
}
}
void CCatchMgr::ResetCatchNode()
{
m_CatchNode.x = -10000.123456;
m_CatchNode.y = -10000.123456;
}
void CCatchMgr::ResetCatchPoint(CDC* pDC)
{
if(HasCatchPoint())
{
//擦除之前的
DrawCatchPointExt(m_CatchNode,pDC);
}
//重置坐标
ResetCatchNode();
}
bool CCatchMgr::HasCatchPoint()
{
if(m_CatchNode.x == -10000.123456)
{
return false;
}
return true;
}
bool CCatchMgr::GetCatchPoint(CPoint &pt)
{
if(HasCatchPoint())
{
pt = gDraw->Dbxy2CPoint(m_CatchNode);
return true;
}
return false;
}
//获取离鼠标最近的捕获点
CCatchPoint CCatchMgr::GetNearestCatchPt(Dbxy pt)
{
CCatchPoint CatchPt;
double MinDis;
vector<CCatchPoint>::iterator iter = m_CatchPointVec.begin();
vector<CCatchPoint>::iterator iter_end = m_CatchPointVec.end();
for(;iter!=iter_end;iter++)
{
double dis = CalDistance(pt,(*iter));
if(iter == m_CatchPointVec.begin())
{
MinDis = dis;
CatchPt = (*iter);
}
else if(dis<MinDis)
{
MinDis = dis;
CatchPt = (*iter);
}
}
return CatchPt;
}
#endif
#if 1//每种捕捉对应的函数
//捕获pt 附近的点
void CCatchMgr::Catch(Dbxy DownPt,Dbxy pt,CDC* pDC,bool bCatchTemp)
{
//先清空捕获点容器
m_CatchPointVec.clear();
m_DataPtLineVec.clear();
//获得鼠标为中心的捕获矩形rect
DbRect rect = gDraw->GetCurCatchRect(pt);
//收集rect 范围内所有的线段
GetLineInRect(rect,bCatchTemp);
//捕获rect 范围内的node 节点
CatchNode(rect);
//捕获rect 范围内线段的交点
CatchIntersectPointOfLines(rect);
//捕获鼠标rect 和线段的交点
CatchIntersectPointWithMouse(rect);
//捕获正交点
CatchOrthoPoint(DownPt,pt,rect);
//捕捉元件对象切割道的交点用于指定mark 点
CatchCutTrack(rect);
//选择离鼠标最近的点为捕获点
CCatchPoint CatchPt;
if(!m_CatchPointVec.empty())
{
CatchPt = GetNearestCatchPt(pt);
}
//绘制捕获点
DrawCatchPoint(CatchPt,pDC);
}
//收集rect 范围内所有的线段
void CCatchMgr::GetLineInRect(DbRect &rect,bool bCatchTemp)
{
GetLayerInstance().GetLineInRect(rect,m_DataPtLineVec,bCatchTemp);
}
//收集rect 范围内的节点
void CCatchMgr::CatchNode(DbRect rect)
{
if(gDraw->IsCatchObjNode()== false)
return;
//优先级控制
if(!m_CatchPointVec.empty())
return;
//检查线段的端点是否在矩形内即可
vector<DbLine>::iterator iter = m_DataPtLineVec.begin();
vector<DbLine>::iterator iter_end = m_DataPtLineVec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).m_pt1.IsNode())
{
Dbxy pt = (*iter).m_pt1.GetPt();
if(IsPointInRect(pt,rect))
{
CCatchPoint CatchPoint(pt.x,pt.y,_CATCH_NODE);
m_CatchPointVec.push_back(CatchPoint);
}
}
if((*iter).m_pt2.IsNode())
{
Dbxy pt = (*iter).m_pt2.GetPt();
if(IsPointInRect(pt,rect))
{
CCatchPoint CatchPoint(pt.x,pt.y,_CATCH_NODE);
m_CatchPointVec.push_back(CatchPoint);
}
}
}
}
//收集rect 范围内的线段交点
void CCatchMgr::CatchIntersectPointOfLines(DbRect rect)
{
if(gDraw->IsCatchCrossPoint()== false)
return;
//优先级控制
if(!m_CatchPointVec.empty())
return;
int size = m_DataPtLineVec.size();
for(int i=0;i<size;i++)
{
DbLine &line1 = m_DataPtLineVec[i];
for(int j=i+1;j<size;j++)
{
DbLine &line2 = m_DataPtLineVec[j];
//连续线段的交点不算
if(line1.IsSerialLine(line2))
{
continue;
}
//先判断是否相交
if(IsTwoLineIntersect(line1.m_pt1.GetPt(),line1.m_pt2.GetPt(),line2.m_pt1.GetPt(),line2.m_pt2.GetPt()))
{
//如果相交求出交点
Dbxy pt = CalIntersection(line1.m_pt1.GetPt(),line1.m_pt2.GetPt(),line2.m_pt1.GetPt(),line2.m_pt2.GetPt());
//交点在rect 内则加入捕捉点
if(IsPointInRect(pt,rect))
{
CCatchPoint CatchPoint(pt.x,pt.y,_CATCH_INTERSECT);
m_CatchPointVec.push_back(CatchPoint);
}
}
}
}
}
//捕获线段和鼠标的交点
void CCatchMgr::CatchIntersectPointWithMouse(DbRect rect)
{
if(gDraw->IsCatchObjLine()== false)
return;
//优先级控制
if(!m_CatchPointVec.empty())
return;
vector<DbLine>::iterator iter = m_DataPtLineVec.begin();
vector<DbLine>::iterator iter_end = m_DataPtLineVec.end();
for(;iter!=iter_end;iter++)
{
Dbxy LinePt1 = (*iter).m_pt1.GetPt();
Dbxy LinePt2 = (*iter).m_pt2.GetPt();
if(IsPointInRect(LinePt1,rect)||IsPointInRect(LinePt2,rect))//不要捕捉端点的部分
{
break;
}
Dbxy pt = IntersectionOfRectAndLine(LinePt1,LinePt2,rect);
CCatchPoint CatchPoint(pt.x,pt.y,_CATCH_INTERSECT);
m_CatchPointVec.push_back(CatchPoint);
}
}
//捕获正交点
void CCatchMgr::CatchOrthoPoint(Dbxy DownPt,Dbxy MousePt,DbRect rect)
{
if(gDraw->IsCatchOrthoPoint()== false)
return;
//优先级控制
if(!m_CatchPointVec.empty())
return;
DbSize size = rect.GetSize();
if(abs(MousePt.x-DownPt.x)<=size.w/2)
{
CCatchPoint CatchPoint(DownPt.x,MousePt.y,_CATCH_ORTHO);
m_CatchPointVec.push_back(CatchPoint);
}
else if(abs(MousePt.y-DownPt.y)<=size.h/2)
{
CCatchPoint CatchPoint(MousePt.x,DownPt.y,_CATCH_ORTHO);
m_CatchPointVec.push_back(CatchPoint);
}
}
//捕捉元件对象切割道的交点用于指定mark 点
void CCatchMgr::CatchCutTrack(DbRect rect)
{
if(gDraw->IsCatchCutTrack()== false)
return;
//优先级控制
if(!m_CatchPointVec.empty())
return;
//只有在测量的时候才捕捉
MOUSE_TOOL tool = gMouseToolMgr.GetToolType();
if(tool == _TOOL_MEASURE)
{
vector<CObjComponent>&vec = gObjComponentMgr->GetComponentVec();
Dbxy pt = rect.GetCenterPt();
double MinDis = 0;//最近的距离
int MinIdx = -1;
int size = vec.size();
for(int i=0;i<size;i++)
{
double CurDis = CalDistance(pt,vec[i].GetBasePt());
if(CurDis <= vec[i].GetSize().w)
{
if(MinDis == 0 || CurDis<MinDis)
{
MinIdx = i;
MinDis = CurDis;
}
}
}
if(MinIdx != -1)
{
Dbxy pt = vec[MinIdx].GetBasePt();
CCatchPoint CatchPoint(pt.x,pt.y,_CATCH_CUT_TRACK);
m_CatchPointVec.push_back(CatchPoint);
}
}
}
#endif

@ -0,0 +1,34 @@
#pragma once
#include "GlobalDefine.h"
#include "ObjBase.h"
#include "SmartPtr.h"
//鼠标捕捉管理
class CCatchMgr
{
public:
CCatchMgr(void);
~CCatchMgr(void);
void Clear();
void Catch(Dbxy DownPt,Dbxy pt,CDC* pDC,bool bCatchTemp);
void ResetCatchPoint(CDC* pDC);
bool GetCatchPoint(CPoint &pt);
private:
void CatchNode(DbRect rect);
void CatchIntersectPointOfLines(DbRect rect);
void CatchIntersectPointWithMouse(DbRect rect);
void ResetCatchNode();
bool HasCatchPoint();
void DrawCatchPoint(CCatchPoint pt,CDC* pDC);
void DrawCatchPointExt(CCatchPoint pt,CDC* pDC);
CCatchPoint GetNearestCatchPt(Dbxy pt);
void GetLineInRect(DbRect &rect,bool bCatchTemp);
void CatchOrthoPoint(Dbxy DownPt,Dbxy MousePt,DbRect rect);
void CatchCutTrack(DbRect rect);
private:
vector<DbLine> m_DataPtLineVec;//保存rect 范围内所有的线段
vector<CCatchPoint> m_CatchPointVec;//在鼠标范围内的捕获点的容器
CCatchPoint m_CatchNode;//之前抓取的点
};
extern CCatchMgr gCatchMgr;

@ -0,0 +1,66 @@
// ChildFrm.cpp : CChildFrame 类的实现
//
#include "stdafx.h"
#include "LaiPuLaser.h"
#include "ChildFrm.h"
#include "GlobalDrawMgr.h"
#include "LogMgr.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CChildFrame
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWndEx)
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWndEx)
ON_WM_SYSCOMMAND()
END_MESSAGE_MAP()
// CChildFrame 构造/析构
CChildFrame::CChildFrame()
{
// TODO: 在此添加成员初始化代码
}
CChildFrame::~CChildFrame()
{
}
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或样式
if( !CMDIChildWndEx::PreCreateWindow(cs) )
return FALSE;
cs.style |= WS_MAXIMIZE;
return TRUE;
}
// CChildFrame 诊断
#ifdef _DEBUG
void CChildFrame::AssertValid() const
{
CMDIChildWndEx::AssertValid();
}
void CChildFrame::Dump(CDumpContext& dc) const
{
CMDIChildWndEx::Dump(dc);
}
#endif //_DEBUG
// CChildFrame 消息处理程序
void CChildFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID == SC_CLOSE)
return;
CMDIChildWndEx::OnSysCommand(nID, lParam);
}

@ -0,0 +1,34 @@
// ChildFrm.h : CChildFrame 类的接口
//
#pragma once
class CChildFrame : public CMDIChildWndEx
{
DECLARE_DYNCREATE(CChildFrame)
public:
CChildFrame();
// 特性
public:
// 操作
public:
// 重写
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
// 实现
public:
virtual ~CChildFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// 生成的消息映射函数
protected:
afx_msg void OnSysCommand( UINT nID, LPARAM lParam );
DECLARE_MESSAGE_MAP()
};

@ -0,0 +1,689 @@
/*
Comm Base Library(WIN98/NT/2000) ver 1.1
Compile by BC++ 5; C++ Builder 4, 5, 6, X; VC++ 5, 6; VC.net; GCC;
copyright(c) 2004.5 - 2005.8 llbird wushaojian@21cn.com
*/
#ifndef _CN_COMM_H_
#define _CN_COMM_H_
#pragma warning(disable: 4530)
#pragma warning(disable: 4786)
#pragma warning(disable: 4800)
//屏蔽编译警告
#pragma warning(disable : 4244)
#pragma warning(disable : 4305)
#pragma warning(disable : 4996)
#pragma warning(disable : 4101)
#include <assert.h>
#include <stdio.h>
#include <Windows.h>
//第三方的串口类: 提供了通用的窗口操作
/*
cnComm com;
1.使
com.Open();
2.
com.Write(m_send);//m_send为发送的字符串
3.()
ON_COM_RECEIVE
afx_msg void OnCommRecv(WPARAM wParam, LPARAM lParam);
ON_MESSAGE(ON_COM_RECEIVE,OnCommRecv)
com.SetWnd(AfxGetMainWnd()->m_hWnd);
void CSerialPortClassDlg::OnCommRecv(WPARAM wParam, LPARAM lParam)
{
 //读取串口上的字符
 char str[100];
 com.ReadString(str, 100);
}
*/
//送到窗口的消息 WPARAM 端口号
#define ON_COM_RECEIVE WM_USER + 618
#define ON_COM_CTS WM_USER + 619 //LPARAM 1 valid
#define ON_COM_DSR WM_USER + 621 //LPARAM 1 valid
#define ON_COM_RING WM_USER + 623
#define ON_COM_RLSD WM_USER + 624
#define ON_COM_BREAK WM_USER + 625
#define ON_COM_TXEMPTY WM_USER + 626
#define ON_COM_ERROR WM_USER + 627 //LPARAM save Error ID
#define DEFAULT_COM_MASK_EVENT EV_RXCHAR | EV_ERR | EV_CTS | EV_DSR | EV_BREAK | EV_TXEMPTY | EV_RING | EV_RLSD
class cnComm
{
public:
//------------------------------Construction-----------------------------------
//第1个参数为是否在打开串口时启动监视线程 第2个参数为IO方式 阻塞方式0/ 异步重叠方式(默认)
cnComm(bool fAutoBeginThread = true, DWORD dwIOMode = FILE_FLAG_OVERLAPPED): _dwIOMode(dwIOMode), _fAutoBeginThread(fAutoBeginThread)
{
Init();
}
virtual ~cnComm()
{
Close();
UnInit();
}
//----------------------------------Attributes----------------------------------
//判断串口是否打开
inline bool IsOpen()
{
return _hCommHandle != INVALID_HANDLE_VALUE;
}
//判断串口是否打开
operator bool()
{
return _hCommHandle != INVALID_HANDLE_VALUE;
}
//获得串口句炳
inline HANDLE GetHandle()
{
return _hCommHandle;
}
//获得串口句炳
operator HANDLE()
{
return _hCommHandle;
}
//获得串口参数 DCB
DCB *GetState()
{
return IsOpen() && ::GetCommState(_hCommHandle, &_DCB) == TRUE ?
&_DCB: NULL;
}
//设置串口参数 DCB
bool SetState(DCB *pdcb = NULL)
{
return IsOpen() ? ::SetCommState(_hCommHandle, pdcb == NULL ? &_DCB:pdcb) == TRUE: false;
}
//设置串口参数:波特率,停止位,等 支持设置字符串 "9600, 8, n, 1"
bool SetState(char *szSetStr)
{
if (IsOpen())
{
if (::GetCommState(_hCommHandle, &_DCB) != TRUE)
return false;
if (::BuildCommDCB(szSetStr, &_DCB) != TRUE)
return false;
return ::SetCommState(_hCommHandle, &_DCB) == TRUE;
}
return false;
}
//设置串口参数:波特率,停止位,等
bool SetState(DWORD dwBaudRate, DWORD dwByteSize = 8, DWORD dwParity = NOPARITY, DWORD dwStopBits = ONESTOPBIT)
{
if (IsOpen())
{
if (::GetCommState(_hCommHandle, &_DCB) != TRUE)
return false;
_DCB.BaudRate = dwBaudRate;
_DCB.ByteSize = (unsigned char)dwByteSize;
_DCB.Parity = (unsigned char)dwParity;
_DCB.StopBits = (unsigned char)dwStopBits;
return ::SetCommState(_hCommHandle, &_DCB) == TRUE;
}
return false;
}
//获得超时结构
LPCOMMTIMEOUTS GetTimeouts(void)
{
return IsOpen() && ::GetCommTimeouts(_hCommHandle, &_CO) == TRUE ? &_CO: NULL;
}
//设置超时
bool SetTimeouts(LPCOMMTIMEOUTS lpCO)
{
return IsOpen() ? ::SetCommTimeouts(_hCommHandle, lpCO) == TRUE:false;
}
//设置串口的I/O缓冲区大小
bool SetBufferSize(DWORD dwInputSize, DWORD dwOutputSize)
{
return IsOpen() ? ::SetupComm(_hCommHandle, dwInputSize, dwOutputSize)== TRUE: false;
}
//关联消息的窗口句柄
inline void SetWnd(HWND hWnd)
{
assert(::IsWindow(hWnd));
_hNotifyWnd = hWnd;
}
//设定发送通知, 接受字符最小值
inline void SetNotifyNum(DWORD dwNum)
{
_dwNotifyNum = dwNum;
}
//线程是否运行
inline bool IsThreadRunning()
{
return _hThreadHandle != NULL;
}
//获得线程句柄
inline HANDLE GetThread()
{
return _hThreadHandle;
}
//设置要监视的事件, 打开前设置有效
void SetMaskEvent(DWORD dwEvent = DEFAULT_COM_MASK_EVENT)
{
_dwMaskEvent = dwEvent;
}
//获得读缓冲区的字符数
int GetInputSize()
{
COMSTAT Stat;
DWORD dwError;
return ::ClearCommError(_hCommHandle, &dwError, &Stat) == TRUE ? Stat.cbInQue : (DWORD) - 1L;
}
//----------------------------------Operations----------------------------------
//打开串口 缺省 9600, 8, n, 1
bool Open(DWORD dwPort)
{
return Open(dwPort, 9600);
}
//打开串口 缺省 baud_rate, 8, n, 1
bool Open(DWORD dwPort, DWORD dwBaudRate)
{
if (dwPort < 1 || dwPort > 1024)
return false;
BindCommPort(dwPort);
if (!OpenCommPort())
return false;
if (!SetupPort())
return false;
return SetState(dwBaudRate);
}
//打开串口, 使用类似"9600, 8, n, 1"的设置字符串设置串口
bool Open(DWORD dwPort, char *szSetStr)
{
if (dwPort < 1 || dwPort > 1024)
return false;
BindCommPort(dwPort);
if (!OpenCommPort())
return false;
if (!SetupPort())
return false;
return SetState(szSetStr);
}
//读取串口 dwBufferLength个字符到 Buffer 返回实际读到的字符数 可读任意数据
DWORD Read(LPVOID Buffer, DWORD dwBufferLength, DWORD dwWaitTime = 10)
{
if (!IsOpen())
return 0;
COMSTAT Stat;
DWORD dwError;
if (::ClearCommError(_hCommHandle, &dwError, &Stat) && dwError > 0)
{
::PurgeComm(_hCommHandle,PURGE_RXABORT | PURGE_RXCLEAR);
return 0;
}
if (!Stat.cbInQue)
// 缓冲区无数据
return 0;
unsigned long uReadLength = 0;
dwBufferLength = dwBufferLength > Stat.cbInQue ? Stat.cbInQue :dwBufferLength;
if (!::ReadFile(_hCommHandle, Buffer, dwBufferLength, &uReadLength,&_ReadOverlapped))
{
if (::GetLastError() == ERROR_IO_PENDING)
{
WaitForSingleObject(_ReadOverlapped.hEvent, dwWaitTime);
// 结束异步I/O
if (!::GetOverlappedResult(_hCommHandle, &_ReadOverlapped,&uReadLength, false))
{
if (::GetLastError() != ERROR_IO_INCOMPLETE)
uReadLength = 0;
}
}
else
uReadLength = 0;
}
return uReadLength;
}
//读取串口 dwBufferLength - 1 个字符到 szBuffer 返回ANSI C 模式字符串指针 适合一般字符通讯
char *ReadString(char *szBuffer, DWORD dwBufferLength, DWORD dwWaitTime =20)
{
unsigned long uReadLength = Read(szBuffer, dwBufferLength - 1,dwWaitTime);
szBuffer[uReadLength] = '\0';
return szBuffer;
}
//写串口 可写任意数据 "abcd" or "\x0\x1\x2"
DWORD Write(LPVOID Buffer, DWORD dwBufferLength)
{
if (!IsOpen())
return 0;
DWORD dwError;
if (::ClearCommError(_hCommHandle, &dwError, NULL) && dwError > 0)
::PurgeComm(_hCommHandle, PURGE_TXABORT | PURGE_TXCLEAR);
unsigned long uWriteLength = 0;
if (!::WriteFile(_hCommHandle, Buffer, dwBufferLength, &uWriteLength,&_WriteOverlapped))
if (::GetLastError() != ERROR_IO_PENDING)
uWriteLength = 0;
return uWriteLength;
}
//写串口 写ANSI C 模式字符串指针
DWORD Write(const char *szBuffer)
{
assert(szBuffer);
return Write((void*)szBuffer, strlen(szBuffer));
}
//读串口 同步应用
DWORD ReadSync(LPVOID Buffer, DWORD dwBufferLength)
{
if (!IsOpen())
return 0;
DWORD dwError;
if (::ClearCommError(_hCommHandle, &dwError, NULL) && dwError > 0)
{
::PurgeComm(_hCommHandle,PURGE_RXABORT | PURGE_RXCLEAR);
return 0;
}
DWORD uReadLength = 0;
::ReadFile(_hCommHandle, Buffer, dwBufferLength, &uReadLength, NULL);
return uReadLength;
}
//写串口 同步应用
DWORD WriteSync(LPVOID Buffer, DWORD dwBufferLength)
{
if (!IsOpen())
return 0;
DWORD dwError;
if (::ClearCommError(_hCommHandle, &dwError, NULL) && dwError > 0)
::PurgeComm(_hCommHandle, PURGE_TXABORT | PURGE_TXCLEAR);
unsigned long uWriteLength = 0;
::WriteFile(_hCommHandle, Buffer, dwBufferLength, &uWriteLength, NULL);
return uWriteLength;
}
//写串口 szBuffer 可以输出格式字符串 包含缓冲区长度
DWORD Write(char *szBuffer, DWORD dwBufferLength, char *szFormat, ...)
{
if (!IsOpen())
return 0;
va_list va;
va_start(va, szFormat);
_vsnprintf(szBuffer, dwBufferLength, szFormat, va);
va_end(va);
return Write(szBuffer);
}
//写串口 szBuffer 可以输出格式字符串 不检查缓冲区长度 小心溢出
DWORD Write(char *szBuffer, char *szFormat, ...)
{
if (!IsOpen())
return 0;
va_list va;
va_start(va, szFormat);
vsprintf(szBuffer, szFormat, va);
va_end(va);
return Write(szBuffer);
}
//关闭串口 同时也关闭关联线程
virtual void Close()
{
if (IsOpen())
{
PurgeComm(_hCommHandle, PURGE_TXABORT | PURGE_TXCLEAR);
EndThread();
::CloseHandle(_hCommHandle);
_hCommHandle = INVALID_HANDLE_VALUE;
}
}
//DTR 电平控制
bool SetDTR(bool OnOrOff)
{
return IsOpen() ? EscapeCommFunction(_hCommHandle, OnOrOff ? SETDTR :CLRDTR): false;
}
//RTS 电平控制
bool SetRTS(bool OnOrOff)
{
return IsOpen() ? EscapeCommFunction(_hCommHandle, OnOrOff ? SETRTS :CLRRTS): false;
}
//
bool SetBreak(bool OnOrOff)
{
return IsOpen() ? EscapeCommFunction(_hCommHandle, OnOrOff ? SETBREAK: CLRBREAK): false;
}
//辅助线程控制 建监视线程
bool BeginThread()
{
if (!IsThreadRunning())
{
_fRunFlag = true;
_hThreadHandle = NULL;
DWORD id;
_hThreadHandle = ::CreateThread(NULL, 0, CommThreadProc, this, 0,&id);
return (_hThreadHandle != NULL);
}
return false;
}
//暂停监视线程
inline bool SuspendThread()
{
return IsThreadRunning() ? ::SuspendThread(_hThreadHandle) !=0xFFFFFFFF: false;
}
//恢复监视线程
inline bool ResumeThread()
{
return IsThreadRunning() ? ::ResumeThread(_hThreadHandle) !=0xFFFFFFFF: false;
}
//终止线程
bool EndThread(DWORD dwWaitTime = 100)
{
if (IsThreadRunning())
{
_fRunFlag = false;
::SetCommMask(_hCommHandle, 0);
::SetEvent(_WaitOverlapped.hEvent);
if (::WaitForSingleObject(_hThreadHandle, dwWaitTime) !=WAIT_OBJECT_0)
if (!::TerminateThread(_hThreadHandle, 0))
return false;
::CloseHandle(_hThreadHandle);
::ResetEvent(_WaitOverlapped.hEvent);
_hThreadHandle = NULL;
return true;
}
return false;
}
protected:
volatile DWORD _dwPort; //串口号
volatile HANDLE _hCommHandle; //串口句柄
char _szCommStr[20]; //保存COM1类似的字符串
DCB _DCB; //波特率,停止位,等
COMMTIMEOUTS _CO; //超时结构
DWORD _dwIOMode; // 0 同步 默认 FILE_FLAG_OVERLAPPED重叠I/O异步
OVERLAPPED _ReadOverlapped, _WriteOverlapped; // 重叠I/O
volatile HANDLE _hThreadHandle; //辅助线程
volatile HWND _hNotifyWnd; // 通知窗口
volatile DWORD _dwNotifyNum; //接受多少字节(>=_dwNotifyNum)发送通知消息
volatile DWORD _dwMaskEvent; //监视的事件
volatile bool _fRunFlag; //线程运行循环标志
bool _fAutoBeginThread; //Open() 自动 BeginThread();
OVERLAPPED _WaitOverlapped; //WaitCommEvent use
//初始化
void Init()
{
memset(_szCommStr, 0, 20);
memset(&_DCB, 0, sizeof(_DCB));
_DCB.DCBlength = sizeof(_DCB);
_hCommHandle = INVALID_HANDLE_VALUE;
memset(&_ReadOverlapped, 0, sizeof(_ReadOverlapped));
memset(&_WriteOverlapped, 0, sizeof(_WriteOverlapped));
_ReadOverlapped.hEvent = ::CreateEvent(NULL, true, false, NULL);
assert(_ReadOverlapped.hEvent != INVALID_HANDLE_VALUE);
_WriteOverlapped.hEvent = ::CreateEvent(NULL, true, false, NULL);
assert(_WriteOverlapped.hEvent != INVALID_HANDLE_VALUE);
_hNotifyWnd = NULL;
_dwNotifyNum = 0;
_dwMaskEvent = DEFAULT_COM_MASK_EVENT;
_hThreadHandle = NULL;
memset(&_WaitOverlapped, 0, sizeof(_WaitOverlapped));
_WaitOverlapped.hEvent = ::CreateEvent(NULL, true, false, NULL);
assert(_WaitOverlapped.hEvent != INVALID_HANDLE_VALUE);
}
//析构
void UnInit()
{
if (_ReadOverlapped.hEvent != INVALID_HANDLE_VALUE)
CloseHandle(_ReadOverlapped.hEvent);
if (_WriteOverlapped.hEvent != INVALID_HANDLE_VALUE)
CloseHandle(_WriteOverlapped.hEvent);
if (_WaitOverlapped.hEvent != INVALID_HANDLE_VALUE)
CloseHandle(_WaitOverlapped.hEvent);
}
//绑定串口
void BindCommPort(DWORD dwPort)
{
assert(dwPort >= 1 && dwPort <= 1024);
char p[5];
_dwPort = dwPort;
strcpy(_szCommStr, "\\\\.\\COM");
ltoa(_dwPort, p, 10);
strcat(_szCommStr, p);
}
//打开串口
virtual bool OpenCommPort()
{
if (IsOpen())
Close();
_hCommHandle = ::CreateFile(_szCommStr, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | _dwIOMode,NULL);
if (_fAutoBeginThread)
{
if (IsOpen() && BeginThread())
return true;
else
{
Close(); //创建线程失败
return false;
}
}
return IsOpen();
}
//设置串口
virtual bool SetupPort()
{
if (!IsOpen())
return false;
if (!::SetupComm(_hCommHandle, 4096, 4096))
return false;
if (!::GetCommTimeouts(_hCommHandle, &_CO))
return false;
_CO.ReadIntervalTimeout = 0;
_CO.ReadTotalTimeoutMultiplier = 1;
_CO.ReadTotalTimeoutConstant = 1000;
_CO.WriteTotalTimeoutMultiplier = 1;
_CO.WriteTotalTimeoutConstant = 1000;
if (!::SetCommTimeouts(_hCommHandle, &_CO))
return false;
if (!::PurgeComm(_hCommHandle, PURGE_TXABORT | PURGE_RXABORT |PURGE_TXCLEAR | PURGE_RXCLEAR))
return false;
return true;
}
//---------------------------------------threads callback-----------------------------------
//线程收到消息自动调用, 如窗口句柄有效, 送出消息, 包含串口编号, 均为虚函数可以在基层类中扩展
virtual void OnReceive() //EV_RXCHAR
{
if (::IsWindow(_hNotifyWnd))
::PostMessage(_hNotifyWnd, ON_COM_RECEIVE, WPARAM(_dwPort), LPARAM (0));
}
virtual void OnDSR()
{
if (::IsWindow(_hNotifyWnd))
{
DWORD Status;
if (GetCommModemStatus(_hCommHandle, &Status))
::PostMessage(_hNotifyWnd, ON_COM_DSR, WPARAM(_dwPort),LPARAM((Status &MS_DSR_ON) ? 1 : 0));
}
}
virtual void OnCTS()
{
if (::IsWindow(_hNotifyWnd))
{
DWORD Status;
if (GetCommModemStatus(_hCommHandle, &Status))
::PostMessage(_hNotifyWnd, ON_COM_CTS, WPARAM(_dwPort), LPARAM( (Status &MS_CTS_ON) ? 1 : 0));
}
}
virtual void OnBreak()
{
if (::IsWindow(_hNotifyWnd))
{
::PostMessage(_hNotifyWnd, ON_COM_BREAK, WPARAM(_dwPort), LPARAM(0));
}
}
virtual void OnTXEmpty()
{
if (::IsWindow(_hNotifyWnd))
::PostMessage(_hNotifyWnd, ON_COM_TXEMPTY, WPARAM(_dwPort), LPARAM (0));
}
virtual void OnError()
{
DWORD dwError;
::ClearCommError(_hCommHandle, &dwError, NULL);
if (::IsWindow(_hNotifyWnd))
::PostMessage(_hNotifyWnd, ON_COM_ERROR, WPARAM(_dwPort), LPARAM (dwError));
}
virtual void OnRing()
{
if (::IsWindow(_hNotifyWnd))
::PostMessage(_hNotifyWnd, ON_COM_RING, WPARAM(_dwPort), LPARAM(0));
}
virtual void OnRLSD()
{
if (::IsWindow(_hNotifyWnd))
::PostMessage(_hNotifyWnd, ON_COM_RLSD, WPARAM(_dwPort), LPARAM(0));
}
virtual DWORD ThreadFunc()
{
if (!::SetCommMask(_hCommHandle, _dwMaskEvent))
{
char szBuffer[256];
_snprintf(szBuffer, 255,
"%s(%d) : COM%d Call WINAPI SetCommMask(%x, %x) Fail, thread work invalid! GetLastError() = %d;", __FILE__, __LINE__, _dwPort, _hCommHandle, _dwMaskEvent, GetLastError());
MessageBox(NULL, szBuffer, "Class cnComm", MB_OK);
return 1;
}
COMSTAT Stat;
DWORD dwError;
for (DWORD dwLength, dwMask = 0; _fRunFlag && IsOpen(); dwMask = 0)
{
if (!::WaitCommEvent(_hCommHandle, &dwMask, &_WaitOverlapped))
{
if (::GetLastError() == ERROR_IO_PENDING)
// asynchronous
::GetOverlappedResult(_hCommHandle, &_WaitOverlapped,&dwLength, TRUE);
else
continue;
}
if (dwMask == 0)
continue;
switch (dwMask)
{
case EV_RXCHAR:
::ClearCommError(_hCommHandle, &dwError, &Stat);
if (Stat.cbInQue >= _dwNotifyNum)
OnReceive();
break;
case EV_TXEMPTY:
OnTXEmpty();
break;
case EV_CTS:
OnCTS();
break;
case EV_DSR:
OnDSR();
break;
case EV_RING:
OnRing();
break;
case EV_RLSD:
OnRLSD();
break;
case EV_BREAK:
OnBreak();
break;
case EV_ERR:
OnError();
break;
} //case
} //for
return 0;
}
private:
//the function protected
cnComm(const cnComm &);
cnComm &operator = (const cnComm &);
//base function for thread
static DWORD WINAPI CommThreadProc(LPVOID lpPara)
{
return ((cnComm*)lpPara)->ThreadFunc();
}
};
#endif //_CN_COMM_H_

@ -0,0 +1,138 @@
#include "StdAfx.h"
#include "CommPortMgr.h"
#include "LogMgr.h"
CCommPortMgr::CCommPortMgr(void)
{
}
CCommPortMgr::~CCommPortMgr(void)
{
}
//打开com 口(dwBaudRate 是波特率)
bool CCommPortMgr::Open(DWORD dwPort, DWORD dwBaudRate)
{
if(IsOpen())//打开状态直接返回
return true;
CString str = "Function :[CCommPortMgr::Open][打开com 口]";
gLogMgr->WriteDebugLog(str);
CString str1;
str1.Format("%ld",dwPort);
str = "Result :[com 口<"+str1+">打开]";
bool ret;
if(m_Com.Open(dwPort,dwBaudRate) == false)
{
gLogMgr->WriteDebugLog(str,_LOG_ERROR);
ret = false;
}
else
{
str += "[OK]";
gLogMgr->WriteDebugLog(str);
ret = true;
}
return ret;
}
//打开串口, 使用类似"9600, n, 8, 1"的设置字符串设置串口
bool CCommPortMgr::Open(DWORD dwPort, char *szSetStr)
{
CString str = "Function :[CCommPortMgr::Open][打开com 口]";
//gLogMgr->WriteDebugLog(str);
CString str1;
str1.Format("%ld",dwPort);
str = "Result :[com 口<"+str1+">打开]";
bool ret;
if(m_Com.Open(dwPort,szSetStr) == false)
{
//gLogMgr->WriteDebugLog(str,_LOG_ERROR);
ret = false;
}
else
{
str += "[OK]";
//gLogMgr->WriteDebugLog(str);
ret = true;
}
return ret;
}
//绑定串口消息的窗口ID
void CCommPortMgr::SetWnd(HWND hWnd)
{
CString str = "Function :[SetWnd][绑定串口消息的响应窗口ID]";
gLogMgr->WriteDebugLog(str);
m_Com.SetWnd(hWnd);
}
//读取串口消息到szBuffer
CString CCommPortMgr::ReadBuf(char *szBuffer,DWORD dwBufferLength)
{
CString str = "Function :[ReadString][读取串口消息]";
//gLogMgr->WriteDebugLog(str);
m_Com.ReadString(szBuffer,dwBufferLength);
return str;
}
CString CCommPortMgr::ReadStr()
{
CString str = "Function :[ReadString][读取串口消息]";
gLogMgr->WriteDebugLog(str);
const int dwBufferLength = 500;
char szBuffer[dwBufferLength];
memset(szBuffer,'0',dwBufferLength);
m_Com.ReadString(szBuffer,dwBufferLength);
//转化为CString
str = szBuffer;
//gLogMgr->WriteDebugLog(str);
return str;
}
int CCommPortMgr::Read(LPVOID Buffer, DWORD dwBufferLength)
{
//CString str = "Function :[ReadString][读取串口消息]";
//gLogMgr->WriteDebugLog(str);
return m_Com.Read(Buffer,dwBufferLength);
}
//发送消息到串口
void CCommPortMgr::Write(const char *szBuffer)
{
//CString str = "Function :[Write][发送消息到串口]";
//gLogMgr->WriteDebugLog(str+szBuffer);
m_Com.Write(szBuffer);
}
void CCommPortMgr::WriteBuf(LPVOID Buffer, DWORD dwBufferLength)
{
//CString str = "Function :[Write][发送消息到串口]";
//gLogMgr->WriteDebugLog(str);
m_Com.Write(Buffer,dwBufferLength);
}
//关闭串口
void CCommPortMgr::Close()
{
CString str = "Function :[Close][关闭串口]";
gLogMgr->WriteDebugLog(str);
m_Com.Close();
}
void CCommPortMgr::SetBufferSize(DWORD dwInputSize, DWORD dwOutputSize)
{
m_Com.SetBufferSize(dwInputSize,dwOutputSize);
}
int CCommPortMgr::GetInputSize()
{
gLogMgr->WriteDebugLog("BufferSize","",m_Com.GetInputSize());
return 0;
}

@ -0,0 +1,24 @@
#pragma once
#include "CommPortClass.h"
//对第三方com 再封装一次
class CCommPortMgr
{
public:
CCommPortMgr(void);
~CCommPortMgr(void);
bool Open(DWORD dwPort, DWORD dwBaudRate = 9600);
bool Open(DWORD dwPort, char *szSetStr);
void Close();
void SetWnd(HWND hWnd);
void Write(const char *szBuffer);
void WriteBuf(LPVOID Buffer, DWORD dwBufferLength);
CString ReadStr();
CString ReadBuf(char *szBuffer,DWORD dwBufferLength);
int Read(LPVOID Buffer, DWORD dwBufferLength);
bool IsOpen(){return m_Com.IsOpen();};
void SetBufferSize(DWORD dwInputSize, DWORD dwOutputSize);
int GetInputSize();
private:
cnComm m_Com;//PLC 串口管理对象
};

@ -0,0 +1,49 @@
#include "StdAfx.h"
#include "CommandAddNode.h"
CCommandAddNode::CCommandAddNode(void)
{
}
CCommandAddNode::~CCommandAddNode(void)
{
}
void CCommandAddNode::ExcuteExt()
{
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
(*iter)->InsertNode(m_idx,m_pt);
}
}
}
void CCommandAddNode::UndoExt()
{
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
(*iter)->DelNodePtByIdx(m_idx);
}
}
}
CString CCommandAddNode::GetStr()
{
CString str = "_add_node Ìí¼Ó½Úµã-----";
return str;
}
void CCommandAddNode::SetPar(int idx,Dbxy pt)
{
m_idx = idx;
m_pt = pt;
}

@ -0,0 +1,17 @@
#pragma once
#include "commandbase.h"
//添加节点
class CCommandAddNode :public CCommandBase
{
public:
CCommandAddNode(void);
~CCommandAddNode(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
void SetPar(int idx,Dbxy pt);
private:
int m_idx;//节点的索引值
Dbxy m_pt;//节点的坐标
};

@ -0,0 +1,47 @@
#include "StdAfx.h"
#include "CommandArray.h"
#include "Layer.h"
#include "GlobalFunction.h"
CCommandArray::CCommandArray(void)
{
}
CCommandArray::~CCommandArray(void)
{
}
void CCommandArray::ExcuteExt()
{
CLayer &layer = GetLayerInstance();
//先删除阵列基准obj
layer.DelObj(m_BaseObjContainer);
//再导入阵列对象
layer.AddObject(m_ObjContainer);
}
void CCommandArray::UndoExt()
{
CLayer &layer = GetLayerInstance();
//删除阵列对象
layer.DelObj(m_ObjContainer);
//导入基准对象
layer.AddObject(m_BaseObjContainer);
}
CString CCommandArray::GetStr()
{
CString str = "_array 阵列-----";
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
if(vec.size()>1)
{
CString str1;
str1.Format("%ld",vec.size());
str +="[数量] : <"+str1+">";
}
return str;
};
//保存基准obj
void CCommandArray::SaveBaseObj(CObjContainer &ObjContainer)
{
ObjContainer.AllObjAddToContainer(m_BaseObjContainer,true);
}

@ -0,0 +1,16 @@
#pragma once
#include "commandbase.h"
class CCommandArray :
public CCommandBase
{
public:
CCommandArray(void);
~CCommandArray(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
void SaveBaseObj(CObjContainer &ObjContainer);
private:
CObjContainer m_BaseObjContainer;//基准对象的容器
};

@ -0,0 +1,36 @@
#include "StdAfx.h"
#include "CommandBase.h"
#include "EasyOperationMgr.h"
CCommandBase::CCommandBase(void)
{
}
CCommandBase::~CCommandBase(void)
{
}
//添加操作对象
void CCommandBase::AddOpObj(Sptr<CObjBase> p)
{
m_ObjContainer.AddObject(p);
}
void CCommandBase::AddOpObj(CObjBase *p)
{
//保存到智能指针
Sptr<CObjBase> sPtr(p);
AddOpObj(sPtr);
}
//是否有操作对象
bool CCommandBase::HasOpObj()
{
return !m_ObjContainer.Empty();
}
void CCommandBase::Excute()
{
ExcuteExt();
gEasyOperationMgr->Refresh();
}
void CCommandBase::Undo()
{
UndoExt();
gEasyOperationMgr->Refresh();
}

@ -0,0 +1,25 @@
#pragma once
#include "GlobalDefine.h"
#include "SmartPtr.h"
#include "ObjContainer.h"
#include "ObjBase.h"
class CCommandBase
{
public:
CCommandBase(void);
virtual ~CCommandBase(void);
virtual CString GetStr() = 0;
virtual void ExcuteExt(){};
virtual void UndoExt(){};
void Excute();
void Undo();
void AddOpObj(CObjBase *p);
void AddOpObj(Sptr<CObjBase>);
bool HasOpObj();
void SetOperatePar(SObjOperatePar par){m_Par = par;};
protected:
CObjContainer m_ObjContainer;//obj 对象容器管理对象
SObjOperatePar m_Par;//操作参数
};

@ -0,0 +1,67 @@
#include "StdAfx.h"
#include "CommandBreakNode.h"
#include "Layer.h"
#include "GlobalFunction.h"
CCommandBreakNode::CCommandBreakNode(void)
{
}
CCommandBreakNode::~CCommandBreakNode(void)
{
}
//第一个是打断之前的obj
void CCommandBreakNode::ExcuteExt()
{
CLayer &layer = GetLayerInstance();
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
(*iter)->SetSelected(true);
if((*iter).IsNull()==false)
{
if(iter == vec.begin())
{
layer.DelObj((*iter));
}
else
{
layer.AddObject((*iter));
}
}
}
}
}
void CCommandBreakNode::UndoExt()
{
CLayer &layer = GetLayerInstance();
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
(*iter)->SetSelected(true);
if(iter == vec.begin())
{
layer.AddObject((*iter));
}
else
{
layer.DelObj((*iter));
}
}
}
}
CString CCommandBreakNode::GetStr()
{
CString str = "_break 打断节点-----";
return str;
}

@ -0,0 +1,12 @@
#pragma once
#include "commandbase.h"
class CCommandBreakNode :public CCommandBase
{
public:
CCommandBreakNode(void);
~CCommandBreakNode(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
};

@ -0,0 +1,37 @@
#include "StdAfx.h"
#include "CommandCopy.h"
#include "Layer.h"
#include "GlobalFunction.h"
CCommandCopy::CCommandCopy(void)
{
}
CCommandCopy::~CCommandCopy(void)
{
}
void CCommandCopy::ExcuteExt()
{
CLayer &layer = GetLayerInstance();
layer.AddObject(m_ObjContainer);
}
void CCommandCopy::UndoExt()
{
CLayer &layer = GetLayerInstance();
layer.DelObj(m_ObjContainer);
}
CString CCommandCopy::GetStr()
{
CString str = "_copy ¸´ÖÆ-----";
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
if(vec.size()>1)
{
CString str1;
str1.Format("%ld",vec.size());
str +="[ÊýÁ¿] : <"+str1+">";
}
return str;
};

@ -0,0 +1,13 @@
#pragma once
#include "commandbase.h"
class CCommandCopy :
public CCommandBase
{
public:
CCommandCopy(void);
~CCommandCopy(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
};

@ -0,0 +1,47 @@
#include "StdAfx.h"
#include "CommandCreat.h"
#include "Layer.h"
#include "GlobalFunction.h"
CCommandCreat::CCommandCreat(void)
{
}
CCommandCreat::~CCommandCreat(void)
{
}
CString CCommandCreat::GetStr()
{
CString str = "_creat ´´½¨-----";
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
str += ((*iter)->GetStr()+" ");
break;
}
}
if(vec.size()>1)
{
CString str1;
str1.Format("%ld",vec.size());
str +="[ÊýÁ¿] : <"+str1+">";
}
return str;
};
void CCommandCreat::ExcuteExt()
{
CLayer &layer = GetLayerInstance();
layer.AddObject(m_ObjContainer);
}
void CCommandCreat::UndoExt()
{
CLayer &layer = GetLayerInstance();
layer.DelObj(m_ObjContainer);
}

@ -0,0 +1,12 @@
#pragma once
#include "CommandBase.h"
class CCommandCreat :public CCommandBase
{
public:
CCommandCreat(void);
~CCommandCreat(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
};

@ -0,0 +1,68 @@
#include "StdAfx.h"
#include "CommandCut.h"
#include "Layer.h"
#include "GlobalFunction.h"
CCommandCut::CCommandCut(void)
{
}
CCommandCut::~CCommandCut(void)
{
}
//m_ObjContainer 的第一个为剪切的obj
//剪切后的obj 可能为0~2 个
void CCommandCut::ExcuteExt()
{
CLayer &layer = GetLayerInstance();
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
(*iter)->SetSelected(false);
if((*iter).IsNull()==false)
{
if(iter == vec.begin())
{
layer.DelObj((*iter));
}
else
{
layer.AddObject((*iter));
}
}
}
}
}
void CCommandCut::UndoExt()
{
CLayer &layer = GetLayerInstance();
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
if(iter == vec.begin())
{
layer.AddObject((*iter));
}
else
{
layer.DelObj((*iter));
}
}
}
}
CString CCommandCut::GetStr()
{
CString str = "_cut 修剪-----";
return str;
}

@ -0,0 +1,12 @@
#pragma once
#include "commandbase.h"
class CCommandCut :public CCommandBase
{
public:
CCommandCut(void);
~CCommandCut(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
};

@ -0,0 +1,47 @@
#include "StdAfx.h"
#include "CommandDelNode.h"
CCommandDelNode::CCommandDelNode(void)
{
}
CCommandDelNode::~CCommandDelNode(void)
{
}
void CCommandDelNode::ExcuteExt()
{
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
(*iter)->DelNodePtByIdx(m_idx);
}
}
}
void CCommandDelNode::UndoExt()
{
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
(*iter)->InsertNode(m_idx,m_pt);
}
}
}
CString CCommandDelNode::GetStr()
{
CString str = "_del_node ɾ³ý½Úµã-----";
return str;
}
void CCommandDelNode::SetPar(int idx,Dbxy pt)
{
m_idx = idx;
m_pt = pt;
}

@ -0,0 +1,16 @@
#pragma once
#include "commandbase.h"
class CCommandDelNode :public CCommandBase
{
public:
CCommandDelNode(void);
~CCommandDelNode(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
void SetPar(int idx,Dbxy pt);
private:
int m_idx;
Dbxy m_pt;
};

@ -0,0 +1,38 @@
#include "StdAfx.h"
#include "CommandDelete.h"
#include "Layer.h"
#include "GlobalFunction.h"
CCommandDelete::CCommandDelete(void)
{
}
CCommandDelete::~CCommandDelete(void)
{
}
void CCommandDelete::ExcuteExt()
{
CLayer &layer = GetLayerInstance();
layer.DelObj(m_ObjContainer);
}
void CCommandDelete::UndoExt()
{
CLayer &layer = GetLayerInstance();
layer.AddObject(m_ObjContainer);
}
CString CCommandDelete::GetStr()
{
CString str = "_erase ɾ³ý-----";
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
if(vec.empty()==false)
{
CString str1;
str1.Format("%ld",vec.size());
str +="[ÊýÁ¿] : <"+str1+">";
}
return str;
}

@ -0,0 +1,12 @@
#pragma once
#include "CommandBase.h"
class CCommandDelete :public CCommandBase
{
public:
CCommandDelete(void);
~CCommandDelete(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
};

@ -0,0 +1,68 @@
#include "StdAfx.h"
#include "CommandJion.h"
#include "Layer.h"
#include "GlobalFunction.h"
CCommandJion::CCommandJion(void)
{
}
CCommandJion::~CCommandJion(void)
{
}
//最后一个是合并后的obj
void CCommandJion::ExcuteExt()
{
CLayer &layer = GetLayerInstance();
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
(*iter)->SetSelected(true);
if((*iter).IsNull()==false)
{
if(iter == vec.end()-1)
{
layer.AddObject((*iter));
}
else
{
layer.DelObj((*iter));
}
}
}
}
}
void CCommandJion::UndoExt()
{
CLayer &layer = GetLayerInstance();
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
(*iter)->SetSelected(true);
if(iter == vec.end()-1)
{
layer.DelObj((*iter));
}
else
{
layer.AddObject((*iter));
}
}
}
}
CString CCommandJion::GetStr()
{
CString str = "_jion 合并-----";
return str;
}

@ -0,0 +1,13 @@
#pragma once
#include "commandbase.h"
//ºÏ²¢
class CCommandJion :public CCommandBase
{
public:
CCommandJion(void);
~CCommandJion(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
};

@ -0,0 +1,125 @@
#include "StdAfx.h"
#include "CommandMgr.h"
#include "LogMgr.h"
#include "GlobalFunction.h"
#define MAX_UNDO_CNT 100//最大撤销次数
CCommandMgr gCommandMgr;
CCommandMgr::CCommandMgr(void)
{
}
CCommandMgr::~CCommandMgr(void)
{
DelAllCmd();
}
void CCommandMgr::DelAllCmd()
{
m_UndoQueue.clear();
m_RedoQueue.clear();
}
//p 是指令特定的操作对象
void CCommandMgr::AddUndoCommand(CCommandBase *p)
{
vector<Sptr<CObjBase>> Vec;
AddUndoCommand(p,Vec);
}
void CCommandMgr::AddUndoCommand(CCommandBase *p,vector<Sptr<CObjBase>> &pMarkObjectVec)
{
if(p->HasOpObj()==false)
{
//加入指定的
if(pMarkObjectVec.empty()==false)
{
vector<Sptr<CObjBase>>::iterator iter = pMarkObjectVec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = pMarkObjectVec.end();
for(;iter!=iter_end;iter++)
{
p->AddOpObj((*iter));
}
}
else//没有指定就加入当前选择的obj
{
GetLayerInstance().GetObjContainer().AddObjToCmd(p,true);
}
}
if(p->HasOpObj()==false)//没有操作对象时不要添加指令
{
delete p;
return;
}
gCommandMgr.AddUndoCommandExt(p);
}
//添加指令
void CCommandMgr::AddUndoCommandExt(CCommandBase *p)
{
//------------------------------------日志start
CLog log;
log.AddCmdLog();
log.str = p->GetStr();
gLogMgr->WriteLog(log);
//------------------------------------日志end
//保存到智能指针
Sptr<CCommandBase> sPtr(p);
m_UndoQueue.push_back(sPtr);
if(m_UndoQueue.size()>MAX_UNDO_CNT)
{
m_UndoQueue.pop_front();
}
//之前的redo 全部清除
m_RedoQueue.clear();
}
bool CCommandMgr::HasUndoCmd()
{
return !m_UndoQueue.empty();
}
bool CCommandMgr::HasRedoCmd()
{
return !m_RedoQueue.empty();
}
void CCommandMgr::Undo()
{
if(!m_UndoQueue.empty())
{
Sptr<CCommandBase> p = m_UndoQueue[m_UndoQueue.size()-1];
p->Undo();
m_RedoQueue.push_back(p);
m_UndoQueue.pop_back();
//------------------------------------日志start
CLog log;
log.AddCmdLog();
{
CString str = p->GetStr();
log.str = "_undo 撤销"+str;
}
gLogMgr->WriteLog(log);
//------------------------------------日志end
}
}
void CCommandMgr::Redo()
{
if(!m_RedoQueue.empty())
{
Sptr<CCommandBase> p = m_RedoQueue[m_RedoQueue.size()-1];
p->Excute();
m_UndoQueue.push_back(p);
m_RedoQueue.pop_back();
//------------------------------------日志start
CLog log;
log.AddCmdLog();
{
CString str = p->GetStr();
log.str = "_redo 重做"+str;
}
gLogMgr->WriteLog(log);
//------------------------------------日志end
}
}
//重置回撤指令状态
void CCommandMgr::Reset()
{
m_UndoQueue.clear();
m_RedoQueue.clear();
}

@ -0,0 +1,26 @@
#pragma once
#include "CommandBase.h"
#include "GlobalDefine.h"
//³·ÏúÖ¸Áî¹ÜÀí
class CCommandMgr
{
public:
CCommandMgr(void);
~CCommandMgr(void);
void AddUndoCommand(CCommandBase *p);
void AddUndoCommand(CCommandBase *p,vector<Sptr<CObjBase>> &pMarkObjectVec);
void AddUndoCommandExt(CCommandBase *p);
bool HasUndoCmd();
bool HasRedoCmd();
void Undo();
void Redo();
void Reset();
void DelAllCmd();
private:
deque<Sptr<CCommandBase>> m_UndoQueue;
deque<Sptr<CCommandBase>> m_RedoQueue;
};
extern CCommandMgr gCommandMgr;

@ -0,0 +1,19 @@
#include "StdAfx.h"
#include "CommandMirror.h"
CCommandMirror::CCommandMirror(void)
{
}
CCommandMirror::~CCommandMirror(void)
{
}
void CCommandMirror::ExcuteExt()
{
m_ObjContainer.OperateObj(m_Par,false);
}
void CCommandMirror::UndoExt()
{
m_ObjContainer.OperateObj(m_Par,false);
}

@ -0,0 +1,12 @@
#pragma once
#include "CommandBase.h"
class CCommandMirror :public CCommandBase
{
public:
CCommandMirror(void);
~CCommandMirror(void);
virtual CString GetStr(){return "¾µÏñ";};
virtual void ExcuteExt();
virtual void UndoExt();
};

@ -0,0 +1,48 @@
#include "StdAfx.h"
#include "CommandModifiCircle.h"
#include "ObjCircle.h"
CCommandModifiCircle::CCommandModifiCircle(void)
{
}
CCommandModifiCircle::~CCommandModifiCircle(void)
{
}
//b 为true 时设置旧参数
void CCommandModifiCircle::SetPar(double Radius,int EdgeCnt,bool b)
{
if(b)
{
m_OldRadius = Radius;//半径
m_OldEdgeCnt = EdgeCnt;//边数
}
else
{
m_Radius = Radius;//半径
m_EdgeCnt = EdgeCnt;//边数
}
}
void CCommandModifiCircle::ExcuteExt()
{
ReCreatObj(true);
}
void CCommandModifiCircle::UndoExt()
{
ReCreatObj(false);
}
void CCommandModifiCircle::ReCreatObj(bool bExcute)
{
CObjBase *pBase = m_ObjContainer.GetCurOpObj();
if(pBase)
{
CObjCircle *p = dynamic_cast<CObjCircle*>(pBase);
if(bExcute)
{
p->ReCreat(m_Radius,m_EdgeCnt);
}
else
{
p->ReCreat(m_OldRadius,m_OldEdgeCnt);
}
}
}

@ -0,0 +1,24 @@
#pragma once
#include "commandbase.h"
//修改圆
class CCommandModifiCircle :
public CCommandBase
{
public:
CCommandModifiCircle(void);
~CCommandModifiCircle(void);
virtual CString GetStr(){return "修改circle";};
virtual void ExcuteExt();
virtual void UndoExt();
void SetPar(double Radius,int EdgeCnt,bool b);
private:
void ReCreatObj(bool bExcute);
private:
double m_OldRadius;//半径
int m_OldEdgeCnt;//边数
double m_Radius;//半径
int m_EdgeCnt;//边数
};

@ -0,0 +1,31 @@
#include "StdAfx.h"
#include "CommandModifiFill.h"
CCommandModifiFill::CCommandModifiFill(void)
{
}
CCommandModifiFill::~CCommandModifiFill(void)
{
}
//b 为true 时设置旧参数
void CCommandModifiFill::SetPar(SFillPar par,bool b)
{
if(b)
{
m_OldPar = par;
}
else
{
m_NewPar = par;
}
}
void CCommandModifiFill::ExcuteExt()
{
m_ObjContainer.FillObj(m_NewPar,false);
}
void CCommandModifiFill::UndoExt()
{
m_ObjContainer.FillObj(m_OldPar,false);
}

@ -0,0 +1,20 @@
#pragma once
#include "commandbase.h"
#include "SFillPar.h"
//填充
class CCommandModifiFill :public CCommandBase
{
public:
CCommandModifiFill(void);
~CCommandModifiFill(void);
virtual CString GetStr(){return "修改fill";};
virtual void ExcuteExt();
virtual void UndoExt();
void SetPar(SFillPar par,bool b);
private:
//字体参数
SFillPar m_OldPar;
SFillPar m_NewPar;
};

@ -0,0 +1,49 @@
#include "StdAfx.h"
#include "CommandModifiFont.h"
#include "ObjTxt.h"
CCommandModifiFont::CCommandModifiFont(void)
{
}
CCommandModifiFont::~CCommandModifiFont(void)
{
}
//b Ϊtrue ʱÉèÖþɲÎÊý
void CCommandModifiFont::SetStringPar(SFontPar &par,bool b)
{
if(b)
{
m_OldFontPar = par;
}
else
{
m_NewFontPar = par;
}
}
void CCommandModifiFont::ExcuteExt()
{
ReCreatObj(true);
}
void CCommandModifiFont::UndoExt()
{
ReCreatObj(false);
}
void CCommandModifiFont::ReCreatObj(bool bExcute)
{
CObjBase *pBase = m_ObjContainer.GetCurOpObj();
if(pBase)
{
CObjTxt *p = dynamic_cast<CObjTxt*>(pBase);
if(bExcute)
{
p->SetFontPar(m_NewFontPar);
}
else
{
p->SetFontPar(m_OldFontPar);
}
p->Creat();
}
}

@ -0,0 +1,21 @@
#pragma once
#include "commandbase.h"
#include "SFontPar.h"
class CCommandModifiFont :public CCommandBase
{
public:
CCommandModifiFont(void);
~CCommandModifiFont(void);
virtual CString GetStr(){return "修改font";};
virtual void ExcuteExt();
virtual void UndoExt();
void SetStringPar(SFontPar &par,bool b);
private:
void ReCreatObj(bool bExcute);
private:
//字体参数
SFontPar m_OldFontPar;
SFontPar m_NewFontPar;
};

@ -0,0 +1,55 @@
#include "StdAfx.h"
#include "CommandModifiString.h"
#include "ObjTxt.h"
CCommandModifiString::CCommandModifiString()
{
}
CCommandModifiString::~CCommandModifiString(void)
{
}
//b 为true 时设置旧参数
void CCommandModifiString::SetStringPar(SStringPar &par,bool b)
{
if(b)
{
m_OldStringPar.Copy(par);
}
else
{
m_NewStringPar.Copy(par);
}
}
void CCommandModifiString::ExcuteExt()
{
ReCreatObj(true);
}
void CCommandModifiString::UndoExt()
{
ReCreatObj(false);
}
void CCommandModifiString::ReCreatObj(bool bExcute)
{
CObjBase *pBase = m_ObjContainer.GetCurOpObj();
if(pBase)
{
CObjString *p = dynamic_cast<CObjString*>(pBase);
if(bExcute)
{
//可变文本
p->SetValStr(m_NewStringPar.m_ValString);
//字体
p->SetFontTypeName(m_NewStringPar.m_FontTypeName);
p->SetFontName(m_NewStringPar.m_FontName);
}
else
{
//可变文本
p->SetValStr(m_OldStringPar.m_ValString);
//字体
p->SetFontTypeName(m_OldStringPar.m_FontTypeName);
p->SetFontName(m_OldStringPar.m_FontName);
}
p->Creat();
}
}

@ -0,0 +1,21 @@
#pragma once
#include "commandbase.h"
#include "SStringPar.h"
//修改合成对象
class CCommandModifiString :public CCommandBase
{
public:
CCommandModifiString();
~CCommandModifiString(void);
virtual CString GetStr(){return "修改string";};
virtual void ExcuteExt();
virtual void UndoExt();
void SetStringPar(SStringPar &par,bool b);
private:
void ReCreatObj(bool bExcute);
private:
SStringPar m_OldStringPar;
SStringPar m_NewStringPar;
};

@ -0,0 +1,32 @@
#include "StdAfx.h"
#include "CommandMove.h"
CCommandMove::CCommandMove(void)
{
}
CCommandMove::~CCommandMove(void)
{
}
CString CCommandMove::GetStr()
{
CString str1 = "_move ÒÆ¶¯--------[¾àÀëx ] : <";
CString str2;
str2.Format("%lf",m_Par.MoveX);
CString str3 = "> [¾àÀëy ] : <";
CString str4;
str4.Format("%lf",m_Par.MoveY);
CString str5 = ">";
return str1+str2+str3+str4+str5;
}
void CCommandMove::ExcuteExt()
{
m_ObjContainer.OperateObj(m_Par,false);
}
void CCommandMove::UndoExt()
{
//·´ÏòÒÆ¶¯
SObjOperatePar par = m_Par;
par.MoveX = par.MoveX*(-1);
par.MoveY = par.MoveY*(-1);
m_ObjContainer.OperateObj(par,false);
}

@ -0,0 +1,13 @@
#pragma once
#include "CommandBase.h"
class CCommandMove :public CCommandBase
{
public:
CCommandMove(void);
~CCommandMove(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
};

@ -0,0 +1,44 @@
#include "StdAfx.h"
#include "CommandMoveNode.h"
CCommandMoveNode::CCommandMoveNode(void)
{
}
CCommandMoveNode::~CCommandMoveNode(void)
{
}
CString CCommandMoveNode::GetStr()
{
CString str = "_moveNode 移动节点";
return str;
}
void CCommandMoveNode::SetPar(int idx,Dbxy OldPt,Dbxy NewPt)
{
m_NodeIdx = idx;//操作node 节点的索引值
m_OldPt = OldPt;//旧的坐标
m_NewPt = NewPt;//新的坐标
}
void CCommandMoveNode::ExcuteExt()
{
SetNode(true);
}
void CCommandMoveNode::UndoExt()
{
SetNode(false);
}
void CCommandMoveNode::SetNode(bool bExcute)
{
CObjBase *pBase = m_ObjContainer.GetCurOpObj();
if(pBase)
{
if(bExcute)
{
pBase->SetNodePtByIdx(m_NodeIdx,m_NewPt);
}
else
{
pBase->SetNodePtByIdx(m_NodeIdx,m_OldPt);
}
}
}

@ -0,0 +1,19 @@
#pragma once
#include "commandbase.h"
class CCommandMoveNode :public CCommandBase
{
public:
CCommandMoveNode(void);
~CCommandMoveNode(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
void SetPar(int idx,Dbxy OldPt,Dbxy NewPt);
private:
void SetNode(bool bExcute);
private:
int m_NodeIdx;//操作node 节点的索引值
Dbxy m_OldPt;//旧的坐标
Dbxy m_NewPt;//新的坐标
};

@ -0,0 +1,45 @@
#include "StdAfx.h"
#include "CommandReverse.h"
#include "Layer.h"
#include "GlobalFunction.h"
CCommandReverse::CCommandReverse(void)
{
}
CCommandReverse::~CCommandReverse(void)
{
}
void CCommandReverse::ExcuteExt()
{
Operater();
}
void CCommandReverse::UndoExt()
{
Operater();
}
CString CCommandReverse::GetStr()
{
CString str = "_reverse ·´×ª½áµã˳Ðò-----";
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
if(vec.empty()==false)
{
CString str1;
str1.Format("%ld",vec.size());
str +="[¶ÔÏóÊýÁ¿] : <"+str1+">";
}
return str;
}
void CCommandReverse::Operater()
{
vector<Sptr<CObjBase>> &vec = m_ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
(*iter)->Operate(m_Par);
}
}
}

@ -0,0 +1,15 @@
#pragma once
#include "commandbase.h"
//反转节点顺序
class CCommandReverse :public CCommandBase
{
public:
CCommandReverse(void);
~CCommandReverse(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
private:
void Operater();
};

@ -0,0 +1,34 @@
#include "StdAfx.h"
#include "CommandRotato.h"
CCommandRotato::CCommandRotato(void)
{
}
CCommandRotato::~CCommandRotato(void)
{
}
CString CCommandRotato::GetStr()
{
CString str1 = "_rotato Ðýת-------- [½Ç¶È] : <";
double angle = m_Par.Angle;
if(angle>180)
{
angle = (360-angle)*(-1);
}
CString str2;
str2.Format("%lf",angle);
CString str3 = ">";
return str1+str2+str3;
}
void CCommandRotato::ExcuteExt()
{
m_ObjContainer.OperateObj(m_Par,false);
}
void CCommandRotato::UndoExt()
{
SObjOperatePar par = m_Par;
par.Angle = par.Angle*(-1);
m_ObjContainer.OperateObj(par,false);
}

@ -0,0 +1,12 @@
#pragma once
#include "CommandBase.h"
class CCommandRotato :public CCommandBase
{
public:
CCommandRotato(void);
~CCommandRotato(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
};

@ -0,0 +1,70 @@
#include "StdAfx.h"
#include "CommandStretch.h"
CCommandStretch::CCommandStretch(void)
{
m_bSetXY = false;//是否同时设置XY 方向
}
CCommandStretch::~CCommandStretch(void)
{
}
CString CCommandStretch::GetStr()
{
CString str1 = "_stretch 拉伸-------- [方向] : <";
CString str2;
if(m_Par.xy == _X)
str2 = "X> [旧尺寸] : <";
else
str2 = "Y> [旧尺寸] : <";
CString str3;
str3.Format("%lf",m_Par.OldSize);
CString str4 = "> [新尺寸] : <";
CString str5;
str5.Format("%lf",m_Par.NewSize);
CString str6 = ">";
return str1+str2+str3+str4+str5+str6;
};
void CCommandStretch::SetOperateParY(SObjOperatePar par)
{
m_bSetXY = true;//是否同时设置XY 方向
m_ParY = par;
};
void CCommandStretch::ExcuteExt()
{
if(m_bSetXY)
{
m_ObjContainer.OperateObj(m_Par,true);
m_ObjContainer.OperateObj(m_ParY,true);
}
else
{
m_ObjContainer.OperateObj(m_Par,true);
}
}
void CCommandStretch::UndoExt()
{
SObjOperatePar par = m_Par;
par.OpType = _OP_STRETCH;
par.BasePt = m_Par.BasePt;
par.OldSize = m_Par.NewSize;
par.Diff = m_Par.Diff*(-1);
par.xy = m_Par.xy;
SObjOperatePar parY = m_ParY;
parY.OpType = _OP_STRETCH;
parY.BasePt = m_ParY.BasePt;
parY.OldSize = m_ParY.NewSize;
parY.Diff = m_ParY.Diff*(-1);
parY.xy = m_ParY.xy;
if(m_bSetXY)
{
m_ObjContainer.OperateObj(par,true);
m_ObjContainer.OperateObj(parY,true);
}
else
{
m_ObjContainer.OperateObj(par,true);
}
}

@ -0,0 +1,16 @@
#pragma once
#include "commandBase.h"
class CCommandStretch :public CCommandBase
{
public:
CCommandStretch(void);
~CCommandStretch(void);
virtual CString GetStr();
virtual void ExcuteExt();
virtual void UndoExt();
void SetOperateParY(SObjOperatePar par);
private:
bool m_bSetXY;//是否同时设置XY 方向
SObjOperatePar m_ParY;//操作参数
};

File diff suppressed because it is too large Load Diff

@ -0,0 +1,123 @@
#pragma once
#include "module.h"
class CCamera;
class CProduct;
class CWorkCmdContainer;
//管理常用 的流程
class CCommonFlowMgr :public CModule
{
friend class DlgCutDeviceCtrl;
friend class CDlgSW_XL_Flow;
public:
CCommonFlowMgr(void);
~CCommonFlowMgr(void);
virtual CMFCPropertyGridProperty *CreatGridProperty();
virtual MODULE GetModuleType(){return _COMMON_FLOW_PROP;};
virtual void Ini();
virtual void WriteWorkFileExt(vector<CLab> &LabVec);
virtual void ReadWorkFile(CLabVecRang &LabVecRang);
bool InitDevice();
bool CameraCatchTwoMark();
bool MultipleAreaMark(CProduct &Product,bool bSel);
bool CutShapeByPlatform(CProduct &Product,bool bSel);
bool NormalMarkByPciCard(bool bSel,int times,int CyclicTimes);
bool CameraCatch();
bool AutoMeasureVisionData();
void MovePtToCamera(vector<Dbxy> &PtVec,vector<Dbxy> &ResultVec,bool bCatch);
void MovePtToCamera(Dbxy pt);
int GetAreaCycleCnt(){return m_AreaCycleCnt;};
void SetAreaCycleCnt(int n){m_AreaCycleCnt = n;};
int GetOneObjMarkCnt(){return m_OneObjMarkCnt;};
void SetOneObjMarkCnt(int val){m_OneObjMarkCnt = val;};
int GetSpecialOneObjMarkCnt(){return m_SpecialOneObjMarkCnt;};
void SetSpecialOneObjMarkCnt(int val){m_SpecialOneObjMarkCnt = val;};
int GetCutSpeed(){return m_CutSpeed;};
void SetCutSpeed(int val){m_CutSpeed = val;};
bool IsbConnectObj(){return m_bConnectObj;};
void MoveSelObjToCamera(CProduct &Product);
double GetFirstGap(){return m_FirstGap;};
Dbxy GetAdjustOffset(){return m_AdjustOffset;};
void SetAdjustOffset(Dbxy pt){m_AdjustOffset = pt;};
Dbxy GetAdjustOffsetAll(){return m_AdjustOffsetAll;};//获取治具2或4的振镜偏移
void SetAdjustOffsetAll(Dbxy Offset);//设置治具2或4的振镜偏移调用前已根据条件确定当前是2或是4
Dbxy GetAdjustSize(){return m_SizeAdjust;};
void SetAdjustSize(Dbxy s){m_SizeAdjust = s;};
double GetRotatoAdjust(){return m_RotatoAdjust;};
void SetRotatoAdjust(double val){m_RotatoAdjust = val;};
bool IsNoMarkCanWork(){return m_NoMarkCanWork;};
bool IsbWorkStop(){return m_bWorkStop;};
void SetbWorkStop(bool b){m_bWorkStop = b;};
void CameraCatchTwoMark(CProduct &Product);
void SetLightStateCmd(bool bStart);
bool StartWorkConfirm(bool bSelMark);
bool IsNeedExecAgain();
void ResetProductOffset();
void SetbCollectSpecialObj(bool b){m_bCollectSpecialObj = b;};
bool IsbCollectSpecialObj(){return m_bCollectSpecialObj;};
bool IsbStretchDataToRealSize(){return m_bStretchDataToRealSize;};
bool CameraCatchMark3(CProduct &Product);
void MarkAreaByIdx(int AreaIndex);//根据加工区域索引加工
private:
void SetLightStateCmd(CWorkCmdContainer &CmdContainer,bool bStart);
bool CameraCatchMarkExt(CProduct &Product);
void MoveToFirstArea();
private:
CCamera *m_CurCamera;//当前使用的相机
int m_AlamDelay;//报警延时(ms)
int m_FindOriginTimes;//自动回原点的加工次数(大于0 时生效)
int m_CurWorktimes;//当前的加工次数
int m_AllWorkExecTimes;//重复执行次数(用来拷机)
int m_CurWorkExecTimes;//当前执行次数(用来拷机)
bool m_bStartWorkMsg;//加工前提示
bool m_NoMarkCanWork;//没有定位点时也可以加工
bool m_bWorkStop;//工作是否停止
bool m_bVacuum;//是否使用真空吸附(加工前吸附,结束后放开)
bool m_bCheckObjDataConsistency;//是否检查数据的一致性(避免obj 数据不相等的情况)
//初始化相关参数-----------------------------------------------------
bool m_bIniConfirmMsgBox;//是否弹出初始化确认对话框
bool m_bIniPlatfrom;//是否初始化电机平台
bool m_bIniMotorX;//是否初始化电机X
bool m_bIniMotorY;//是否初始化电机Y
bool m_bIniMotorZ;//是否初始化电机Z
bool m_bInitedToProductPt;//初始化完成后是否返回上料点
//大幅面加工参数-------------------------------------------------------
//每个obj 的总加工次数= (m_FocalAdjustCnt-1)*m_AreaCycleCnt*m_OneObjMarkCnt
bool m_bFocalAdjust;//加工的时候是否实时调整焦距
double m_FocalAdjustDis;//变焦距离mm
int m_FocalAdjustCnt;//变焦次数(每变焦一次按照下面的参数加工一遍)
//产品相关的切割参数
int m_AreaCycleCnt;//每次一个workarea 的循环加工次数
int m_OneObjMarkCnt;//单个元件加工次数
int m_SpecialOneObjMarkCnt;//特殊刀增加的切割次数
bool m_bCollectSpecialObj;//是否正在收集特殊对象数据
int m_CutSpeed;//切割速度
Dbxy m_ProductOffset;//针对产品的切割偏移
bool m_bConnectObj;//是否连接多个obj 数据
bool m_bBackToProductPt;//加工完成后是否返回取料点
bool m_bSetLightState;//是否设置警示灯状态
int m_ConcentricCnt;//同心数据的数量
double m_FirstGap;//第一个拉伸尺寸
double m_ConcentricGap;//同心数据的间隔mm(大于0 向外)(小于0 向内)
Dbxy m_AdjustOffset;//偏移微调mm
Dbxy m_AdjustOffsetAll;//偏移微调mm (针对所有)
Dbxy m_SizeAdjust;//尺寸调整mm
double m_RotatoAdjust;//旋转调整mm
bool m_bStretchDataToRealSize;//根据抓取结果拉伸数据
//平台cut 参数--------------------------------------------------------------
bool m_bUseLaser;//是否开关激光
//振镜校准参数--------------------------------------------------------------
double m_CalibrationPointGap;//打点之间的间隔mm
double m_CalibrationRange;//振镜校准范围mm
};
extern CCommonFlowMgr *gCommonFlowMgr;

@ -0,0 +1,23 @@
#include "StdAfx.h"
#include "CreaterCatchMark.h"
#include "GlobalFunction.h"
#include "CameraKeyence.h"
#include "WorkCmdCameraCatch.h"
CCreaterCatchMark::CCreaterCatchMark(const CString &str)
:CCreaterWorkCmd(str)
{
}
CCreaterCatchMark::~CCreaterCatchMark(void)
{
}
void CCreaterCatchMark::Creat()
{
CCamera *pCamera = gCameraKeyence;
//ץȡmark µã
{
//CWorkCmdCameraCatch *pCmd = new CWorkCmdCameraCatch(*pCamera);
//AddCmd(pCmd);
}
}

@ -0,0 +1,14 @@
#pragma once
#include "createrworkcmd.h"
//创建抓取定位点的指令
class CCreaterCatchMark :public CCreaterWorkCmd
{
public:
CCreaterCatchMark(const CString &str);
~CCreaterCatchMark(void);
virtual void Creat();
private:
};

@ -0,0 +1,36 @@
#include "StdAfx.h"
#include "CreaterCatchMarkFlow.h"
#include "GlobalFunction.h"
#include "WorkCmdMovePlatformXY.h"
#include "CameraKeyence.h"
#include "WorkCmdCameraCatch.h"
#include "ProductMgr.h"
#include "ObjComponentMgr.h"
CCreaterCatchMarkFlow::CCreaterCatchMarkFlow(const CString &str)
:CCreaterWorkCmd(str)
{
}
CCreaterCatchMarkFlow::~CCreaterCatchMarkFlow(void)
{
}
void CCreaterCatchMarkFlow::Creat()
{
//×Ô¶¯ÅŲ¼Ê±²»Òª×¥È¡
if(gObjComponentMgr->IsAutoArray())
return;
vector<CProduct> &ProductVec = gProductMgr->GetProductVec();
vector<CProduct>::iterator iter = ProductVec.begin();
vector<CProduct>::iterator iter_end = ProductVec.end();
for(;iter!=iter_end;iter++)
{
CreatExt(*iter);
}
}
void CCreaterCatchMarkFlow::CreatExt(CProduct &Product)
{
}

@ -0,0 +1,15 @@
#pragma once
#include "createrworkcmd.h"
class CProduct;
//创建抓取定位点的流程
class CCreaterCatchMarkFlow :public CCreaterWorkCmd
{
public:
CCreaterCatchMarkFlow(const CString &str);
~CCreaterCatchMarkFlow(void);
virtual void Creat();
private:
void CreatExt(CProduct &Product);
};

@ -0,0 +1,75 @@
#include "StdAfx.h"
#include "CreaterCutFlow.h"
#include "GlobalFunction.h"
#include "MarkAreaMgr.h"
#include "WorkCmdMovePlatformXY.h"
#include "WorkCmdPciPortSwitch.h"
#include "Laser.h"
#include "PciPortMgr.h"
#define MARK_ALL "ALL"
#define MARK_SEL "SEL"
CCreaterCutFlow::CCreaterCutFlow(const CString &str)
:CCreaterWorkCmd(str)
{
}
CCreaterCutFlow::~CCreaterCutFlow(void)
{
}
//根据工作区域的数据来创建切割流程
void CCreaterCutFlow::Creat()
{
//参数1 表示是否全部加工
CString MarkType = GetPar(1);
//搜集工作数据-------------------------------------------------
if(MarkType == MARK_SEL)
CollectWorkData(true);
else
CollectWorkData(false);
//使用数据来创建工作流程
vector<CMarkArea> &AreaVec = gMarkAreaMgr->GetAreaVec();
vector<CMarkArea>::iterator iter = AreaVec.begin();
vector<CMarkArea>::iterator iter_end = AreaVec.end();
for(;iter!=iter_end;iter++)
{
vector<vector<Dbxy>> &Vec = (*iter).GetDataVec();
CreatExt(Vec);
}
}
void CCreaterCutFlow::CreatExt(vector<vector<Dbxy>> &Vec)
{
vector<vector<Dbxy>>::iterator iter = Vec.begin();
vector<vector<Dbxy>>::iterator iter_end = Vec.end();
for(int i=0;iter!=iter_end;i++,iter++)
{
vector<Dbxy>::iterator iter1 = (*iter).begin();
vector<Dbxy>::iterator iter1_end = (*iter).end();
for(;iter1!=iter1_end;iter1++)
{
//移动平台---------------------------------------------
{
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
pCmd->MoveToTargetPt((*iter1),gLaser->GetCoord());
if(iter1 != (*iter).begin())//移动到第一个点是空移
{
pCmd->InWorkState();//其他点是工作点
}
AddCmd(pCmd);
}
//开激光-------------------------------------------------
if(iter1==(*iter).begin())
{
CWorkCmd *pCmd = new CWorkCmdPciPortSwitch(PCI_PORT_LASER,true);
AddCmd(pCmd);
}
}
//关激光-------------------------------------------------
{
CWorkCmd *pCmd = new CWorkCmdPciPortSwitch(PCI_PORT_LASER,false);
pCmd->CanNotCancel();//不能取消
AddCmd(pCmd);
}
}
}

@ -0,0 +1,14 @@
#pragma once
#include "createrworkcmd.h"
//根据workarea 内的obj 数据来创建切割工作流程
class CCreaterCutFlow :public CCreaterWorkCmd
{
public:
CCreaterCutFlow(const CString &str);
~CCreaterCutFlow(void);
virtual void Creat();
private:
void CreatExt(vector<vector<Dbxy>> &Vec);
};

@ -0,0 +1,16 @@
#include "StdAfx.h"
#include "CreaterDeviceParReset.h"
#include "WorkCmdDeviceParReset.h"
CCreaterDeviceParReset::CCreaterDeviceParReset(const CString &str)
:CCreaterWorkCmd(str)
{
}
CCreaterDeviceParReset::~CCreaterDeviceParReset(void)
{
}
void CCreaterDeviceParReset::Creat()
{
CWorkCmd *pCmd = new CWorkCmdDeviceParReset;
AddCmd(pCmd);
}

@ -0,0 +1,12 @@
#pragma once
#include "createrworkcmd.h"
//设备参数复位
class CCreaterDeviceParReset :public CCreaterWorkCmd
{
public:
CCreaterDeviceParReset(const CString &str);
~CCreaterDeviceParReset(void);
virtual void Creat();
};

@ -0,0 +1,105 @@
#include "StdAfx.h"
#include "CreaterMarkFlow.h"
#include "GlobalFunction.h"
#include "MarkAreaMgr.h"
#include "WorkCmdMovePlatformXY.h"
#include "Laser.h"
#include "WorkCmdMarkArea.h"
#include "ProductMgr.h"
#include "Motor.h"
#include "WorkCmdMoveMotor.h"
#define MARK_ALL "ALL"
#define MARK_SEL "SEL"
CCreaterMarkFlow::CCreaterMarkFlow(const CString &str)
:CCreaterWorkCmd(str)
{
}
CCreaterMarkFlow::~CCreaterMarkFlow(void)
{
}
//根据工作区域的数据来创建
void CCreaterMarkFlow::Creat()
{
//参数1 表示是否全部加工
CString MarkType = GetPar(1);
bool bMarkSel = (MarkType == MARK_SEL);
vector<CProduct> &ProductVec = gProductMgr->GetProductVec();
vector<CProduct>::iterator iter = ProductVec.begin();
vector<CProduct>::iterator iter_end = ProductVec.end();
for(int i=0;iter!=iter_end;i++,iter++)
{
if((*iter).IsUsed())
{
//设置当前的工件,用来计算偏移旋转
gProductMgr->SetCurProductIdx(i);
CreatExt(bMarkSel);
}
#if 0
if(iter!=iter_end-1)//加工完一个先移动回原点
{
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
Dbxy MovePt;
Dbxy TargetPt;
pCmd->MoveToTargetPt(MovePt,TargetPt);
AddCmd(pCmd);
}
#endif
}
}
void CCreaterMarkFlow::CreatExt(bool bMarkSel)
{
//搜集工作数据-------------------------------------------------
CollectWorkData(bMarkSel);
//以area 的中心点转换数据-------------------------------
CMarkAreaMgr *MarkAreaMgr = gMarkAreaMgr;
//使用数据来创建工作流程----------------------------
vector<CMarkArea> &AreaVec = MarkAreaMgr->GetAreaVec();
vector<CMarkArea>::iterator iter = AreaVec.begin();
vector<CMarkArea>::iterator iter_end = AreaVec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).HasWorkData())
{
//移动area 实际中心点到振镜中心
{
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
// pCmd->MoveToTargetPt((*iter).GetRealBasePt(),gLaser->GetCoord());
pCmd->InWorkState();//工作速度
AddCmd(pCmd);
}
//变焦次数
int FocalAdjustCnt = gProductMgr->GetFocalAdjustCnt();
double FocalAdjustDis = gProductMgr->GetFocalAdjustDis();
for(int i=0;i<FocalAdjustCnt+1;++i)
{
//标刻当前area
{
CWorkCmdMarkArea *pCmd = new CWorkCmdMarkArea((*iter));
AddCmd(pCmd);
}
//变焦
if(FocalAdjustCnt>0 && !IsDbEqualZero(FocalAdjustDis) && i<FocalAdjustCnt)
{
CMotor &Motor = *(CMotor::GetMotor(MOTOR_Z));
CWorkCmdMoveMotor *pCmd = new CWorkCmdMoveMotor(Motor,FocalAdjustDis);
AddCmd(pCmd);
}
}
//焦距回调
if(FocalAdjustCnt>0 && !IsDbEqualZero(FocalAdjustDis))
{
for(int i=0;i<FocalAdjustCnt;i++)
{
CMotor &Motor = *(CMotor::GetMotor(MOTOR_Z));
CWorkCmdMoveMotor *pCmd = new CWorkCmdMoveMotor(Motor,FocalAdjustDis*(-1));
AddCmd(pCmd);
}
}
}
}
}

@ -0,0 +1,14 @@
#pragma once
#include "createrworkcmd.h"
//´´½¨Æ½Ãæ±ê¿ÌÁ÷³Ì
class CCreaterMarkFlow :public CCreaterWorkCmd
{
public:
CCreaterMarkFlow(const CString &str);
~CCreaterMarkFlow(void);
virtual void Creat();
private:
void CreatExt(bool bMarkSel);
};

@ -0,0 +1,16 @@
#include "StdAfx.h"
#include "CreaterMotorCheckLimit.h"
CCreaterMotorCheckLimit::CCreaterMotorCheckLimit(const CString &str)
:CCreaterWorkCmd(str)
{
}
CCreaterMotorCheckLimit::~CCreaterMotorCheckLimit(void)
{
}
void CCreaterMotorCheckLimit::Creat()
{
CWorkCmd *pCmd = NULL;
}

@ -0,0 +1,12 @@
#pragma once
#include "createrworkcmd.h"
//检查电机限位
class CCreaterMotorCheckLimit :public CCreaterWorkCmd
{
public:
CCreaterMotorCheckLimit(const CString &str);
~CCreaterMotorCheckLimit(void);
virtual void Creat();
};

@ -0,0 +1,19 @@
#include "StdAfx.h"
#include "CreaterMotorToMachineOrigin.h"
#include "WorkCmdMotorToMachineOrigin.h"
CCreaterMotorToMachineOrigin::CCreaterMotorToMachineOrigin(const CString &str)
:CCreaterWorkCmd(str)
{
}
CCreaterMotorToMachineOrigin::~CCreaterMotorToMachineOrigin(void)
{
}
void CCreaterMotorToMachineOrigin::Creat()
{
CWorkCmd *pCmd = NULL;
//参数1 表示那个电机
CString Motor = GetPar(1);
pCmd = new CWorkCmdMotorToMachineOrigin(*(CMotor::GetMotor(Motor)));
AddCmd(pCmd);
}

@ -0,0 +1,12 @@
#pragma once
#include "createrworkcmd.h"
//创建电机移动到机械原点的指令
class CCreaterMotorToMachineOrigin :public CCreaterWorkCmd
{
public:
CCreaterMotorToMachineOrigin(const CString &str);
~CCreaterMotorToMachineOrigin(void);
virtual void Creat();
};

@ -0,0 +1,25 @@
#include "StdAfx.h"
#include "CreaterMotorToOffsetPos.h"
#include "WorkCmdMotorToOffsetPos.h"
#include "Laser.h"
CCreaterMotorToOffsetPos::CCreaterMotorToOffsetPos(const CString &str)
:CCreaterWorkCmd(str)
{
}
CCreaterMotorToOffsetPos::~CCreaterMotorToOffsetPos(void)
{
}
void CCreaterMotorToOffsetPos::Creat()
{
CWorkCmdMotorToOffsetPos *pCmd = NULL;
//参数1 表示那个电机
CString Motor = GetPar(1);
pCmd = new CWorkCmdMotorToOffsetPos(*(CMotor::GetMotor(Motor)));
AddCmd(pCmd);
}

@ -0,0 +1,10 @@
#pragma once
#include "createrworkcmd.h"
class CCreaterMotorToOffsetPos :public CCreaterWorkCmd
{
public:
CCreaterMotorToOffsetPos(const CString &str);
~CCreaterMotorToOffsetPos(void);
virtual void Creat();
};

@ -0,0 +1,19 @@
#include "StdAfx.h"
#include "CreaterMsg.h"
#include "WorkCmdMsg.h"
CCreaterMsg::CCreaterMsg(const CString &str)
:CCreaterWorkCmd(str)
{
}
CCreaterMsg::~CCreaterMsg(void)
{
}
void CCreaterMsg::Creat()
{
//参数1 表示提示内容
CString msg = GetPar(1);
CWorkCmd *pCmd = NULL;
pCmd = new CWorkCmdMsg(msg);
AddCmd(pCmd);
}

@ -0,0 +1,14 @@
#pragma once
#include "createrworkcmd.h"
//创建提示信息
class CCreaterMsg :public CCreaterWorkCmd
{
public:
CCreaterMsg(const CString &str);
~CCreaterMsg(void);
virtual void Creat();
private:
};

@ -0,0 +1,30 @@
#include "StdAfx.h"
#include "CreaterPciPortCheck.h"
#include "WorkCmdPciPortCheck.h"
#include "GlobalFunction.h"
#include "CStringFuc.h"
CCreaterPciPortCheck::CCreaterPciPortCheck(const CString &str)
:CCreaterWorkCmd(str)
{
}
CCreaterPciPortCheck::~CCreaterPciPortCheck(void)
{
}
void CCreaterPciPortCheck::Creat()
{
//参数1 表示端口控制的内容
CString CtrlContent = GetPar(1);
//参数2 表示希望这个端口是开还是关
bool NeedState = Str2Bool(GetPar(2));
//最大检测时间
int MaxDelay = CStringToInt(GetPar(3));
CWorkCmdPciPortCheck *pCmd = new CWorkCmdPciPortCheck(CtrlContent,NeedState);
if(MaxDelay>0)
{
pCmd->SetMaxCheckDelay(MaxDelay);
}
AddCmd(pCmd);
}

@ -0,0 +1,10 @@
#pragma once
#include "createrworkcmd.h"
class CCreaterPciPortCheck :public CCreaterWorkCmd
{
public:
CCreaterPciPortCheck(const CString &str);
~CCreaterPciPortCheck(void);
virtual void Creat();
};

@ -0,0 +1,23 @@
#include "StdAfx.h"
#include "CreaterPciPortSwitch.h"
#include "WorkCmdPciPortSwitch.h"
#include "GlobalFunction.h"
#include "CStringFuc.h"
CCreaterPciPortSwitch::CCreaterPciPortSwitch(const CString &str)
:CCreaterWorkCmd(str)
{
}
CCreaterPciPortSwitch::~CCreaterPciPortSwitch(void)
{
}
void CCreaterPciPortSwitch::Creat()
{
//参数1 表示端口控制的内容
CString CtrlContent = GetPar(1);
//参数2 表示打开还是关闭
bool bOpen = Str2Bool(GetPar(2));
CWorkCmd *pCmd = NULL;
pCmd = new CWorkCmdPciPortSwitch(CtrlContent,bOpen);
AddCmd(pCmd);
}

@ -0,0 +1,10 @@
#pragma once
#include "createrworkcmd.h"
class CCreaterPciPortSwitch :public CCreaterWorkCmd
{
public:
CCreaterPciPortSwitch(const CString &str);
~CCreaterPciPortSwitch(void);
virtual void Creat();
};

@ -0,0 +1,48 @@
#include "StdAfx.h"
#include "CreaterPlatformMove.h"
#include "WorkCmdPciPortCheck.h"
#include "GlobalFunction.h"
#include "WorkCmdMovePlatformXY.h"
//移动到原点
#define TO_ORIGIN _T("TO_ORIGIN")
//移动到取料点
#define TO_WORK_PT _T("TO_WORK_PT")
CCreaterPlatformMove::CCreaterPlatformMove(const CString &str)
:CCreaterWorkCmd(str)
{
}
CCreaterPlatformMove::~CCreaterPlatformMove(void)
{
}
void CCreaterPlatformMove::Creat()
{
//参数1 表示端口控制的内容
CString MoveMode = GetPar(1);
if(MoveMode == TO_ORIGIN)//返回工作原点
{
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
Dbxy MovePt;
Dbxy TargetPt;
#ifdef __PROGRAM_SHILAN_TUIHUO__
pCmd->SetMoveOrder(2);//Y 轴先动
#endif
pCmd->MoveToTargetPt(MovePt,TargetPt);
AddCmd(pCmd);
}
else if(MoveMode == TO_WORK_PT)//取料点
{
CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY();
Dbxy MovePt;
Dbxy TargetPt(gPlatformXY->GetProductPoint());
#ifdef __LPS_IS3000__
pCmd->SetMoveOrder(2);//X 轴先动
#endif
pCmd->MoveToTargetPt(MovePt,TargetPt);
AddCmd(pCmd);
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save