37 FD_DHV(
"AttributeSignalOutput(" <<
this <<
"):DoAssign(): assignment from " << &rSrcAttr);
38 mActions=rSrcAttr.mActions;
43 (void) rLabel; (void) pContext;
47 std::vector<Action>::const_iterator ait;
65 (void) rLabel; (void) pContext;
67 FD_DHV(
"AttributeSignalOutput::DoRead()");
76 while(!rTr.
Eos(
"Actions")) {
82 }
else if(value ==
"Clr") {
84 }
else if(value ==
"Inv") {
95 std::stringstream errstr;
96 errstr <<
"Invalid output event property" << rTr.
FileLine();
97 throw Exception(
"AttributeSignalOutput::Read", errstr.str(), 52);
109 while(!rTr.
Eos(
"Actions")) {
151 std::stringstream errstr;
152 errstr <<
"Invalid output event property" << rTr.
FileLine();
153 throw Exception(
"AttributeSignalOutput::Read", errstr.str(), 52);
178 FD_DHV(
"AttributeSignalInput(" <<
this <<
"):DoAssign(): assignment from " << &rSrcAttr);
179 mTriggers=rSrcAttr.mTriggers;
185 (void) rLabel; (void) pContext;
186 FD_DHV(
"AttributeSignalInput()::DoWrite()");
188 std::vector<Trigger>::const_iterator ait;
191 if(ait->mPos && (!ait->mNeg)) {
194 if((!ait->mPos) && ait->mNeg) {
197 if((ait->mPos) && ait->mNeg) {
211 (void) rLabel; (void) pContext;
213 FD_DHV(
"AttributeSignalInput()::DoRead(tr)");
223 while(!rTr.
Eos(
"Triggers")) {
227 if (value ==
"PosEdge") {
230 }
else if (value ==
"NegEdge") {
233 }
else if (value ==
"AnyEdge") {
245 std::stringstream errstr;
246 errstr <<
"invalid input event property" << rTr.
FileLine();
247 throw Exception(
"AttributeSignalInput::Read", errstr.str(), 52);
258 while(!rTr.
Eos(
"Triggers")) {
304 std::stringstream errstr;
305 errstr <<
"Invalid input event property" << rTr.
FileLine();
306 throw Exception(
"AttributeSignalInput::Read", errstr.str(), 52);
331 FD_DHV(
"AttributeSignalEvent::AttributeSignalEvent(" <<
this <<
")");
332 pOutputPrototype=OutputPrototypep();
333 pInputPrototype=InputPrototypep();
340 FD_DHV(
"AttributeSimplenetEvent(" <<
this <<
"): form other attr " << &rOtherAttr);
399 faudes_mutex_init(&
mMutex);
401 mName=
"SignalDevice";
415 faudes_mutex_destroy(&
mMutex);
482 rTr.
ReadEnd(
"SynchronousWrite");
498 #define LOCK_E {int rc = faudes_mutex_lock(&mMutex); \
499 if(rc) {FD_ERR("sDevice("<<mName<<")::LOCK_E: lock mutex error\n"); exit(1); }}
500 #define UNLOCK_E {int rc = faudes_mutex_unlock(&mMutex); \
501 if(rc) {FD_ERR("sDevice("<<mName<<")::LOCK_E: unlock mutex error\n"); exit(1); }}
504 #define TLOCK_E {int rc = faudes_mutex_lock(&sdevice->mMutex); \
505 if(rc) {FD_ERR("sDevice::TLOCK_E: lock mutex error\n"); exit(1); }}
507 #define TUNLOCK_E {int rc = faudes_mutex_unlock(&sdevice->mMutex); \
508 if(rc) {FD_ERR("sDevice::TLOCK_E: unlock mutex error\n"); exit(1); }}
528 FD_ERR(
"sDevice("<<
mName<<
")::Start(): cannot creat thread\n");
545 FD_DHV(
"sDevice("<<
mName<<
")::Stop(): Lock passed, waiting to join thread");
550 FD_ERR(
"sDevice("<<
mName<<
")::Stop(): cannot join thread??\n");
566 FD_DHV(
"sDevice("<<
mName<<
")::Reset(): reset signals");
603 std::vector<AttributeSignalInput::Trigger>::const_iterator ait;
613 std::vector<AttributeSignalOutput::Action>::const_iterator ait;
620 "Inv-Action is only supported with SyncWrite", 52);
633 #ifdef FAUDES_DEBUG_IODEVICE
636 FD_DH(
"sDevice(" <<
mName <<
")::Compile(): output signal at address " << i);
696 FD_DHV(
"sDevice(" <<
mName <<
")::CycleTime(int)");
698 std::stringstream errstr;
699 errstr <<
"Changing cycle-time not possible while background thread is still running ";
700 throw Exception(
"sDevice::CycleTime: ", errstr.str(), 100);
708 FD_DHV(
"sDevice(" <<
mName <<
")::ReadSignal(int)");
711 std::stringstream errstr;
712 errstr <<
"(" <<
mName <<
") is not able to read signals";
713 throw Exception(
"sDevice::ReadSignal():", errstr.str(), 552);
717 std::stringstream errstr;
718 errstr <<
"Signal access not possible while background thread is not running ";
719 throw Exception(
"sDevice::ReadSignal: ", errstr.str(), 552);
737 FD_DHV(
"sDevice(" <<
mName <<
")::WriteSignal(int)");
740 std::stringstream errstr;
741 errstr <<
"(" <<
mName <<
") is not configured for outputs";
742 throw Exception(
"sDevice::WriteSignal():", errstr.str(), 552);
746 std::stringstream errstr;
747 errstr <<
"Signal access not possible while background thread is not running ";
748 throw Exception(
"sDevice::ReadSignal: ", errstr.str(), 552);
780 FD_DH(
"sDevice(" << sdevice->
mName <<
")::Synchro(" << sdevice <<
"): with ct " << sdevice->
mCycleTime);
782 #ifdef FAUDES_DEBUG_IOTIMING_X
790 faudes_systime_t* timeA =
new faudes_systime_t[MAX_SAMPLES];
791 faudes_systime_t* timeB =
new faudes_systime_t[MAX_SAMPLES];
792 faudes_systime_t* timeC =
new faudes_systime_t[MAX_SAMPLES];
796 faudes_gettimeofday(timeA+itime);
804 faudes_systime_t timeL1;
805 faudes_gettimeofday(&timeL1);
819 FD_DHV(
"sDevice("<<sdevice->
Name()<<
")::synchro: reset: clear lines");
835 FD_DHV(
"sDevice("<<sdevice->
Name()<<
")::synchro: reset: edge detection");
877 FD_DHV(
"sDevice::synchro: sensed positive edge at bit address " << bit);
883 for(; eit!=eit_end; eit++) {
888 FD_DHV(
"sDevice::synchro: send signal " );
893 FD_DHV(
"sDevice::synchro: sensed negative edge at bit address " << bit);
900 for(; eit!=eit_end; eit++) {
905 FD_DHV(
"sDevice::synchro: send signal " );
925 if(!level->
edge)
continue;
944 #ifdef FAUDES_DEBUG_IOTIMING_X
947 if(itime < MAX_SAMPLES) faudes_gettimeofday(timeB+itime);
951 faudes_systime_t timeL2;
952 faudes_gettimeofday(&timeL2);
953 long int delta = (timeL2.tv_nsec - timeL1.tv_nsec)/1000;
954 delta+= 1000000 * (timeL2.tv_sec - timeL1.tv_sec);
961 #ifdef FAUDES_DEBUG_IOTIMING_X
966 if(itime < MAX_SAMPLES) faudes_gettimeofday(timeC+itime);
969 if(itime < MAX_SAMPLES) faudes_gettimeofday(timeA+itime);
977 #ifdef FAUDES_DEBUG_IOTIMING_X
982 FD_DHT(
"sDevice::synchro: performance analysis");
987 SamplesA.
Name(
"time stamp AA: overall period");
992 SamplesB.
Name(
"time stamp AB: process time");
997 SamplesC.
Name(
"time stamp CB: sleep time");
1002 SamplesWS.
Name(
"time passed till the next call of WaitInputs");
1005 faudes_systime_t dAA,dBA,dCB,dER;
1009 for(
int ind = 0; ind < itime-2; ind++){
1020 SamplesA.
Sample(dAA.tv_sec*1000000 + dAA.tv_nsec/1000);
1021 SamplesB.
Sample(dBA.tv_sec*1000000 + dBA.tv_nsec/1000);
1022 SamplesC.
Sample(dCB.tv_sec*1000000 + dCB.tv_nsec/1000);
1023 SamplesWS.
Sample(1000000*dER.tv_sec + dER.tv_nsec/1000);
1039 std::cout << SamplesA.
Str() << std::endl;
1040 std::cout << SamplesB.
Str() << std::endl;
1041 std::cout << SamplesC.
Str() << std::endl;
1042 std::cout << SamplesWS.
Str() << std::endl;
1045 FD_DH(
"sDevice(" << sdevice->
mName <<
")::synchro: terminate background thread");
1046 faudes_thread_exit(NULL);
1054 FD_DHV(
"sDevice("<<
mName<<
")::WriteOutput(" << output <<
")");
1059 std::stringstream errstr;
1060 errstr <<
"Unknown output event " << output;
1061 throw Exception(
"sDevice::WriteOutput", errstr.str(), 65);
1066 std::stringstream errstr;
1067 errstr <<
"Invalid output attribute " << output;
1068 throw Exception(
"sDevice::WriteOutput", errstr.str(), 65);
1071 FD_DHV(
"sDevice("<<
mName<<
")::WriteOutput: properties found");
1073 std::vector<AttributeSignalOutput::Action>::const_iterator eit;
1080 FD_DHV(
"sDevice("<<
mName<<
")::WriteOutput: mBit "<<eit->mBit<<
" mValue "<<eit->mValue);
1092 FD_DHV(
"sDevice("<<
mName<<
")::WriteOutput: mBit "<<eit->mBit<<
" mValue "<<eit->mValue);
1094 switch(eit->mValue) {
1096 level->
next=1;
break;
1098 level->
next=0;
break;
1109 FD_DHV(
"sDevice("<<
mName<<
")::WriteOutput: done");
1118 FD_DHV(
"sDevice("<<
mName<<
")::ClrInputSignals(): lock mutex ");
1120 FD_DHV(
"sDevice("<<
mName<<
")::ClrInputSignals(): edge detection ");
1124 FD_DHV(
"sDevice("<<
mName<<
")::ClrInputSignals(): edge detetion ReadSignal bit " << bit);
1137 FD_DHV(
"sDevice("<<
mName<<
")::ClrInputSignals(): edge detetion ReadSignal bit " << bit);
1149 FD_DHV(
"sDevice("<<
mName<<
")::ClrInputSignals(): initialize recent edges ");
1156 redge->
lost =
false;
1164 FD_DHV(
"sDevice("<<
mName<<
")::ClrInputSignals(): done");
1175 FD_DHV(
"sDevice("<<
mName<<
")::ClrOutputSignals: passed lock");
1192 FD_DHV(
"sDevice("<<
mName<<
")::ClrOutputSignals: done");