123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- #pragma once
- #include "dt.h"
- #include "CHardware.h"
- #include "JAxis.h"
- #ifdef C_AXIS_EXPORTS
- #define C_AXIS_DLL_API __declspec(dllexport)
- #else
- #define C_AXIS_DLL_API
- #endif
- enum SPEED {
- FAST=10,
- MEDIUM=5,
- SLOW=2
- };
- #define SYNC true
- #define NOSYNC false
- #define MOVEING 1
- class C_AXIS_DLL_API CAxis
- {
- public:
- enum AXIS_TYPE { X = 0, Y, Z, R, FORCE, Z1 };
- enum TRIG_AXIS { TX = 0, TY, TZ};
- typedef struct _HOT_ZONE_ID_STRUCT
- {
- INT ZoneId;
- string ModuleType;
- TRIG_AXIS TrigAxis;
-
- bool operator==(const _HOT_ZONE_ID_STRUCT& other) const {
- return (ZoneId == other.ZoneId) && (ModuleType == other.ModuleType) && (TrigAxis == other.TrigAxis);
- }
- }HOT_ZONE_ID_STRUCT;
- private:
- AXIS_TYPE m_eAxisType = AXIS_TYPE::X;
- string m_strAxisType;
- string m_strModuleType;
- JAxis* m_pAxis = nullptr;
- string m_strAxisName = "";
- INT m_iUse = 0;
- bool m_bIsInitSuccess = false;
- UINT m_iHomeTime = 500000;
- UINT m_iFastTime = 50000;
- UINT m_iMediumTime = 50000;
- UINT m_iSlowTime = 100000;
- UINT m_iLastWaitTime = 100000;
- UINT m_iCommonWaitTime = 100000;
- unsigned long m_lStartSysTime;
- bool m_bEnable = false;
- std::vector <ns_db::MODULE_HOT_ZONE_STRUCT> m_vecHotZoneList;
- static std::mutex m_MutexHotZone;
- static std::vector<HOT_ZONE_ID_STRUCT> m_vecHotZoneId;
-
- double m_dCurrentPosition;
-
- bool CheckHotZone(double pos);
- bool IsTriggerHotZoneX(double pos);
- bool IsTriggerHotZoneY(double pos);
- bool IsTriggerHotZoneZ(double pos);
- bool IsTriggerHotZone(ns_db::MODULE_HOT_ZONE_STRUCT stHotZone, AXIS_TYPE axis,double pos);
-
- void SetTriggerHotZone();
- void AddHotZoneId(HOT_ZONE_ID_STRUCT stHotZone);
- void DeleteHotZoneId(HOT_ZONE_ID_STRUCT stHotZone);
- public:
- CAxis();
- LONG Init(JAxis* pAxis, ns_db::AXIS_LIST_STRUCT *pAxisStruct);
- string GetAxisName() {return m_strAxisName;};
- string GetModuleType() { return m_strModuleType; };
- string GetStringAxisType() { return m_strAxisType; };
- string GetStringModuleType() { return m_strModuleType; };
- AXIS_TYPE GetAxisType() { return m_eAxisType; };
-
- LONG GetAxisStatus(AxisStatus& axisStatus);
- LONG GetActualPos(double &pos);
- LONG AxisOn();
- LONG AxisOff();
- LONG GetProfilePos(double& dProfilePos);
- LONG Sync();
- LONG Stop(AxisStopMode eStopMode = AXIS_SMOOTH_STOP);
- LONG CheckDone();
- LONG Home(bool bSync = SYNC);
- LONG Move_PassPosReturn(double dDist, double dPassDist, SPEED speed = FAST);
- LONG MoveTo_PassPosReturn(double dPos, double dPassPos, SPEED speed = FAST);
- LONG Move(double dDist, SPEED speed = FAST, bool bSync = SYNC);
- LONG MoveTo(double dPos, SPEED speed = FAST, bool bSync = SYNC);
- LONG Move(double dPos, double speed, bool bSync = SYNC);
- LONG MoveTo(double dPos, double speed, bool bSync = SYNC);
-
- LONG MoveForceCurrent(int nTorqueRatio, int nReachTime = 50, int nStopTime = 10);
- LONG GetProfileCurrent(double& dProfileTorque);
- LONG GetActualCurrent(double& dProfileTorque);
- LONG SetStopDec(double val, double val1);
- LONG SetBufferParamF(int nBufferNo, std::string sParamFName, double dDoubleParam);
- LONG GetBufferParamF(int nBufferNo, std::string sParamFName, double& dDoubleParam);
- LONG SetBufferParam(int nBufferNo, std::string sParamFName, int dDoubleParam);
- LONG GetBufferParam(int nBufferNo, std::string sParamFName, int& dDoubleParam);
- LONG WriteSerialValueF(std::string sSerial, double tValue);
- LONG WriteSerialValueN(std::string sSerial, int tValue);
- LONG WriteSocketValueF(std::string ascii, double tValue);
- LONG WriteSocketValueN(std::string ascii, int tValue);
- LONG WriteSocketCommand(std::string ascii);
-
-
- LONG RunBuffer(int id);
- LONG StopBuffer(int id);
- };
|