⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cup_connection.h

📁 一般OPTO22工业控制器主要用于IO控制,用途比较广泛而其上位机一般使用DELPHI平台或BCB平台进行建模和控制,该程序实现了OPTO和C++builder平台下上位机之间模拟量数字量的传输,并以
💻 H
字号:
//---------------------------------------------------------------------------

#ifndef Cup_ConnectionH
#define Cup_ConnectionH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "OptoSnapIoMemMapXLib_OCX.h"
#include <OleCtrls.hpp>
#include <ExtCtrls.hpp>
#include "stdlib.h"
#include <OleServer.hpp>//#include   <IdGlobal.hpp>//为了使用IntToBin()函数而使用的头文件
#include "DataAccess.h"
//---------------------------------------------------------------------------
struct tagSIOMM_AnaInMod012
{
  float fValue[12];
};

struct tagSIOMM_AnaOutSingleMod
{
  float fValue[2];
};

//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
        TButton *Connect;
        TEdit *IP_Address;
        TEdit *Port_Number;
        TButton *Disconnect;
        TGroupBox *Configuration;
        TLabel *Label3;
        TGroupBox *Status;
        TLabel *Label2;
        TLabel *Label1;
        TLabel *Label4;
        TButton *DataProcess;
        TMemo *Error_Message;
        TOptoSnapIoMemMapX *OptoSnapIoMemMapX1;
        void __fastcall ConnectClick(TObject *Sender);
        void __fastcall DisconnectClick(TObject *Sender);
        void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
        void __fastcall DataProcessClick(TObject *Sender);
        void __fastcall Error_MessageChange(TObject *Sender);
private:	// User declarations

        AnsiString __fastcall GetDig_inModuleStates(long ModuleNumber,bool half_Bank,long nStatePts);

public:		// User declarations
        __fastcall TForm1(TComponent* Owner);
//------------------------------------自定义函数-------------------------------------------------------
long __fastcall PtConfigure(void);
/* 在数据采集前对IO模块进行配置
output:
       long nResult:操作成功与否状态
*/
long __fastcall GetAna_inModule012Value(tagSIOMM_AnaInMod012 *pAnaInMod012Data );
/* 获取0,1,2 轨道上的模拟量模块输入,适用于四通道的模拟量输入模块
input:
       pAnaInMod012Data:将得到的12路模拟量输入构成的数组数据存在此地址中
output:
       long nResult:操作成功与否状态
*/

long __fastcall GetDig_inModule_N_States(long ModuleNumber,bool half_Bank,long * pDigInMod_N_States);
/* 获取N 轨道上的数字量模块输入,适用于四通道的数字量输入模块
input:
       ModuleNumber: 须获取的数字量模块所在轨道位置
       pAnaInMod012Data:将得到的4路0,1数字量输入构成的long数据存在此地址中
output:
       long nResult:操作成功与否状态
*/
long __fastcall SetAna_OutModule_N_Value(long ModuleNumber,tagSIOMM_AnaOutSingleMod * AnaOutModSiData);
/* 设置N 轨道上的模拟量模块输出,仅适用于两通道的模拟量输出模块
input:
       ModuleNumber: 须控制的模拟量模块所在轨道位置
       AnaOutModSiData:模块须输出的两路数据 ,数据值应当在-100~100之间,与PtConfigure一致
output:
       long nResult:操作成功与否状态
*/
void __fastcall HandleError(long nResult);
};
//连接出错时的窗口显示。正确时显示白字


// Error values generated by the classed in the driver toolkit
#define SIOMM_OK                             1
#define SIOMM_ERROR                         -1
#define SIOMM_TIME_OUT                      -2
#define SIOMM_ERROR_NO_SOCKETS              -3  // Unable to access socket interface
#define SIOMM_ERROR_CREATING_SOCKET         -4
#define SIOMM_ERROR_CONNECTING_SOCKET       -5
#define SIOMM_ERROR_RESPONSE_BAD            -6
#define SIOMM_ERROR_NOT_CONNECTED_YET       -7
#define SIOMM_ERROR_OUT_OF_MEMORY           -8
#define SIOMM_ERROR_NOT_CONNECTED           -9
#define SIOMM_ERROR_STREAM_TYPE_BAD         -10
// Error values generated by the I/O brain itself
#define SIOMM_BRAIN_ERROR_UNDEFINED_CMD      0xE001
#define SIOMM_BRAIN_ERROR_INVALID_PT_TYPE    0xE002
#define SIOMM_BRAIN_ERROR_INVALID_FLOAT      0xE003
#define SIOMM_BRAIN_ERROR_PUC_EXPECTED       0xE004
#define SIOMM_BRAIN_ERROR_INVALID_ADDRESS    0xE005
#define SIOMM_BRAIN_ERROR_INVALID_CMD_LENGTH 0xE006
#define SIOMM_BRAIN_ERROR_RESERVED           0xE007
#define SIOMM_BRAIN_ERROR_BUSY               0xE008
#define SIOMM_BRAIN_ERROR_CANT_ERASE_FLASH   0xE009
#define SIOMM_BRAIN_ERROR_CANT_PROG_FLASH    0xE00A
#define SIOMM_BRAIN_ERROR_IMAGE_TOO_SMALL    0xE00B
#define SIOMM_BRAIN_ERROR_IMAGE_CRC_MISMATCH 0xE00C
#define SIOMM_BRAIN_ERROR_IMAGE_LEN_MISMATCH 0xE00D
#define SIOMM_BRAIN_ERROR_FEATURE_NOT_IMPL   0xE00E
#define SIOMM_BRAIN_ERROR_WATCHDOG_TIMEOUT   0xE00F
// The types of socket connections
#define SIOMM_TCP   1
#define SIOMM_UDP   2
// Error values generated by the users
#define User_Error1 -11
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -