iop_wago.h
Go to the documentation of this file.
1/** @file iop_wago.h Hardware access via comedi */
2
3/*
4 FAU Discrete Event Systems Library (libfaudes)
5
6 Copyright (C) 2009, Thomas Wittmann, Thomas Moor.
7 Copyright (C) 2010, Thomas Moor.
8
9*/
10
11
12
13#ifndef FAUDES_IOW_WAGO_H
14#define FAUDES_IOW_WAGO_H
15
16// include core-libary and iodevice
17#include "corefaudes.h"
18#include "iop_include.h"
19
20// only compile for use with wago-ipc
21#ifdef FAUDES_IODEVICE_WAGO
22
23namespace faudes {
24
25
26
27/**
28 * Signal-based I/O for WAGO IPC with kBus interface.
29 *
30 * The wDevice provides access to the kBus (Klemmenbus) used by WAGO to read and write
31 * the process-image of the respective IPC configuration.
32 *
33 * Note: the current implementation of wDevice uses the bit addressing in the
34 * IEC process image according to WAGO specifications. For the LRT lab experient,
35 * digital inputs and outputs range from bitaddress 0 to 15, respectively. You may use
36 * the <tt>iomonitor</tt> to identify the address scheme of your kbus configuration.
37 *
38 * Note: this device compiles under Linux only. Compilation requires WAGO supplied
39 * libraries that can be obtained from WAGO; see also the tutorial README.
40 * This device must be explicitely anabled
41 * Makefile.plugin.
42 *
43 * @ingroup IODevicePlugin
44 */
45
46class FAUDES_API wDevice : public sDevice {
47
48FAUDES_TYPE_DECLARATION(WagoDevice,wDevice,sDevice)
49
50 public:
51
52 /**
53 * Default constructor
54 */
55 wDevice(void);
56
57 /**
58 * Copy constructor (TODO!)
59 */
60 wDevice(const wDevice&) : sDevice() {};
61
62 /**
63 * Explicit destructor.
64 */
65 virtual ~wDevice(void);
66
67
68 /**
69 * Activate the device. This function opens/initializes the kbus support libraries and
70 * sets up the internal kbus-thread. Furthermore it invalidates the io-images.
71 * During the actual read- and write-process this will be reversed if admissable.
72 *
73 * In oder to enable signal-edge detection the faudes-background thread will be started
74 *
75 * @exception Exception
76 * - not yet configured (id not configured)
77 * - failed to open kbus (id not configured)
78 */
79 virtual void Start(void);
80
81 /**
82 * Deactivate the device. This function shuts the kbus and related mechanisms down
83 * and disables output execution and input reading.
84 * It stops the background thread and resets all output signals to 0.
85 */
86 virtual void Stop(void);
87
88protected:
89
90 /**
91 * wago API access
92 *
93 **/
94
95 // Initialze kbus
96 int kbusInit(void);
97 // Shutdown kbus
98 void kbusShutdown(void);
99 // Get pointer to the kbus-info structure
100 struct kbus_info* kbusGetInfo(void);
101
102
103
104
105 /**
106 * IO Hook, inputs
107 *
108 * The Wago device uses the pre hook to lock the process image.
109 *
110 * @return
111 * True on success, false on KBUS error
112 *
113 */
114 virtual bool DoReadSignalsPre(void);
115
116 /**
117 * IO Hook, inputs
118 *
119 * The Wago device uses the post hook to release the process image.
120 *
121 *
122 */
123 virtual void DoReadSignalsPost(void);
124
125 /**
126 * Get input signal.
127 *
128 * Extract bit value from image.
129 *
130 * @param bitaddr
131 * Abstract bit address
132 * @return
133 * True for logic level high;
134 */
135 virtual bool DoReadSignal(int bitaddr);
136
137 /**
138 * IO Hook, outputs
139 *
140 * The Wago device uses the pre hook to lock the process image.
141 *
142 * @return
143 * True on success, false on KBUS error
144 *
145 */
146 virtual bool DoWriteSignalsPre(void);
147
148 /**
149 * IO Hook, outputs
150 *
151 * The Wago device uses the post hook to release the process image.
152 *
153 *
154 */
155 virtual void DoWriteSignalsPost(void);
156
157 /**
158 * Set output signal.
159 *
160 * Set value of bit in process image.
161 *
162 * @param bitaddr
163 * Abstract bit address
164 * @param value
165 * True for logic level high;
166 *
167 */
168 virtual void DoWriteSignal(int bitaddr, bool value);
169
170 /** Read non-event-related configuration data from tokenreader
171 *
172 *
173 * @param rTr
174 * TokenReader to read from
175 * @param rLabel
176 * Section to read
177 * @param pContext
178 * Read context to provide contextual information
179 *
180 * */
181 void DoReadPreface(TokenReader& rTr,const std::string& rLabel="", const Type* pContext=0);
182
183 /** Write non-event-related configuration data to tokenreader
184 *
185 *
186 * @param rTw
187 * TokenWriter to write
188 * @param rLabel
189 * Section to write
190 * @param pContext
191 * Context to provide contextual information
192 *
193 * */
194 void DoWritePreface(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const ;
195
196 // process image pointers
197 char* pInputImage;
198 char* pOutputImage;
199
200 // kbus api error flag
201 bool mKbusOk;
202
203}; //class wDevice
204
205} //namespace
206
207
208#endif // configured
209
210#endif // include
#define FAUDES_API
#define FAUDES_TYPE_DECLARATION(ftype, ctype, cbase)
Definition cfl_types.h:879

libFAUDES 2.33k --- 2025.09.16 --- c++ api documentaion by doxygen