|
Go to the documentation of this file.
16 #ifdef FAUDES_IODEVICE_WAGO
21 extern void start_kbus_thread( void);
23 extern void kbus_update_image( void);
25 extern int kbus_running( void);
35 AutoRegisterType<wDevice> gRtiRegisterWagoDevice("WagoDevice");
38 wDevice::wDevice( void) : sDevice() {
39 FD_DHV( "wDevice(" << mName << ")::wDevice()");
41 mDefaultLabel = "WagoDevice";
50 wDevice::~wDevice( void) {
51 FD_DHV( "wDevice(" << mName << ")::~wDevice()");
56 void wDevice::Start( void) {
60 if(mState!=Down) return;
61 FD_DH( "wDevice(" << mName << ")::Start(): open devices");
63 int res = kbus_init();
66 FD_DHV( "wDevice(" << mName << ")::Start(): res = " << res );
69 std::stringstream errstr;
70 errstr << "cannot open kbus";
71 throw Exception( "wDevice()::Start()", errstr.str(), 552);
84 void wDevice::Stop( void) {
86 if(mState != Up && mState != StartUp) return;
87 FD_DHV( "wDevice(" << mName << ")::Stop()");
96 void wDevice::DoWritePreface(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
98 FD_DHV( "wDevice("<<mName<< ")::DoWritePreface()");
105 void wDevice::DoReadPreface(TokenReader& rTr, const std::string& rLabel, const Type* pContext){
107 FD_DHV( "wDevice("<<mName<< ")::DoReadPreface()");
114 bool wDevice::DoReadSignalsPre( void) {
119 if(pInputImage) return true;
123 if(pOutputImage) return false;
126 pInputImage=( char*) kbus_lock_input_image();
128 int kok= kbus_running();
132 if(mKbusOk) FD_WARN( "wDevice(" << mName << ")::DoReadSignalsPre(): kbus error and friends ");
136 kbus_release_io_image();
147 FD_WARN( "wDevice(" << mName << ")::DoReadSignalsPre(): kbus recovered");
151 if(!mKbusOk) kbus_release_io_image();
160 void wDevice::DoReadSignalsPost( void) {
163 if(pInputImage) kbus_release_io_image();
170 bool wDevice::DoReadSignal( int bit){
178 return ( pInputImage[byte] & (0x01 << (bit)) ) != 0x00;
183 bool wDevice::DoWriteSignalsPre( void) {
185 if(pInputImage) return false;
187 if(pOutputImage) return true;
189 pOutputImage=( char*) kbus_lock_output_image();
197 void wDevice::DoWriteSignalsPost( void) {
199 if(pOutputImage) kbus_release_io_image();
206 void wDevice::DoWriteSignal( int bit, bool value){
210 int byte = (bit) / 8;
213 FD_DHV( "wDevice(" << mName << ")::DoWriteSignal(int): bit " << bit << " in byte " << byte);
217 if(value) pOutputImage[byte] |= (0x1 << (bit));
219 else pOutputImage[byte] &= ~(0x1 << (bit));
225 #endif // end wago-support
libFAUDES 2.26g
--- 2015.08.17
--- c++ api documentaion by doxygen
|