1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
typedef struct { //! Ouverure de la socket int (pascal FAR *OpenSocket) (int port, char* portname);
//! Connection de la socket int (pascal FAR *ConnectPLC) (int dc); //! DéConnection de la socket int (pascal FAR *DisconnectPLC) (int dc);
//! Lit des mots int (pascal FAR *ReadBytes) (int dc, int area, int DBnumber, int start, int len, char* buffer);
//! Ecrit des mots int (pascal FAR *WriteBytes) (int dc, int area, int DBnumber, int start, int len, char* buffer);
} IEthernet;
class daveInterface { public: //! Création de l'interface daveInterface* (pascal FAR *Init) (daveOSserialType fd, char* name, int localMPI, int useProto, int speed);
};
class daveConnection { public: //! Création de l'interface daveConnection* (pascal FAR *Init) (daveInterface* di, int MPI, int rack, int slot);
};
tes variables: //! Pointeur sur la structure contenant les fonctions de la Dll Applicom IEthernet driveri;
// Connection vers PLC en Ethernet daveConnection *dci;
daveInterface *dii;
daveOSserialType fdsi;
dans le .cpp : dii = new daveInterface();
dci = new daveConnection();
(FARPROC)driveri.OpenSocket = GetProcAddress(DllEtherneti, "openSocket");
(FARPROC)dii->Init = GetProcAddress(DllEtherneti, "daveNewInterface");
(FARPROC)dci->Init = GetProcAddress(DllEtherneti, "daveNewConnection");
(FARPROC)driveri.ConnectPLC = GetProcAddress(DllEtherneti, "daveConnectPLC");
(FARPROC)driveri.DisconnectPLC = GetProcAddress(DllEtherneti, "daveDisconnectPLC");
(FARPROC)driveri.ReadBytes = GetProcAddress(DllEtherneti, "daveReadBytes");
(FARPROC)driveri.WriteBytes = GetProcAddress(DllEtherneti, "daveWriteBytes");
fdsi.rfd = driveri.OpenSocket(Port, /*"08-00-06-9D-C1-AA"*/Ip.c_str());
fdsi.wfd = fdsi.rfd;
if (fdsi.rfd>0) { dii = dii->Init(fdsi, "Read", 1, ProtoISOTCP, Speed1500k/*Speed187k*/);
// fds, Name, localMPI, Protocole, Speed dci = dci->Init(dii,2,0, 2);
// daveInterface, @MPI, rack, slot int rslt = driveri.ConnectPLC((int)dci);
if (rslt == 0) { printf("Connected.\n");
} } int rslt = driveri.ReadBytes((int)dci, areaDB, DBNum, Offset, Nb * sizeof(short), (char*)Buffer); |
Partager