| 
									
										
										
										
											2022-01-12 14:30:11 +08:00
										 |  |  |  | #pragma once
 | 
					
						
							|  |  |  |  | #include "pch.h"
 | 
					
						
							|  |  |  |  | #include "AbstractPort.h"
 | 
					
						
							|  |  |  |  | using namespace std; | 
					
						
							|  |  |  |  | // #ifdef IRIS_API_EXPORTS
 | 
					
						
							|  |  |  |  | // 
 | 
					
						
							|  |  |  |  | // #ifdef __cplusplus
 | 
					
						
							|  |  |  |  | // #define IRIS_API_FUNC extern "C" __declspec(dllexport)
 | 
					
						
							|  |  |  |  | // #else
 | 
					
						
							|  |  |  |  | // #define IRIS_API_FUNC __declspec(dllexport)
 | 
					
						
							|  |  |  |  | // #endif
 | 
					
						
							|  |  |  |  | // 
 | 
					
						
							|  |  |  |  | // #else
 | 
					
						
							|  |  |  |  | // 
 | 
					
						
							|  |  |  |  | // #ifdef __cplusplus
 | 
					
						
							|  |  |  |  | // #define IRIS_API_FUNC extern "C" __declspec(dllimport)
 | 
					
						
							|  |  |  |  | // #else
 | 
					
						
							|  |  |  |  | // #define IRIS_API_FUNC __declspec(dllimport)
 | 
					
						
							|  |  |  |  | // #endif
 | 
					
						
							|  |  |  |  | // 
 | 
					
						
							|  |  |  |  | // #endif
 | 
					
						
							|  |  |  |  | // 
 | 
					
						
							|  |  |  |  | // 
 | 
					
						
							|  |  |  |  | // #ifdef IRIS_API_EXPORTS
 | 
					
						
							|  |  |  |  | // #define IRIS_API_CLASS  __declspec(dllexport)
 | 
					
						
							|  |  |  |  | // #else
 | 
					
						
							|  |  |  |  | // #define IRIS_API_CLASS  __declspec(dllimport)
 | 
					
						
							|  |  |  |  | // #endif
 | 
					
						
							|  |  |  |  | #define MAXDISTANCE 1265000
 | 
					
						
							|  |  |  |  | class /*IRIS_API_CLASS*/ CVSMD12XControl | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | public: | 
					
						
							|  |  |  |  | 	CVSMD12XControl(); | 
					
						
							|  |  |  |  | 	~CVSMD12XControl(); | 
					
						
							|  |  |  |  | private: | 
					
						
							|  |  |  |  | 	int *m_piPositionInPulses; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	CAbstractPort *m_pAbsPort; | 
					
						
							|  |  |  |  | 	unValue m_unValue; | 
					
						
							|  |  |  |  | 	MSInfo m_stuMSInfo; | 
					
						
							|  |  |  |  | 	ControllerParams m_stuControllerParams; | 
					
						
							|  |  |  |  | 	int m_iProtocolType; | 
					
						
							|  |  |  |  | 	int m_iCID; | 
					
						
							|  |  |  |  | 	std::string m_strCID; | 
					
						
							|  |  |  |  | public: | 
					
						
							|  |  |  |  | 	bool m_bIsSyncMove; | 
					
						
							|  |  |  |  | 	//////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  |  | 	//for IRIS Linear Motor - Electric Shutter
 | 
					
						
							|  |  |  |  | 	//Initialize communication setup iPortType(0:RS232  1:RS485)  iCID(For RS485 device) bSyncMove(move mode)
 | 
					
						
							|  |  |  |  | 	bool ILMES_InitializeComm(QString portName,int bandrate=9600, int iPortType = 1, int iCID = 1, bool bSyncMove = true); | 
					
						
							|  |  |  |  | 	//Initialize communication setup iPortType(0:RS232  1:RS485)  iCID(For RS485 device) bSyncMove(move mode)
 | 
					
						
							|  |  |  |  | 	bool ILMES_InitializeComm(PortInfo portinfo,int iPortType = 1,int iCID = 1, bool bSyncMove = true); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	//Initialize Controller params
 | 
					
						
							|  |  |  |  | 	bool ILMES_InitializeParams(ControllerParams cpParams); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	//Set the light hole position(pulses)
 | 
					
						
							|  |  |  |  | 	void ILMES_SetPosition(int *piPositionInPulse,size_t szSize); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	bool ILMES_MoveToPos(int iPositionIndex); | 
					
						
							| 
									
										
										
										
											2022-02-14 11:10:02 +08:00
										 |  |  |  |     bool IsMotionFinished(); | 
					
						
							| 
									
										
										
										
											2022-01-12 14:30:11 +08:00
										 |  |  |  | public: | 
					
						
							|  |  |  |  | 	int waitetime; | 
					
						
							|  |  |  |  | 	////init port 
 | 
					
						
							|  |  |  |  | 	void SetProtocolType(int iProtocolType = 0);//0:RS232  1:RS485 call before send any command
 | 
					
						
							|  |  |  |  | 	void SetCID(int iID);//set device id when using RS485 protocol call before send any command
 | 
					
						
							|  |  |  |  | 	void SetSyncMode(bool bSyncMove = false); | 
					
						
							|  |  |  |  | 	bool InitAndOpenPort(PortInfo portinfo);//Init comport by PortInfo Struct
 | 
					
						
							|  |  |  |  | 	 | 
					
						
							|  |  |  |  | 	//////////////////////////////////////////////////////////////////////////for debug or unsupported function
 | 
					
						
							|  |  |  |  | 	std::string ReadReceive(); | 
					
						
							|  |  |  |  | 	int         SendCommand(const std::string strSend); // return indicates how many char has been sent
 | 
					
						
							|  |  |  |  | 	//////////////////////////////////////////////////////////////////////////motor control
 | 
					
						
							|  |  |  |  | 	////init&misc
 | 
					
						
							|  |  |  |  | 	bool  InitController(); //Init Motor controller hand shake
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	bool  Enable();  //enbale
 | 
					
						
							|  |  |  |  | 	bool  Disable(); //disable
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	bool  GetStatus(MSInfo &stuMotorParam);  //load motor status see MSInfo Struct
 | 
					
						
							|  |  |  |  | 	////motion control
 | 
					
						
							| 
									
										
										
										
											2022-02-14 11:10:02 +08:00
										 |  |  |  | 	bool  Move(int iRelPulse);  // relative move mode,pulse     (-2147483647<34><37>2147483647)
 | 
					
						
							|  |  |  |  | 	bool  MoveTo(int iAbsPulse);//absolute mode,pulse     (-2147483647<34><37>2147483647)
 | 
					
						
							|  |  |  |  | 	bool  Move_NoSyn(int iRelPulse);  // relative move mode,pulse     (-2147483647<34><37>2147483647)
 | 
					
						
							|  |  |  |  | 	bool  MoveTo_NoSyn(int iAbsPulse);//absolute mode,pulse     (-2147483647<34><37>2147483647)
 | 
					
						
							| 
									
										
										
										
											2022-01-12 14:30:11 +08:00
										 |  |  |  | 	bool  SetLogicZero();  //set logic zero
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	bool  StartBackZero();//back zero
 | 
					
						
							|  |  |  |  | 	bool  StopBackZero();// stop back zero & reset register
 | 
					
						
							|  |  |  |  | 	////Set&Get
 | 
					
						
							| 
									
										
										
										
											2022-02-14 11:10:02 +08:00
										 |  |  |  | 	bool  SetBaudRate(int iBaudRate);//set controller baud rates,default B9600     (2400 <20><> 921600)
 | 
					
						
							| 
									
										
										
										
											2022-01-12 14:30:11 +08:00
										 |  |  |  | 	int   GetBaudRate();  // -1:should retry;
 | 
					
						
							|  |  |  |  | 	  | 
					
						
							| 
									
										
										
										
											2022-02-14 11:10:02 +08:00
										 |  |  |  | 	bool  SetMicroSteps(int iMicroSteps);//set micro steps     (0<><30>5)->(1/2/4/8/16/32)
 | 
					
						
							| 
									
										
										
										
											2022-01-12 14:30:11 +08:00
										 |  |  |  | 	int   GetMicroSteps(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-14 11:10:02 +08:00
										 |  |  |  | 	bool  SetAccSpeed(float fAccSpd);//set acceleration speed in pulse     (0 <20><> 192000000)
 | 
					
						
							| 
									
										
										
										
											2022-01-12 14:30:11 +08:00
										 |  |  |  | 	float GetAccSpeed(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-14 11:10:02 +08:00
										 |  |  |  | 	bool  SetRunSpeed(float fRunSpeed);//set normal running speed in pulse     (0 <20><> 192000000)
 | 
					
						
							| 
									
										
										
										
											2022-01-12 14:30:11 +08:00
										 |  |  |  | 	float GetRunSpeed(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-14 11:10:02 +08:00
										 |  |  |  | 	bool  SetDecSpeed(float fDecSpeed);//set deceleration speed in pulse     (0 <20><> 192000000)
 | 
					
						
							| 
									
										
										
										
											2022-01-12 14:30:11 +08:00
										 |  |  |  | 	float GetDecSpeed(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	bool  SetSpeed(float fRunSpeed, float fAccSpd, float fDecSpeed);//see above three functions
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-14 11:10:02 +08:00
										 |  |  |  | 	bool  SetHoldCurrent(float fHoldCurrent);//set hold current ( 0 <20><> 8.0 )Amp? pay attention to your motor specification.
 | 
					
						
							| 
									
										
										
										
											2022-01-12 14:30:11 +08:00
										 |  |  |  | 	float GetHoldCurrent(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-14 11:10:02 +08:00
										 |  |  |  | 	bool  SetAccCurrent(float fAccCurrent);//set acceleration current ( 0 <20><> 8.0 )Amp? pay attention to your motor specification.
 | 
					
						
							| 
									
										
										
										
											2022-01-12 14:30:11 +08:00
										 |  |  |  | 	float GetAccCurrent(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-14 11:10:02 +08:00
										 |  |  |  | 	bool  SetRunCurrent(float fRunCurrent);//set normal running current ( 0 <20><> 8.0 )Amp? pay attention to your motor specification.
 | 
					
						
							| 
									
										
										
										
											2022-01-12 14:30:11 +08:00
										 |  |  |  | 	float GetRunCurrent(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	bool  SetCurrent(float fAccCurrent, float fRunCurrent, float fHoldCurrent);//see above three functions
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	bool  SetS1FETE(ZZ_U8 bS1FETE);//S1 register falling edge trigger event,see enum
 | 
					
						
							|  |  |  |  | 	ZZ_U8  GetS1FETE(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	bool  SetS1RETE(ZZ_U8 bS1RETE);//S1 register rising edge trigger event
 | 
					
						
							|  |  |  |  | 	ZZ_U8  GetS1RETE(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	bool  SetS2FETE(ZZ_U8 bS2FETE);//S2 register falling edge trigger event
 | 
					
						
							|  |  |  |  | 	ZZ_U8  GetS2FETE(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	bool  SetS2RETE(ZZ_U8 bS2RETE);//S2 register rising edge trigger event
 | 
					
						
							|  |  |  |  | 	ZZ_U8  GetS2RETE(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	//(ZeroMode 0:off 1:once 2:once + safe position 3:twice 4:twice + safe position) (OpenVoltageLevel 0:Low Level 1:High Level)
 | 
					
						
							| 
									
										
										
										
											2022-02-14 11:10:02 +08:00
										 |  |  |  | 	//(ZeroSensor 0:S1 1:S2 2:S3 3:S4 4:S5 5:S6)( ZeroVelocity <20><>-192000) <20><><EFBFBD><EFBFBD>192000<30><30>pulse)(SafePosition <20><>-2147483647) <20><><EFBFBD><EFBFBD>2147483647<34><37>)
 | 
					
						
							| 
									
										
										
										
											2022-01-12 14:30:11 +08:00
										 |  |  |  | 	bool  SetZeroParams(ZZ_U8 bZeroMode, ZZ_U8 bSwitchOpenVL, ZZ_U8 bZeroSensor, float fZeroVelocity, int iSafePosition); | 
					
						
							|  |  |  |  | 	ZZ_U8  GetZeroMode(); | 
					
						
							|  |  |  |  | 	ZZ_U8  GetSwitchOpenVoltageLevel(); | 
					
						
							|  |  |  |  | 	ZZ_U8  GetZeroSensor(); | 
					
						
							|  |  |  |  | 	int   GetSafePosition(); | 
					
						
							|  |  |  |  | 	float GetZeroVelocity(); | 
					
						
							|  |  |  |  | 	 | 
					
						
							|  |  |  |  | private: | 
					
						
							|  |  |  |  | 	bool  ParseReturnedString(std::string &strRecv,int iType); | 
					
						
							|  |  |  |  | 	bool  ParseReturnedParam(std::string &strRecv); | 
					
						
							|  |  |  |  | 	void  VSMD_BitShift(ZZ_U8* src, unValue* dst); | 
					
						
							|  |  |  |  | 	char* VSMD_Split(char* cStr, char cSplit); | 
					
						
							|  |  |  |  | }; | 
					
						
							|  |  |  |  | 
 |