EvalGraphBuilder::EvalUnit EvalGraphBuilder::createEvalUnit( const std::list<Component>& comps, const std::list<Component>& ccomps) { LOG_SCOPE(ANALYZE,"cEU",true); if( Logger::Instance().shallPrint(Logger::DBG) ) { DBGLOG(DBG,"= EvalGraphBuilder::createEvalUnit(" << printrange(comps) << "," << printrange(ccomps) << ")"); BOOST_FOREACH(Component c, comps) { const ComponentInfo& ci = cg.propsOf(c); if( !ci.innerEatoms.empty() ) DBGLOG(DBG," compi " << printManyToString<RawPrinter>(ci.innerEatoms, ",", registry())); if( !ci.outerEatoms.empty() ) DBGLOG(DBG," compo " << printManyToString<RawPrinter>(ci.outerEatoms, ",", registry())); if( !ci.innerRules.empty() ) DBGLOG(DBG," compr " << printManyToString<RawPrinter>(ci.innerRules, "\n", registry())); if( !ci.innerConstraints.empty() ) DBGLOG(DBG," compc " << printManyToString<RawPrinter>(ci.innerConstraints, "\n", registry())); } BOOST_FOREACH(Component c, ccomps) { const ComponentInfo& ci = cg.propsOf(c); assert( ci.innerRules.empty() && ci.innerEatoms.empty() && ci.outerEatoms.empty() ); if( !ci.innerConstraints.empty() ) DBGLOG(DBG," ccompc " << printManyToString<RawPrinter>(ci.innerConstraints, "\n", registry())); } }
void transitivePredecessorComponents(const ComponentGraph& compgraph, Component from, Set& preds) { // we need a hash map, as component graph is no graph with vecS-storage // typedef boost::unordered_map<Component, boost::default_color_type> CompColorHashMap; typedef boost::associative_property_map<CompColorHashMap> CompColorMap; CompColorHashMap ccWhiteHashMap; // fill white hash map ComponentIterator cit, cit_end; for(boost::tie(cit, cit_end) = compgraph.getComponents(); cit != cit_end; ++cit) { //boost::put(ccWhiteHashMap, *cit, boost::white_color); ccWhiteHashMap[*cit] = boost::white_color; } CompColorHashMap ccHashMap(ccWhiteHashMap); // // do DFS // DFSVisitor dfs_vis(compgraph, preds); //LOG("doing dfs visit for root " << *itr); boost::depth_first_visit( compgraph.getInternalGraph(), from, dfs_vis, CompColorMap(ccHashMap)); DBGLOG(DBG,"predecessors of " << from << " are " << printrange(preds)); }
main () { auto int channel, value1, value2; auto float voltage, volts1, volts2; auto unsigned int rawdata, gaincode; auto char buffer[64]; brdInit(); while (1) { do { printf("\nChoose channel 0 - 6 .... "); gets(buffer); channel = atoi(buffer); } while(channel < 0 || channel > 6); printrange(); do { printf("\nChoose gain code .... "); gets(buffer); gaincode = atoi(buffer); } while(gaincode < 0 || gaincode > 7); printf("\nAdjust to lower voltage of %s and enter actual = ", vstr[gaincode]); gets(buffer); volts1 = atof(buffer); value1 = anaIn(channel, SINGLE, gaincode); if (value1 == ADOVERFLOW) printf("lo: channel=%d overflow\n", channel); else printf("lo: channel=%d raw=%d\n", channel, value1); printf("\nAdjust to higher voltage of %s and enter actual = ", vstr[gaincode]); gets(buffer); volts2 = atof(buffer); value2 = anaIn(channel, SINGLE, gaincode); if (value2 == ADOVERFLOW) printf("hi: channel=%d overflow\n", channel); else printf("hi: channel=%d raw=%d\n", channel, value2); anaInCalib(channel, SINGLE, gaincode, value1, volts1, value2, volts2); printf("\nstore constants to flash\n"); anaInEEWr(channel, SINGLE, gaincode); printf("\nread back constants\n"); anaInEERd(channel, SINGLE, gaincode); printf("\nVary voltage from 0 - 10 .... \n"); while (strcmp(buffer,"q") && strcmp(buffer,"Q")) { voltage = anaInVolts(channel, gaincode); printf("Ch %2d Volt=%.5f \n", channel, voltage); printf("press enter key to read values again or 'Q' to calibrate another channel\n\n"); gets(buffer); } } }
void main () { auto int channel; auto float voltage; auto unsigned int rawdata, gaincode; auto char buffer[64]; brdInit(); while (1) { printrange(); printf("\nChoose gain code .... "); gets(buffer); gaincode = atoi(buffer); printf("\nAdjust to lower voltage of %s and enter actual = ", vstr[gaincode]); gets(buffer); for (channel=STARTCHAN; channel<=ENDCHAN; channel++) { ln[channel].volts1 = atof(buffer); ln[channel].value1 = anaIn(channel, SINGLE, gaincode); if (ln[channel].value1 == ADOVERFLOW) printf("lo: channel=%d overflow\n", channel); else printf("lo: channel=%d raw=%d\n", channel, ln[channel].value1); } printf("\nAdjust to higher voltage of %s and enter actual = ", vstr[gaincode]); gets(buffer); for (channel=STARTCHAN; channel<=ENDCHAN; channel++) { ln[channel].volts2 = atof(buffer); ln[channel].value2 = anaIn(channel, SINGLE, gaincode); if (ln[channel].value2 == ADOVERFLOW) printf("hi: channel=%d overflow\n", channel); else printf("hi: channel=%d raw=%d\n", channel, ln[channel].value2); } for (channel=STARTCHAN; channel<=ENDCHAN; channel++) { anaInCalib(channel, SINGLE, gaincode, ln[channel].value1, ln[channel].volts1,ln[channel].value2, ln[channel].volts2); } printf("\nstore constants to flash\n"); anaInEEWr(ALLCHAN, SINGLE, gaincode); //store all channels printf("\nread back constants\n"); anaInEERd(ALLCHAN, SINGLE, gaincode); //read all channels printf("\nVary voltage %s\n", vstr[gaincode]); while (strcmp(buffer,"q") && strcmp(buffer,"Q")) { for (channel=STARTCHAN; channel<=ENDCHAN; channel++) { voltage = anaInVolts(channel, gaincode); printf("Ch %2d Volt=%.5f \n", channel, voltage); } printf("press enter key to read values again or 'Q' to calibrate another gain\n\n"); gets(buffer); } } }
void main () { auto int channel, keypress; auto int key; auto int gaincode; auto float voltage; auto int mode; auto char s[128]; // Initialize the controller brdInit(); // Configure channels 0-7 for Single-Ended unipolar mode of operation. // (Max voltage range is 0 - 20v) for (channel = 0; channel < BL_ANALOG_IN; ++channel) { anaInConfig(channel, SE0_MODE); } while (1) { printrange(); printf(" Choose gain code (0-%d) = ", BL_MAX_GAINS - 1); do { while(!kbhit()); // wait for key hit key = getchar() - '0'; } while (key < 0 || key >= BL_MAX_GAINS); gaincode = key; printf("%d", gaincode); blankScreen(); DispStr(1, 2, "A/D input voltage for channels 0 - 7"); DispStr(1, 3, "------------------------------------"); DispStr(1, 14, "Press key to select another gain option."); while(1) { for (channel = 0; channel < BL_ANALOG_IN; ++channel) { voltage = anaInVolts(channel, gaincode); if (voltage > BL_ERRCODESTART) { // valid read sprintf(s, "Channel = %2d Voltage = %.3fV ", channel, voltage); } else if (voltage == BL_NOT_CAL) { sprintf(s, "Channel = %2d Voltage = Not Calibrated ", channel); } else { sprintf(s, "Channel = %2d Voltage = Exceeded Range ", channel); } DispStr(1,channel + 4, s); } if (kbhit()) { getchar(); blankScreen(); while (kbhit()) { getchar(); } break; } } } } //end main
void main () { auto long value1, value2; auto unsigned int rawdata; auto int channel, gaincode; auto int key, i; auto float voltage, volts1, volts2, cal_voltage; auto char buffer[64]; // Initialize the controller brdInit(); // Configure channel pair 0 & 1 for Single-Ended bipolar mode of operation. // (Max voltage range is �V) anaInConfig(0, SE1_MODE); // Configure channel pair 2 & 3 for Single-Ended bipolar mode of operation // (Max voltage range is �V) anaInConfig(1, SE1_MODE); // Configure channel pair 4 & 5 for Single-Ended bipolar mode of operation // (Max voltage range is �V) anaInConfig(2, SE1_MODE); // Configure channel pair 6 & 7 for Single-Ended bipolar mode of operation // (Max voltage range is �V) anaInConfig(3, SE1_MODE); while(1) { DispStr(1, 1,"!!!Caution this will overwrite the calibration constants set at the factory."); DispStr(1, 2,"Do you want to continue(Y/N)?"); while(!kbhit()); key = getchar(); if(key == 'Y' || key == 'y') { break; } else if(key == 'N' || key == 'n') { exit(0); } } while(kbhit()) getchar(); while (1) { printf("\n\nPlease enter an ADC channel, 0 thru 7...."); do { channel = getchar(); } while (!( (channel >= '0') && (channel <= '7')) ); channel = channel - 0x30; printf("%d", channel); while(kbhit()) getchar(); printrange(); printf("\nChoose gain code .... "); do { gaincode = getchar(); } while (!( (gaincode >= '0') && (gaincode <= '5')) ); gaincode = gaincode - 0x30; printf("%d", gaincode); while(kbhit()) getchar(); cal_voltage = vmax[gaincode]*.8; printf("\nAdjust Power connected to AIN%d to approx. %.2f\n", channel, cal_voltage); printf("and then enter actual voltage = "); gets(buffer); volts1 = atof(buffer); value1 = 0; for(i=0; i<10; i++) value1 += anaIn(channel, gaincode); value1 = value1/10; printf("Hi: channel=%d raw=%d\n", channel, value1); printf("\nSwap power supply connections and then PRESS any key\n"); while(!kbhit()); while(kbhit()) getchar(); volts2 = -volts1; value2 = 0; for(i=0; i<10; i++) value2 += anaIn(channel, gaincode); value2 = value2/10; printf("Lo: channel=%d raw=%d\n", channel, value2); anaInCalib(channel, SE1_MODE, gaincode, (int) value1, volts1, (int) value2, volts2); printf("\nVary voltage within the range selected.... \n"); do { voltage = anaInVolts(channel, gaincode); printf("Ch %2d Volt=%.4f \n", channel, voltage); printf("Press ENTER key to read values again or 'Q' to calibrate another channel\n\n"); while(!kbhit()); key = getchar(); while(kbhit()) getchar(); } while(key != 'q' && key != 'Q'); } }
void main () { auto long average; auto unsigned int rawdata; auto int channel, gaincode; auto int key, i; auto float voltage, cal_voltage; auto char buffer[64]; brdInit(); while(1) { DispStr(1, 1,"!!!Caution this will overwrite the calibration constants set at the factory."); DispStr(1, 2,"Do you want to continue(Y/N)?"); while(!kbhit()); key = getchar(); if(key == 'Y' || key == 'y') { break; } else if(key == 'N' || key == 'n') { exit(0); } } while (1) { printrange(); printf("\nChoose gain code .... "); do { gaincode = getchar(); } while (!( (gaincode >= '0') && (gaincode <= '7')) ); gaincode = gaincode - 0x30; printf("%d", gaincode); while(kbhit()) getchar(); cal_voltage = .1*vmax[gaincode]; printf("\nAdjust to approx. %.4f and then enter actual voltage = ", cal_voltage); gets(buffer); for (channel=STARTCHAN; channel<=ENDCHAN; channel++) { ln[channel].volts1 = atof(buffer); average = 0; for(i=0; i<10; i++) average += anaIn(channel, SE_MODE, gaincode); ln[channel].value1 = (int)average/10; printf("lo: channel=%d raw=%d\n", channel, ln[channel].value1); } while(kbhit()) getchar(); cal_voltage = .9*vmax[gaincode]; printf("\nAdjust to approx. %.4f and then enter actual voltage = ", cal_voltage); gets(buffer); for (channel=STARTCHAN; channel<=ENDCHAN; channel++) { ln[channel].volts2 = atof(buffer); average = 0; for(i=0; i<10; i++) average += anaIn(channel, SE_MODE, gaincode); ln[channel].value2 = (int)average/10; printf("hi: channel=%d raw=%d\n", channel, ln[channel].value2); } while(kbhit()) getchar(); for (channel=STARTCHAN; channel<=ENDCHAN; channel++) { anaInCalib(channel, SE_MODE, gaincode, ln[channel].value1, ln[channel].volts1, ln[channel].value2, ln[channel].volts2); } printf("\nstore constants to flash\n"); for (channel=STARTCHAN; channel<=ENDCHAN; channel++) { anaInEEWr(channel, SE_MODE, gaincode); //store all channels } printf("\nread back constants\n"); anaInEERd(ALL_CHANNELS, SE_MODE, gaincode); //read all channels printf("\nVary voltage within the range selected\n"); do { for (channel=STARTCHAN; channel<=ENDCHAN; channel++) { voltage = anaInVolts(channel, gaincode); printf("Ch %2d Volt=%.5f \n", channel, voltage); } printf("Press ENTER key to read values again or 'Q' to calibrate another gain\n\n"); while(!kbhit()); key = getchar(); while(kbhit()) getchar(); }while(key != 'q' && key != 'Q'); } }
void main () { auto int device0, status; auto char buffer[64]; auto rn_search newdev; auto rn_AinData aindata; auto float voltage, cal_voltage; auto int rawdata; auto int gaincode; auto int data1, data2; auto int channel; auto int key; brdInit(); rn_init(RN_PORTS, 1); //initialize controller RN ports //search for device match newdev.flags = MATCHFLAG; newdev.productid = MATCHPID; if ((device0 = rn_find(&newdev)) == -1) { printf("\n no device found\n"); exit(0); } while(1) { DispStr(1, 1,"!!!Caution this will overwrite the calibration constants set at the factory."); DispStr(1, 2,"Do you want to continue(Y/N)?"); while(!kbhit()); key = getchar(); if(key == 'Y' || key == 'y') { break; } else if(key == 'N' || key == 'n') { exit(0); } } printf("\n"); while(kbhit()) getchar(); while (1) { // display the voltage that was read on the A/D channels printrange(); printf("\nChoose Voltage Configuration for the ADC Board 0 - 7.... "); do { gaincode = getchar(); } while (!( (gaincode >= '0') && (gaincode <= '7')) ); gaincode = gaincode - 0x30; printf("%d", gaincode); while(kbhit()) getchar(); // enable on all channels for conversions for(channel = 0; channel < 8; channel++) { status = rn_anaInConfig(device0, channel, RNSINGLE, gaincode, 0); } cal_voltage = .1*vmax[gaincode]; printf("\nAdjust to approx. %.4f and then enter actual voltage = ", cal_voltage); gets(buffer); for (channel=0; channel < 8; channel++) { ln[channel].volts1 = atof(buffer); status = rn_anaIn(device0, channel, &data1, NUMSAMPLES, 0); ln[channel].value1 = data1; if (ln[channel].value1 == ADOVERFLOW) printf("lo: channel=%d overflow\n", channel); else printf("lo: channel=%d raw=%d\n", channel, ln[channel].value1); } cal_voltage = .9*vmax[gaincode]; printf("\nAdjust to approx. %.4f and then enter actual voltage = ", cal_voltage); gets(buffer); for (channel=0; channel < 8; channel++) { ln[channel].volts2 = atof(buffer); status = rn_anaIn(device0, channel, &data2, NUMSAMPLES, 0); ln[channel].value2 = data2; if (ln[channel].value2 == ADOVERFLOW) printf("hi: channel=%d overflow\n", channel); else printf("hi: channel=%d raw=%d\n", channel, ln[channel].value2); } printf("\nstore all constants to flash\n"); for (channel=0; channel < 8; channel++) { rn_anaInCalib(channel, RNSINGLE, gaincode, ln[channel].value1, ln[channel].volts1,ln[channel].value2, ln[channel].volts2, &aindata); printf("gain=%8.5f offset=%d\n", aindata.gain, aindata.offset); status = rn_anaInWrCalib(device0, channel, RNSINGLE, gaincode, aindata, 0); } printf("\nread back constants\n"); for (channel=0; channel < 8; channel++) { status = rn_anaInRdCalib(device0, channel, RNSINGLE, gaincode, &aindata, 0); printf("read back gain=%8.5f offset=%d\n", aindata.gain, aindata.offset); } //After writing constants to flash, you must hard reset to close // off flash writes. Wait 1 second to make sure device reinitializes // and clear the reset register. rn_reset(device0, 0); rn_msDelay(1000); //Check and clear reset status if(!((status = rn_rst_status(device0, buffer)) & 0x01)) { printf("Error! ADC board didn't reset"); exit(1); } status = rn_enable_wdt(device0, 1); //enable device hardware watchdog // Must enable on all channels for conversions again after reset for(channel = 0; channel < 8; channel++) { status = rn_anaInConfig(device0, channel, RNSINGLE, gaincode, 0); } printf("\nVary power supply for the voltage range selected.... \n\n"); do { for(channel = 0; channel < 8; channel++) { status = rn_anaInVolts(device0, channel, &voltage, NUMSAMPLES, 0); printf("Ch %2d Volt=%.5f \n", channel, voltage); } printf("Press ENTER key to read value again or 'Q' to select another gain option\n\n"); while(!kbhit()); key = getchar(); while(kbhit()) getchar(); }while(key != 'q' && key != 'Q'); } }