123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- #pragma once
- #include <string>
- #include "DIOS.Dev.IODevice.Detail.hpp"
- #include "DIOS.Dev.MECH.Mould.hpp"
- #include "DiosDevThread.h"
- #include "IODeviceWithSCF.tlh"
- #include "IODeviceWithSCF.tli"
- #include "DIOS.Dev.MSGMould.hpp"
- #include "CANPort.h"
- #include <deque>
- #ifndef DIOSDEVMECHWDMAMMOCAN_EXPORTS
- #ifdef _WIN64
- #ifdef _DEBUG
- #pragma comment(lib, "DIOS.Dev.Mech.WDMAMMOCAN64D.lib")
- #else
- #pragma comment(lib, "DIOS.Dev.Mech.WDMAMMOCAN64D.lib")
- #endif
- #else
- #ifdef _DEBUG
- #pragma comment(lib, "DIOS.Dev.Mech.WDMAMMOCAND.lib")
- #else
- #pragma comment(lib, "DIOS.Dev.Mech.WDMAMMOCAND.lib")
- #endif
- #endif
- #endif
- #ifdef DIOSDEVMECHWDMAMMOCAN_EXPORTS
- #define _DIOSDEVMECHDEMO_API __declspec(dllexport)
- #else
- #define _DIOSDEVMECHDEMO_API __declspec(dllimport)
- #endif
- //CAN port class
- //#include "StringExt.h"
- #define TIMING0 0x04
- #define TIMING1 0x1C
- #define ACCESSCODE 0x60000000 //验证码,我ID:24:--0 11000 00 0000 0000 0000 0000 0000 0000
- #define MASKCODE 0x9FFFFFFF //屏蔽码 :-----1 00111 11 1111 1111 1111 1111 1111 1111
- #define ID_ImageConsole 0x18 //图像控制台ID:24
- #include "Usbcan/ZLG.h"
- #include "Usbcan/PC.h"
- #include "Usbcan/JY.h"
- #include "Usbcan/CAN.h"
- using namespace std;
- class CCANPort;
- //end CAN
- namespace DIOS::Dev::Detail::MECH
- {
- namespace nsDev = DIOS::Dev;
-
- class WDMAMMOCANDevice : public IODeviceDetail, public MECHMould
- {
- using super = IODeviceDetail;
- using superMech = MECHMould;
- public:
- //void FireNotify(string key, unsigned int value);
- //void FireNotify(string key, float value);
- void FireNotify(string key, string value);
- protected:
- std::shared_ptr <DIOS::Dev::IOEventCenter> m_EventCenter;
- ResDataObject m_GenConfig;
-
- public:
- WDMAMMOCANDevice(std::shared_ptr <IOEventCenter> center,string configfile="");
- ~WDMAMMOCANDevice();
-
- virtual bool Prepare();
- virtual void Register();
- virtual RET_STATUS GetTomoResults(ResDataObject& resultAngle, ResDataObject& resultHeight);
- virtual RET_STATUS SetGrid(unsigned int GridType);
- virtual RET_STATUS SetAutoTracking(unsigned int nAutoTracking);
- virtual std::string GetGUID() const override;
-
- virtual RET_STATUS SetStudyInfo(STUDAY_INFO info) override { return RET_STATUS::RET_SUCCEED; };
- virtual RET_STATUS SetViewList(int ViewCount, const char* viewID[], const char* viewName[]) override { return RET_STATUS::RET_SUCCEED; };
- virtual RET_STATUS SelectViewInfo(const char* viewID, const char* viewName) override { return RET_STATUS::RET_SUCCEED; };
- virtual RET_STATUS SetAutoTracking(int nAutoTracking) override { return RET_STATUS::RET_SUCCEED; };
- virtual RET_STATUS SetGridType(AttrKey::MECH_GRIDTYPE GridType) override { return RET_STATUS::RET_SUCCEED; };
- virtual RET_STATUS SetSID(float value) override
- {
- m_MECHUnit.m_SID->Update(int(value));//just test.
- return RET_STATUS::RET_SUCCEED;
- };
- virtual RET_STATUS SetSOD(float value) override { return RET_STATUS::RET_SUCCEED; };
- virtual RET_STATUS SetPositonNumber(int pn) override { return RET_STATUS::RET_SUCCEED; };
- virtual RET_STATUS GetTomoResults(std::string& result) override { return RET_STATUS::RET_SUCCEED; };
- };
- #if 1
- class CCANPort
- {
- public:
- CCANPort();
- virtual ~CCANPort();
- static DWORD ReceiveThread(void* param);
- WDMAMMOCANDevice* m_pTableCtrl;
- void SetTableCtrl(WDMAMMOCANDevice* pTabCtrl) { m_pTableCtrl = pTabCtrl; };
- void CAN_Close();
- bool CAN_Reset();
- BOOL CAN_Init(HWND hWnd, DWORD dwAccCode = ACCESSCODE, DWORD dwAccMask = MASKCODE, UCHAR ucFilter = 1, UCHAR ucMode = 0, UCHAR ucTiming0 = TIMING0, UCHAR ucTiming1 = TIMING1, int nCannum = 0);
- BOOL CAN_Open(DWORD DeviceInd = 0, int Reserved = 0);
- bool CAN_transmit(string strData, string strFrmID, BYTE RomoteFlag = 0, BYTE ExternFlag = 0, BYTE type = 1);
- bool CAN_Start();
- HANDLE m_Thread;
- HWND m_hCANWindowHandle;
- BOOL m_bCanStart; //物理CAN节点打开
- protected:
- BOOL m_bCANThreadActive;
- int m_cannum;
- int m_devtype;
- DWORD m_devind;
- VCI_INIT_CONFIG init_config;
- CCAN* m_pCANEx;
- int m_nAngleDirection;//0 负方向 ,1 正方向
- };
- #endif // 0
- }
- //-----------------------------------------------------------------------------
- // WDMAMMOCANDriver
- //-----------------------------------------------------------------------------
- namespace DIOS::Dev::Detail::MECH
- {
- class _DIOSDEVMECHDEMO_API WDMAMMOCANDriver : public IODriverWithSCF <DriverMould>
- {
- using super = IODriverWithSCF <DriverMould>;
- ResDataObject m_GenConfig;
- public:
- WDMAMMOCANDriver();
- virtual ~WDMAMMOCANDriver();
- public:
- virtual void Prepare() override;
- virtual int Connect() override;
- virtual void Disconnect() override;
- virtual bool isConnected() const override;
- virtual void Dequeue(const char* Packet, DWORD Length) override;
- virtual void FireNotify(int code, std::string key, std::string content) override;
- virtual auto CreateDevice(int index)->std::unique_ptr <IODevice> override;
- virtual std::string DriverProbe() override;
- virtual std::string GetResource() override;
- virtual std::string DeviceProbe() override;
- virtual bool GetDeviceConfig(std::string& Cfg) override;
- virtual bool SetDeviceConfig(std::string Cfg) override;
- WDMAMMOCANDevice* m_pDriGenDev;// = nullptr;
- private:
- static PACKET_RET callbackPackageProcess(const char* RecData, DWORD nLength, DWORD& PacketLength);
- bool m_bDemoMode;
- bool m_bDemoConnected; // 在 DEMO 模式下, 调用过 Connect 吗?
- bool m_bDemoInitDataFlag; //是否存在初始化数据
- ResDataObject m_InitDataFile;
- //for webconfig
- ResDataObject m_DeviceConfigSend;
- ResDataObject m_DeviceConfig;
- string g_strAppPath;
- ResDataObject m_ConfigAll; //存储当前的配置,用于修改配置时写回文件
- ResDataObject m_Configurations; //存储当前配置中“CONFIGURATION”节点的内容
- std::unique_ptr <ResDataObject> m_pAttribute;
- std::unique_ptr <ResDataObject> m_pDescription;
- bool SaveConfigFile(bool bSendNotify);
- bool GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue);
- bool SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue);
- CCANPort* m_pCAN;
- bool ResetCommunication();
- };
- }
|