rllib  1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
rleibnetip.h
Go to the documentation of this file.
1 /***************************************************************************
2  rleibnetip.h - description
3  -------------------
4  begin : Wed Apr 04 2007
5  copyright : (C) 2007 by R. Lehrig
6  email : lehrig@t-online.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
13  * published by the Free Software Foundation *
14  * *
15  ***************************************************************************/
16 #ifndef _RL_EIB_NET_IP_H_
17 #define _RL_EIB_NET_IP_H_
18 
19 #include "rldefine.h"
20 #include "rludpsocket.h"
21 #include "rlthread.h"
22 #include <stdio.h>
23 
24 #define EIB_ON 0x81
25 #define EIB_OFF 0x80
26 
28 
32 class rlEIBnetIP : public rlUdpSocket
33 {
34 public:
35 
36  enum EIBnetIP
37  {
38  PORT = 3671,
39  SUCCESS = 0,
40  EIBERROR = 0x0ffffffff,
41  TIMEOUT = -1,
43  };
44 
45  typedef struct
46  {
47  unsigned char headersize;
48  unsigned char version;
49  unsigned short servicetype;
50  unsigned short totalsize;
51  unsigned char data[128-6];
52  }PDU;
53 
54  typedef struct
55  {
56  unsigned char mc; // 0x29
57  unsigned char addi1; // 0x0
58  unsigned char ctrl1; // 0xbc
59  unsigned char ctrl2; // 0xe0
60  unsigned short saddr; // 0x1
61  unsigned short daddr; // 0x100
62  unsigned char apci_length; // 0x1
63  unsigned char apci; // 0x0
64  unsigned char val[14]; // 0x80
65  }EIB_TEL;
66 
67  // this may be used by the application programmer
68  rlEIBnetIP(int num_signals = 1000, int debug = 0, rlDataAcquisitionProvider *provider = NULL);
69  virtual ~rlEIBnetIP();
70 
71  int setServer(rlIpAdr *server);
72  int setClient(rlIpAdr *client);
73  int startReading();
74  int stopReading();
75  int value(const char *name);
76  unsigned int valueUnsigned(const char *name);
77  float valueFloat2(const char *name);
78  float valueFloat4(const char *name);
79  int setValue(const char *name, int val, int length=-1, int addi1=-1, int ctrl=-1, int apci=-1);
80  int setValueUnsigned(const char *name, unsigned int val, int length=-1, int addi1=-1, int ctrl=-1, int apci=-1);
81  int setValueFloat(const char *name, float val, int length=-1, int addi1=-1, int ctrl=-1, int apci=-1);
82  int setText(const char *name, const char *text);
83  int getText(const char *name, char *text, int maxlen);
84  int setSourceAdr(const char *adr);
85  int dump(FILE *fout);
86  int setValuesFromCSV(const char *filename);
87  int debug;
88  int watch_eib;
89 
90  // the rest is for internal use only
91  int connect();
92  int disconnect();
93  int isConnected();
94 #ifndef SWIG_SESSION
95  int getDescription(PDU *pdu);
96 #endif
97  int recv(void *buf, int maxlen);
98  int storeBuffer(unsigned char *buf, int len);
100 
101  void *mem;
102  int memsize;
103  int running;
110 
111 private:
112  int printTelegram(EIB_TEL *tel);
113  int storeInProvider(EIB_TEL *tel);
118  short saddr;
119 };
120 
121 #endif