#pragma once #include "afxcmn.h" #include "CommDataDef.h" // CPlcDeviceDlg 对话框 class CModbusClient; class CPluginMainDialog; typedef struct AGV_PLC_data { union AGVIntWithBools { short data; struct { bool Brake : 1; //刹车 bool Charge : 1; //充电 bool Reserve1 : 1; bool Reserve2 : 1; bool OpFdoor : 1; //开前卷帘门 bool CoFdoor : 1; //关前卷帘门 bool OpBdoor : 1; bool CoBdoor : 1; bool LRollerF : 1; bool LRollerB : 1; bool RRollerF : 1; bool RRollerB : 1; } bits; }AGVControl_u; union PLCIntWithBools { short data; struct { bool IndoorLRoller : 1; //室内左侧滚筒运行 bool IndoorRRoller : 1; //室内右侧滚筒运行 bool OutdoorLRoller : 1; //室外左侧滚筒运行 bool OutdoorRRoller : 1; //室外右侧滚筒运行 bool Reserve1 : 1; bool Reserve2 : 1; bool Reserve3 : 1; bool Reserve4 : 1; bool OpenBarrierGate : 1; //开道闸 bool CloseBarrierGate : 1; //关道闸 bool OpenShopRollerDoor : 1;//开仓库卷帘门 } bits; }PLCControl_u; union RunStaIntWithBools { short data; struct { bool Standby_mode : 1; bool GotoLoading : 1; bool GotoUnloading : 1; bool S_stop : 1; bool Reqloading : 1; bool ReqUnloading : 1; bool AUTOHandSwitch : 1; //手自动切换 1手动 0自动 bool AGVpipelineReset : 1; //车载输送线复位 bool Force_Import : 1; bool Reserve2 : 1; bool Reserve3 : 1; bool Reserve4 : 1; bool Reserve5 : 1; bool Reserve6 : 1; bool Reserve7 : 1; bool Reserve8 : 1; } bits; }RunStaControl_u; int HeartBeat; AGV_PLC_data() { AGVControl_u.data = 0; PLCControl_u.data = 0; RunStaControl_u.data = 0; HeartBeat = 1; } }ST_AGVTOPLCDATA; typedef struct PLC_AGV_data { union AGVIntWithBools { short data; struct { bool Reserve1 : 1; bool Reserve2 : 1; bool Reserve3 : 1; bool Reserve4 : 1; bool FdoorOpen_ste : 1; bool FdoorClose_ste : 1; bool BdoorOpen_ste : 1; bool BdoorClose_ste : 1; bool LFsensor_ste : 1; bool LMsensor_ste : 1; bool LBsensor_ste : 1; bool Fdoorsenor_ste : 1; bool RFsensor_ste : 1; bool RMsensor_ste : 1; bool RBsensor_ste : 1; bool Bdoorsenor_ste : 1; } bits; }AGVstate_u; union RollerIntWithBools { short data; struct { bool IndoorLRoller_ste : 1; bool IndoorRRoller_ste : 1; bool OutdoorLRoller_ste : 1; bool OutdoorRRoller_ste : 1; bool OutdoorAGV_Estop : 1; bool IndoorAGV_Estop : 1; bool Reserve1 : 1; bool Reserve2 : 1; bool BarrierGateIsOpen : 1; //道闸开到位 bool BarrierGateIsClose : 1; //道闸关到位 bool ShopRollerdoorIsOpen : 1;//仓库卷帘门开到位 } bits; }RollerState_u; union StateIntWithBools { short data; struct { bool Fsafeside : 1; bool Bsafeside : 1; bool Lsafeside : 1; bool Rsafeside : 1; bool Fradarslow : 1; bool Fradarstop : 1; bool Bradarslow : 1; bool Bradarstop : 1; bool AGVEstop : 1; bool RadarShield : 1; //雷达屏蔽 bool SafeSideShield : 1; //触边屏蔽 bool Soaking : 1; //浸水传感器触发 } bits; }SafeState_u; union RemoteCIntWithBools { short data; struct { bool RemoteControl : 1; bool Forward : 1; bool Backward : 1; bool LeftRotation : 1; bool RightRotation : 1; bool ZeroHold : 1; bool Reserve : 1; } bits; }RemoteControl_u; union LoadStaIntWithBools { short data; struct { bool Loading : 1; bool LoadFinish : 1; bool Unloading : 1; bool UnloadFinish : 1; bool LoadingErr : 1; bool UnloadingErr : 1; } bits; }LoadState_u; PLC_AGV_data() { AGVstate_u.data = 0; RollerState_u.data = 0; SafeState_u.data = 0; RemoteControl_u.data = 0; LoadState_u.data = 0; } }ST_PLCTOAGVDATA; class CPlcMainDlg : public CDialogEx { DECLARE_DYNAMIC(CPlcMainDlg) public: CPlcMainDlg(CWnd* pParent = NULL); // 标准构造函数 virtual ~CPlcMainDlg(); // 对话框数据 #ifdef AFX_DESIGN_TIME enum { IDD = IDD_DEV_PLC_DLG }; #endif protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 DECLARE_MESSAGE_MAP() public: virtual BOOL OnInitDialog(); void ReadConfigFromIni(); BOOL ConnectPlcController(); void MfcButtonInit(); void OpenFdoor(); void OpenBdoor(); void CloseFdoor(); void CloseBdoor(); void DisplayDLG(); CIPAddressCtrl m_ipAddrCtrl; CMFCButton m_btnOpFdColor; CMFCButton m_btnCoFdColor; CMFCButton m_btnOpBdColor; CMFCButton m_btnCoBdColor; CMFCButton m_btnInDLRColor; CMFCButton m_btnInDRRColor; CMFCButton m_btnOutDLRColor; CMFCButton m_btnOutDRRColor; CMFCButton m_btnFsafeSColor; CMFCButton m_btnBsafeSColor; CMFCButton m_btnLsafeSColor; CMFCButton m_btnRsafeSColor; CMFCButton m_btnFradarSColor; CMFCButton m_btnFradarTColor; CMFCButton m_btnBradarSColor; CMFCButton m_btnBradarTColor; CMFCButton m_btnAGVEstopColor; CMFCButton m_btnShieldRColor; CMFCButton m_btnShieldSSColor; CMFCButton m_btnLrollerFsenColor; CMFCButton m_btnLrollerMsenColor; CMFCButton m_btnLrollerBsenColor; CMFCButton m_btnRrollerFsenColor; CMFCButton m_btnRrollerMsenColor; CMFCButton m_btnRrollerBsenColor; CMFCButton m_btnFDloadSteColor; CMFCButton m_btnBDloadSteColor; CMFCButton m_btnOpenBarrierGate; CMFCButton m_btnCloseBarrierGate; CMFCButton m_btnOpenShopRollDoor; CStatic m_txRemoteControl; CString m_strIpAddr; int m_nPort; BOOL m_bConnectServer; afx_msg void OnBnClickedBtnSet(); afx_msg void OnBnClickedBtnOpenFdoor(); afx_msg void OnBnClickedBtnCloseFdoor(); afx_msg void OnBnClickedBtnOpenBdoor(); afx_msg void OnBnClickedBtnCloseBdoor(); afx_msg void OnTimer(UINT_PTR nIDEvent); LRESULT OnNetMsg(WPARAM wparam, LPARAM lparam); public: CModbusClient *m_pModbusClient; //CPluginMainDialog *m_pMainWnd; void OnDevReadRspDataFromPlc(BYTE nDevId, ST_MODBUS_SERVER_RSPREAD_FRAME stReadFrame); void OnDevWrtRspDataFromPlc(BYTE nDevId, ST_MODBUS_SERVER_RSPWRT_FRAME stWriteFrame); afx_msg void OnBnClickedBtnRdReg(); afx_msg void OnBnClickedBtnWrReg(); afx_msg void OnBnClickedMfcbutton1(); afx_msg void OnBnClickedBtnLrollerF(); afx_msg void OnBnClickedBtnLrollerB(); afx_msg void OnBnClickedBtnLrollerStop(); afx_msg void OnBnClickedBtnRrollerF(); afx_msg void OnBnClickedBtnRrollerB(); afx_msg void OnBnClickedBtnRrollerStop(); afx_msg void OnBnClickedBtnIndoorlsta(); afx_msg void OnBnClickedBtnIndoorrsta(); afx_msg void OnBnClickedBtnOutdoorlsta(); afx_msg void OnBnClickedBtnOutdoorrsta(); afx_msg void OnBnClickedBtnIndoorstop(); afx_msg void OnBnClickedBtnOutdoorstop(); afx_msg void OnBnClickedBtnShiedradar(); afx_msg void OnBnClickedBtnShieldsafedside(); ST_AGVTOPLCDATA m_stAGVTOPLCDATA; ST_PLCTOAGVDATA m_stPLCTOAGVDATA; afx_msg void OnBnClickedBtnOpenbarriergate(); afx_msg void OnBnClickedBtnClosebarriergate(); afx_msg void OnBnClickedBtnOpenshoprolldoor(); };