void CpPrint( void ) { //================= // Compile PRINT statement. itnode *cit; InitIO(); Form(); if( !RecEOS() ) { ReqComma(); if( RecNOpn() ) { cit = CITNode; AdvanceITPtr(); if( RecEOS() ) { CITNode = cit; Error( SX_SURP_OPR ); } CITNode = cit; } } IOList(); ReqEOS(); FiniIO(); }
void ImageGroundTruthPanelViewer::on_key_down(wxKeyEvent & event) { if(event.ControlDown() && event.GetUnicodeKey() == 'O') { InitIO(); return; } if(mp_ground_truth_manager->IsEmpty()) { return ; } try { switch(event.GetKeyCode()) { case WXK_PAGEUP: LoadNextImage(); break; case WXK_PAGEDOWN: LoadPreviousImage(); break; } if(event.ControlDown()) { switch(event.GetUnicodeKey()) { case 'S': Save(); break; case 'Z': Undo(); break; case 'Y': Redo(); break; case 'A': MarkAsBlind(); break; case 'I': MarkAsUnknown(); break; case 'R': Reject(); break; } } } JPB_wx_CATCH("échec de l'ajout d'une boîtes englobante d'occlusion"); }
void CpRead( void ) { //================ // Compile READ statement. itnode *cit; Remember.read = true; InitIO(); cit = CITNode; AdvanceITPtr(); if( RecOpenParen() && ReadKWList() ) { KeywordList(); ReqCloseParen(); } else { CITNode = cit; Form(); if( !RecEOS() ) { ReqComma(); } } if( !Remember.end_equals ) { GNullEofStmt(); } IOList(); ReqEOS(); FiniIO(); }
int main(void) { InitIO(); init_ADC(); InitTimer1(); InitTimer2(); InitExtInt(); while(1) { switch(display_select) { case 0x00: MusicOnLed(); break; case 0x01: FadeOnLed(); break; case 0x02: StrobeOnLed(100, 100, 100); break; /* . . TODO:: Sync up pin change interrupts for the last push button . */ case 0xFF: ColorOnLed(1,0,1); break; } } }
void melt2 () { register short i, j, k, r, c; /* Huffman-dependent part */ if(read_header() == EOF) return; StartHuff(N_CHAR2); init(Table2); /* end of Huffman-dependent part */ InitIO(); for (i = 0; i < N2 - F2; i++) text_buf[i] = ' '; r = N2 - F2; for (in_count = 0;; ) { c = DecodeChar(); if (c == ENDOF) break; if (c < 256) { #ifdef DEBUG if (debug) fprintf(stderr, "'%s'\n", pr_char((uc_t)c)); else #endif /* DEBUG */ putchar (c); text_buf[r++] = c; r &= N2 - 1; in_count++; } else { i = (r - DecodePosition() - 1) & (N2 - 1); j = c - 256 + THRESHOLD; #ifdef DEBUG if (debug) fputc('"', stderr); #endif for (k = 0; k < j; k++) { c = text_buf[(i + k) & (N2 - 1)]; #ifdef DEBUG if (debug) fprintf(stderr, "%s", pr_char((uc_t)c)); else #endif putchar (c); text_buf[r++] = c; r &= (N2 - 1); in_count++; } #ifdef DEBUG if (debug) fprintf(stderr, "\"\n"); #endif } INDICATOR } }
/****************************************************************************** * Initial subroutine * * This subroutine performs all initializations of variables and registers. * It enables TMR1, initializes SPI, and USART, sets up low and high * priority interrupts, sets up the LCD, and configures all I/O pins. * * Inputs: None * Outputs: None ******************************************************************************/ void Initial(void) { char i; OSCCON = 0b01100100; //Oscillator control register, see data // sheet, pp.43 - 45 ODCON1 = 0x00; //Output Drain register, see data sheet // pp. 167 //Set up all I/O ports InitIO(); //Clear Holding register for incoming USART data for (i = 0; i < 10; i++) { Hold[i] = 0; } //Configuring Interrupts RCONbits.IPEN = 1; //Enable priority levels INTCON2bits.TMR0IP = 0; //Assign low priority to TMR0 interrupt INTCONbits.TMR0IE = 1; //Enable TMR0 interrupts IPR1bits.ADIP = 0; //Assign low priority to AD converter PIE1bits.ADIE = 1; //Enable AD interrupts IPR1bits.RC1IP = 1; //Assign high priority to USART PIE1bits.RC1IE = 1; //Enable USART interrupts IPR1bits.TMR1IP = 0; PIE1bits.TMR1IE = 1; INTCONbits.GIEL = 1; //Enable low-priority interrupts to CPU INTCONbits.GIEH = 1; //Enable all interrupts //Set up Timer0 T0CON = 0b00000101; //16-bit, Fosc/4, prescaler 64 TMR0L = TMRL; //Load Timer0 with correct values TMR0H = TMRH; // for 1 second //Set up Timer1 T1CON = 0b00000010; TMR1H = 0; TMR1L = 0; WakeXBEE(); //Wake XBee from sleep Delay10KTCYx(10); //Set up the A/D converter ADCON0 = 0b00001001; //Set up to read temp data on RA2 ADCON1 = 0b00000000; //VDD = 3.3V and VSS = GND ADCON2 = 0b00100001; //Left Just., TAD = 8, FOSC/8 ANCON0 = 0b00000100; //Set AN2 as analog input //Set up the USART InitUSART(); //Initialize the USART on USART1 //Set up SPI InitSPI1(); //Initialize the SPI on MSSP1 T0CONbits.TMR0ON = 1; //Turn on TMR0 }
/// /// @brief Init required IO-pins. This function should be called as /// early as possible in a systems with several SPI-devices. /// /// @param None /// @return None /// void libRFM69_InitHW(void) { InitReset(); InitCS(); ReleaseCS(); InitIO(); return; }
int main(void) { int flag = 0; TIM2_Init(); InitIO(); while(1) { if(tick_1ms >= 5)//500 { tick_1ms = 0; flag = !flag; if(flag == 0) { GPIO_SetBits(GPIOA , 0xaaaa); GPIO_SetBits(GPIOB , 0xaaaa); GPIO_SetBits(GPIOC , 0xaaaa); GPIO_SetBits(GPIOD , 0xaaaa); GPIO_SetBits(GPIOE , 0xaaaa); GPIO_SetBits(GPIOF , 0xaaaa); GPIO_SetBits(GPIOG , 0xaaaa); GPIO_ResetBits(GPIOA , 0x5555); GPIO_ResetBits(GPIOB , 0x5555); GPIO_ResetBits(GPIOC , 0x5555); GPIO_ResetBits(GPIOD , 0x5555); GPIO_ResetBits(GPIOE , 0x5555); GPIO_ResetBits(GPIOF , 0x5555); GPIO_ResetBits(GPIOG , 0x5555); }else { GPIO_ResetBits(GPIOA , 0xaaaa); GPIO_ResetBits(GPIOB , 0xaaaa); GPIO_ResetBits(GPIOC , 0xaaaa); GPIO_ResetBits(GPIOD , 0xaaaa); GPIO_ResetBits(GPIOE , 0xaaaa); GPIO_ResetBits(GPIOF , 0xaaaa); GPIO_ResetBits(GPIOG , 0xaaaa); GPIO_SetBits(GPIOA , 0x5555); GPIO_SetBits(GPIOB , 0x5555); GPIO_SetBits(GPIOC , 0x5555); GPIO_SetBits(GPIOD , 0x5555); GPIO_SetBits(GPIOE , 0x5555); GPIO_SetBits(GPIOF , 0x5555); GPIO_SetBits(GPIOG , 0x5555); } } } }
void melt1 () { register short i, j, k, r, c; StartHuff(N_CHAR1); init(Table1); InitIO(); for (i = 0; i < N1 - F1; i++) text_buf[i] = ' '; r = N1 - F1; for (in_count = 0;; ) { c = DecodeChar(); if (c == ENDOF) break; if (c < 256) { #ifdef DEBUG if (debug) fprintf(stderr, "'%s'\n", pr_char((uc_t)c)); else #endif /* DEBUG */ putchar (c); text_buf[r++] = c; r &= (N1 - 1); in_count++; } else { i = (r - DecodePOld() - 1) & (N1 - 1); j = c - 256 + THRESHOLD; #ifdef DEBUG if (debug) fputc('"', stderr); #endif for (k = 0; k < j; k++) { c = text_buf[(i + k) & (N1 - 1)]; #ifdef DEBUG if (debug) fprintf(stderr, "%s", pr_char((uc_t)c)); else #endif putchar (c); text_buf[r++] = c; r &= (N1 - 1); in_count++; } #ifdef DEBUG if (debug) fprintf(stderr, "\"\n"); #endif } INDICATOR } }
static void JustList( void ) { //========================== // The io statement must have a keyword list in brackets. InitIO(); if( RecTrmOpr() && RecNOpn() ) { AdvanceITPtr(); } if( ReqOpenParen() ) { DoKWList(); } ReqEOS(); GStartIO(); FiniIO(); }
void CpWrite( void ) { //================= // Compile WRITE statement. InitIO(); if( RecTrmOpr() && RecNOpn() ) { AdvanceITPtr(); } if( ReqOpenParen() ) { KeywordList(); ReqCloseParen(); IOList(); } ReqEOS(); FiniIO(); }
static void UnitOrList( void ) { //============================ // The io statement can have a unit id by itself or have a keyword list // in brackets. InitIO(); if( RecNextOpr( OPR_LBR ) && RecNOpn() ) { AdvanceITPtr(); DoKWList(); } else { Permission( IO_UNIT ); // remembers unit= specified Unit(); AdvanceITPtr(); } ReqEOS(); GStartIO(); FiniIO(); }
void main (void) { InitIO(); InitInputDataInt(); ALERT = 0; int count = 0; int recv = NO; Connection_t conn; RGB_DATA_RQT_CMD_t rqt; rqt.id = 255; while(1) { send_RGB_DATA_RQT_CMD(&conn, &rqt); if(get_msg(pmsg) == YES) { recv = YES; } if(count == 0) { if(recv == YES) { ALERT = 1; recv == NO; } else { ALERT = 0; } } __delay_ms(100); count++; if(count == 5) { count = 0; } } }
// Hardware startup sequence void SystemInit(void) { // Log the reason for resetting rcon_at_startup = RCON; RCON = 0; // 8 MHz FRC system clock (default) CLOCK_INTOSC(); // Set mcu to known state InitIO(); // IO pins CLOCK_SOSCDIS(); // We have an ex.osc, turn off internal SysTimeInit(); // Time module // Hardware regs - not needed really because these are defaults U1PWRCbits.USBPWR = 0; // Incase usb module is not disabled RCONbits.PMSLP = 0; // Ensure we use lowest power sleep // Set other hardware to known state myI2Cclear(); // Once only, finish any unfinished i2c comms }
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { WORD Board; double* Out; /* Check for proper number of arguments */ if (nrhs != 1) { mexErrMsgTxt("One input argument BoardNum, one output result; 0 is good."); return; } plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL); Out = mxGetPr(plhs[0]); Board = (WORD)mxGetScalar(prhs[0]); Out[0] = (double)InitIO(Board); }
int main(int argc, char* argv[]) { ProofState_p fstate; Scanner_p in; int i; CLState_p state; SpecFeatureCell features; SpecLimits_p limits; StrTree_p skip_includes = NULL; assert(argv[0]); InitIO(NAME); limits = SpecLimitsAlloc(); state = process_options(argc, argv, limits); OpenGlobalOut(outname); if(state->argc == 0) { CLStateInsertArg(state, "-"); } if(parse_features) { if(raw_classify) { process_raw_feature_files(state->argv, limits); } else { process_feature_files(state->argv, limits); } } else { for(i=0; state->argv[i]; i++) { fstate = ProofStateAlloc(FPIgnoreProps); in = CreateScanner(StreamTypeFile, state->argv[i], true, NULL); ScannerSetFormat(in, parse_format); FormulaAndClauseSetParse(in, fstate->axioms, fstate->f_axioms, fstate->original_terms, NULL, & skip_includes); if(raw_classify) { do_raw_classification(state->argv[i], fstate, limits); } else { FormulaSetPreprocConjectures(fstate->f_axioms, fstate->f_ax_archive, false, false); FormulaSetCNF(fstate->f_axioms, fstate->f_ax_archive, fstate->axioms, fstate->original_terms, fstate->freshvars, fstate->gc_original_terms); if(!no_preproc) { ClauseSetPreprocess(fstate->axioms, fstate->watchlist, fstate->archive, fstate->tmp_terms, eqdef_incrlimit, eqdef_maxclauses); } SpecFeaturesCompute(&features, fstate->axioms, fstate->signature); SpecFeaturesAddEval(&features, limits); if(!tptp_header) { fprintf(GlobalOut, "%s : ", state->argv[i]); SpecFeaturesPrint(GlobalOut, &features); fprintf(GlobalOut, " : "); SpecTypePrint(GlobalOut, &features, mask); fprintf(GlobalOut, "\n"); } else { print_tptp_header(fstate, features); } DestroyScanner(in); ProofStateFree(fstate); } } } CLStateFree(state); SpecLimitsCellFree(limits); fflush(GlobalOut); OutClose(GlobalOut); ExitIO(); #ifdef CLB_MEMORY_DEBUG MemFlushFreeList(); MemDebugPrintStats(stdout); #endif return 0; }
int main(){ unsigned char messageBuf[TWI_BUFFER_SIZE]; unsigned char TWI_slaveAddress; // Own TWI slave address TWI_slaveAddress = 0x20; InitIO(); defset(); InitTimer(); OSCCAL=0xA8; // wdt_reset(); /* Write logical one to WDCE and WDE */ // WDTCR = (1<<WDCE) | (1<<WDE) | (2<<WDP0); // WDTCR = (1<<WDE) | (2<<WDP0); TIMING=eeprom_read_word(&EETIMING); TWI_Slave_Initialise( (unsigned char)((TWI_slaveAddress<<TWI_ADR_BITS) | (FALSE<<TWI_GEN_BIT) )); sei(); TWI_Start_Transceiver(); while (1){ // Check if the TWI Transceiver has completed an operation. if ( ! TWI_Transceiver_Busy() ) { // Check if the last operation was successful if ( TWI_statusReg.lastTransOK ) { // Check if the last operation was a reception if ( TWI_statusReg.RxDataInBuf ) { PORTB^=1<<PB3; TWI_Get_Data_From_Transceiver(messageBuf, 2); // Check if the last operation was a reception as General Call if ( TWI_statusReg.genAddressCall ) { // Put data received out to PORTB as an example. // PORTB = messageBuf[0]; } else // Ends up here if the last operation was a reception as Slave Address Match { // Example of how to interpret a command and respond. switch (messageBuf[0]){ case xval: OCR1A=255-messageBuf[1]; break; case yval: OCR1B=255-messageBuf[1]; break; // TWI_Start_Transceiver_With_Data( messageBuf, 1 ); } } } else // Ends up here if the last operation was a transmission { // __no_operation(); // Put own code here. } // Check if the TWI Transceiver has already been started. // If not then restart it to prepare it for new receptions. if ( ! TWI_Transceiver_Busy() ) { TWI_Start_Transceiver(); } } else // Ends up here if the last operation completed unsuccessfully { TWI_Act_On_Failure_In_Last_Transmission( TWI_Get_State_Info() ); } } } }
/****************************************************************** Main ******************************************************************/ int main(void) { /*Disable watchdog*/ RCONbits.SWDTEN = 0; set_clk(); InitIO(); //Initialize CAN communication initialisation_CAN(); //Initialize PWM (Motor Control) Init_PWM(); //Initialize ADC //Init_ADC(); //Initialize QEI (Speed/Position DC motor) InitQEI(); chinookpack_unpacked_init(&unpacker); #ifdef memory_init /*Retrieve Last gear and mât position*/ do{ EEPROM_REQUEST = 0x55; envoi_CAN_periodique_init(); last_gear = datReceive_can_EEPROM_CONFIG_ANSWER_gear; last_position_mat = datReceive_can_EEPROM_CONFIG_ANSWER_mat; }while(datReceive_can_EEPROM_CONFIG_ANSWER_mat==190.0f); gear = last_gear; Position_mat = last_position_mat; char print[80]; sprintf(print,"last gear: %d \t last position mat : %f \r",last_gear,last_position_mat); char u=0; do { U1TXREG=print[u]; while(U1STAbits.TRMT!=1); u++; }while(print[u]!=0); int k=0; do{ EEPROM_REQUEST = 0xAA; envoi_CAN_periodique_init(); k++; }while(k<5); #endif /*Enable 24V supply switch*/ ENALIM = 1; //envoi_CAN_periodique(); //envoi_CAN_periodique(); //Transmission goes to first gear Stepper_Shift_Init(last_gear); //Mat goes to origin //Init_mat(last_position_mat); while(1) { //Transmission goes to first gear if(datReceive_can_conf) Stepper_Shift_Init(last_gear); Stepper_Shift(); envoi_CAN_periodique(); #ifdef mat_manuel if(!datReceive_can_cmd[0]) { if(last_cmd_mat == 14 || last_cmd_mat == 15){ cmd_mat=datReceive_can_cmd[3]|datReceive_can_cmd[2]|datReceive_can_cmd[1]|datReceive_can_cmd[0]; } if(last_cmd_mat == 11){ delai_mat++; cmd_mat = 0; if(delai_mat<60000) tower_motor_ctrl(&PDC1,Position_mat); else if(delai_mat>=60000) delai_mat = 0; } } else if(!datReceive_can_cmd[2]) { if(last_cmd_mat == 11 || last_cmd_mat == 15){ cmd_mat=datReceive_can_cmd[3]|datReceive_can_cmd[2]|datReceive_can_cmd[1]|datReceive_can_cmd[0]; } if(last_cmd_mat == 14){ cmd_mat = 0; delai_mat++; if(delai_mat<60000) tower_motor_ctrl(&PDC1,Position_mat); else if(delai_mat>=60000) delai_mat = 0; } } else //if(datReceive_can_cmd == 15) { cmd_mat=15; } if(cmd_mat ==14) { last_cmd_mat = cmd_mat; LED0^=1; tower_motor_ctrl(&PDC1,-180.0f); } else if(cmd_mat == 11) { last_cmd_mat = cmd_mat; tower_motor_ctrl(&PDC1,180.0f); } else if(cmd_mat == 15) { last_cmd_mat = cmd_mat; tower_motor_ctrl(&PDC1,Position_mat); } #endif #ifdef mat_test tower_motor_ctrl(&PDC1,-90.0f); #endif #ifdef mat_auto tower_motor_ctrl(&PDC1,datReceive_can_wind_direction); #endif } }
int main(int argc, char* argv[]) { CLState_p state; Scanner_p in; BatchSpec_p spec; StructFOFSpec_p ctrl; char *prover = "eprover"; char *category = NULL; char *train_dir = NULL; long now, start, res; assert(argv[0]); InitIO(NAME); DocOutputFormat = tstp_format; OutputFormat = TSTPFormat; state = process_options(argc, argv); OpenGlobalOut(outname); if((state->argc < 1) || (state->argc > 2)) { Error("Usage: e_ltb_runner <spec> [<path-to-eprover>] \n", USAGE_ERROR); } if(state->argc >= 2) { prover = state->argv[1]; } in = CreateScanner(StreamTypeFile, state->argv[0], true, NULL); ScannerSetFormat(in, TSTPFormat); AcceptDottedId(in, "division.category"); category = ParseDottedId(in); if(TestInpId(in, "division")) { AcceptDottedId(in, "division.category.training_directory"); train_dir = ParseContinous(in); } while(!TestInpTok(in, NoToken)) { start = GetSecTime(); spec = BatchSpecParse(in, prover, category, train_dir, TSTPFormat); /* BatchSpecPrint(GlobalOut, spec); */ if(total_wtc_limit && !spec->total_wtc_limit) { spec->total_wtc_limit = total_wtc_limit; } if(spec->per_prob_limit<=0 && total_wtc_limit<=0) { Error("Either the per-problem time limit or the global " "time limit must be set to a value > 0", USAGE_ERROR); } /* BatchSpecPrint(stdout, spec); */ ctrl = StructFOFSpecAlloc(); BatchStructFOFSpecInit(spec, ctrl); now = GetSecTime(); res = BatchProcessProblems(spec, ctrl, MAX(0,total_wtc_limit-(now-start))); now = GetSecTime(); fprintf(GlobalOut, "\n\n# == WCT: %4lds, Solved: %4ld/%4d ==\n", now-start, res, BatchSpecProblemNo(spec)); if(interactive) { BatchProcessInteractive(spec, ctrl, stdout); } StructFOFSpecFree(ctrl); BatchSpecFree(spec); fprintf(GlobalOut, "# =============== Batch done ===========\n\n"); } DestroyScanner(in); if(category) { FREE(category); } if(train_dir) { FREE(train_dir); } CLStateFree(state); OutClose(GlobalOut); ExitIO(); #ifdef CLB_MEMORY_DEBUG MemFlushFreeList(); MemDebugPrintStats(stdout); #endif return 0; }
int main(int argc, char* argv[]) { TB_p terms; GCAdmin_p collector; VarBank_p freshvars; Sig_p sig; ClauseSet_p clauses; FormulaSet_p formulas, f_ax_archive; Scanner_p in; int i; CLState_p state; StrTree_p skip_includes = NULL; ClauseSet_p demodulators[1]; OCB_p ocb; assert(argv[0]); InitIO(NAME); #ifdef STACK_SIZE IncreaseMaxStackSize(argv, STACK_SIZE); #endif ESignalSetup(SIGXCPU); state = process_options(argc, argv); OpenGlobalOut(outname); if(state->argc == 0) { CLStateInsertArg(state, "-"); } sig = SigAlloc(); SigInsertInternalCodes(sig); terms = TBAlloc(sig); collector = GCAdminAlloc(terms); clauses = ClauseSetAlloc(); formulas = FormulaSetAlloc(); f_ax_archive = FormulaSetAlloc(); GCRegisterClauseSet(collector, clauses); GCRegisterFormulaSet(collector, formulas); GCRegisterFormulaSet(collector, f_ax_archive); for(i=0; state->argv[i]; i++) { in = CreateScanner(StreamTypeFile, state->argv[i], true, NULL); ScannerSetFormat(in, parse_format); /* ClauseSetParseList(in, clauses, terms); */ FormulaAndClauseSetParse(in,clauses, formulas, terms, NULL, &skip_includes); CheckInpTok(in, NoToken); DestroyScanner(in); } CLStateFree(state); if(FormulaSetPreprocConjectures(formulas, f_ax_archive, false, false)) { VERBOUT("Negated conjectures.\n"); } freshvars = VarBankAlloc(); if(FormulaSetCNF(formulas, f_ax_archive, clauses, terms, freshvars, collector)) { VERBOUT("CNFization done\n"); } VarBankFree(freshvars); GCDeregisterFormulaSet(collector, formulas); FormulaSetFree(formulas); GCDeregisterFormulaSet(collector, f_ax_archive); FormulaSetFree(f_ax_archive); demodulators[0] = ClauseSetAlloc(); demodulators[0]->demod_index = PDTreeAlloc(); GCRegisterClauseSet(collector, demodulators[0]); build_rw_system(demodulators[0], clauses); GCDeregisterClauseSet(collector, clauses); ClauseSetFree(clauses); VERBOUT("# Demodulators\n"); VERBOSE(ClauseSetPrint(stderr, demodulators[0], true););
void InitApp(void) { PICLIB_Init(SYS_FREQ); InitIO(); Console_Init(); }
void main() { char outString[MAX_TX_LEN], inString[MAX_TX_LEN]; int i, j, ch, out_string_len; brdInit(); // The brdInit for this board sets pins that are not initially assigned to // hardware as outputs, such as the serial port Rx pins. The Rx pin for // serial port D is not set to an input because it is not used in this // sample. BitWrPortI(PCDDR, &PCDDRShadow, 0, 3); // set serial port C Rx as input serDopen(BAUDRATE); serCopen(BAUDRATE); #ifdef DIGITAL_IO_ACCESSORY InitIO(); #endif // Initialize DS1 LED (PDO) to output BitWrPortI(PDDDR, &PDDDRShadow, 0, 1); // Initialize DS1 LED (PDO) to output BitWrPortI(PDDDR, &PDDDRShadow, 1, 0); // Make sure PD0 not set to alternate function BitWrPortI(PDFR, &PDFRShadow, 0, 1); // Make sure PD0 not set to alternate function BitWrPortI(PDFR, &PDFRShadow, 0, 0); j = 0; while(1) { costate { // Bits for switches and LEDs correspond for (i = S1; i <= S4; i++) { #ifdef DIGITAL_IO_ACCESSORY if (!BitRdPortI(PBDR, i)) #else if (!BitRdPortI(PDDR, i)) #endif { // Delay so we don't output too many times waitfor(DelayMs(300)); // Light corresponding LED #ifdef DIGITAL_IO_ACCESSORY BitWrPortI(PADR, &PADRShadow, LEDON, i); #else BitWrPortI(PDDR, &PDDRShadow, LEDON, i-1); #endif sprintf(outString, "Switch %d is on\n", i-S1+1); out_string_len = strlen(outString); // Make sure there's room in ouput buffer waitfor(serDwrFree() > out_string_len); // Write string out serDwrite(outString, out_string_len); } else { #ifdef DIGITAL_IO_ACCESSORY BitWrPortI(PADR, &PADRShadow, LEDOFF, i); // LED off #else BitWrPortI(PDDR, &PDDRShadow, LEDOFF, i-1); #endif } } } // Wait for any ASCII input // serCgetc() returns -1 (0xFFFF) if no chars available if ( (ch = serCgetc()) != -1 ) { inString[j] = ch; j++; if (j >= MAX_TX_LEN) // Make sure we don't overflow { // array bounds in case 0x0A j = 0; // gets dropped. } else if (ch == '\n') // Check for new line as delimiter { inString[j] = 0; // NULL terminate printf("%s",inString); j = 0; } } } }
int main(int argc, char* argv[]) { int retval = NO_ERROR; CLState_p state; ProofState_p proofstate; ProofControl_p proofcontrol; Clause_p success = NULL, filter_success; bool out_of_clauses; char *finals_state = "exists", *sat_status = "Derivation"; long raw_clause_no, preproc_removed=0, neg_conjectures, parsed_ax_no, relevancy_pruned = 0; double preproc_time; assert(argv[0]); pid = getpid(); InitIO(NAME); #ifdef STACK_SIZE IncreaseMaxStackSize(argv, STACK_SIZE); #endif ESignalSetup(SIGXCPU); h_parms = HeuristicParmsAlloc(); fvi_parms = FVIndexParmsAlloc(); wfcb_definitions = PStackAlloc(); hcb_definitions = PStackAlloc(); state = process_options(argc, argv); OpenGlobalOut(outname); print_info(); if(state->argc == 0) { CLStateInsertArg(state, "-"); } proofstate = parse_spec(state, parse_format, error_on_empty, free_symb_prop, &parsed_ax_no); relevancy_pruned += ProofStateSinE(proofstate, sine); relevancy_pruned += ProofStatePreprocess(proofstate, relevance_prune_level); if(strategy_scheduling) { ExecuteSchedule(StratSchedule, h_parms, print_rusage); } FormulaSetDocInital(GlobalOut, OutputLevel, proofstate->f_axioms); ClauseSetDocInital(GlobalOut, OutputLevel, proofstate->axioms); if(prune_only) { fprintf(GlobalOut, "\n# Pruning successful!\n"); TSTPOUT(GlobalOut, "Unknown"); goto cleanup1; } if(relevancy_pruned || incomplete) { proofstate->state_is_complete = false; } if(BuildProofObject) { FormulaSetArchive(proofstate->f_axioms, proofstate->f_ax_archive); } if((neg_conjectures = FormulaSetPreprocConjectures(proofstate->f_axioms, proofstate->f_ax_archive, answer_limit>0, conjectures_are_questions))) { VERBOUT("Negated conjectures.\n"); } if(FormulaSetCNF(proofstate->f_axioms, proofstate->f_ax_archive, proofstate->axioms, proofstate->original_terms, proofstate->freshvars, proofstate->gc_original_terms)) { VERBOUT("CNFization done\n"); } ProofStateInitWatchlist(proofstate, watchlist_filename, parse_format); raw_clause_no = proofstate->axioms->members; if(!no_preproc) { if(BuildProofObject) { ClauseSetArchive(proofstate->ax_archive, proofstate->axioms); if(proofstate->watchlist) { ClauseSetArchive(proofstate->ax_archive, proofstate->watchlist); } } preproc_removed = ClauseSetPreprocess(proofstate->axioms, proofstate->watchlist, proofstate->archive, proofstate->tmp_terms, eqdef_incrlimit, eqdef_maxclauses); } proofcontrol = ProofControlAlloc(); ProofControlInit(proofstate, proofcontrol, h_parms, fvi_parms, wfcb_definitions, hcb_definitions); PCLFullTerms = pcl_full_terms; /* Preprocessing always uses full terms, so we set the flag for the main proof search only now! */ ProofStateInit(proofstate, proofcontrol); VERBOUT2("Prover state initialized\n"); preproc_time = GetTotalCPUTime(); if(print_rusage) { fprintf(GlobalOut, "# Preprocessing time : %.3f s\n", preproc_time); } if(proofcontrol->heuristic_parms.presat_interreduction) { LiteralSelectionFun sel_strat = proofcontrol->heuristic_parms.selection_strategy; proofcontrol->heuristic_parms.selection_strategy = SelectNoGeneration; success = Saturate(proofstate, proofcontrol, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX, LONG_MAX); fprintf(GlobalOut, "# Presaturation interreduction done\n"); proofcontrol->heuristic_parms.selection_strategy = sel_strat; if(!success) { ProofStateResetProcessed(proofstate, proofcontrol); } } PERF_CTR_ENTRY(SatTimer); if(!success) { success = Saturate(proofstate, proofcontrol, step_limit, proc_limit, unproc_limit, total_limit, answer_limit); } PERF_CTR_EXIT(SatTimer); out_of_clauses = ClauseSetEmpty(proofstate->unprocessed); if(filter_sat) { filter_success = ProofStateFilterUnprocessed(proofstate, proofcontrol, filterdesc); if(filter_success) { success = filter_success; PStackPushP(proofstate->extract_roots, success); } } if(success||proofstate->answer_count) { assert(!PStackEmpty(proofstate->extract_roots)); if(success) { DocClauseQuoteDefault(2, success, "proof"); } fprintf(GlobalOut, "\n# Proof found!\n"); if(!proofstate->status_reported) { TSTPOUT(GlobalOut, neg_conjectures?"Theorem":"Unsatisfiable"); proofstate->status_reported = true; retval = PROOF_FOUND; } if(BuildProofObject) { DerivationComputeAndPrint(GlobalOut, proofstate->extract_roots, proofstate->signature, proof_graph); } } else if(proofstate->watchlist && ClauseSetEmpty(proofstate->watchlist)) { ProofStatePropDocQuote(GlobalOut, OutputLevel, CPSubsumesWatch, proofstate, "final_subsumes_wl"); fprintf(GlobalOut, "\n# Watchlist is empty!\n"); TSTPOUT(GlobalOut, "ResourceOut"); retval = RESOURCE_OUT; } else { if(out_of_clauses&& proofstate->state_is_complete&& (inf_sys_complete || assume_inf_sys_complete)) { finals_state = "final"; } ProofStatePropDocQuote(GlobalOut, OutputLevel, CPIgnoreProps, proofstate, finals_state); if(cnf_only) { fprintf(GlobalOut, "\n# CNFization successful!\n"); TSTPOUT(GlobalOut, "Unknown"); } else if(out_of_clauses) { if(!(inf_sys_complete || assume_inf_sys_complete)) { fprintf(GlobalOut, "\n# Clause set closed under " "restricted calculus!\n"); if(!SilentTimeOut) { TSTPOUT(GlobalOut, "GaveUp"); } retval = INCOMPLETE_PROOFSTATE; } else if(proofstate->state_is_complete && inf_sys_complete) { fprintf(GlobalOut, "\n# No proof found!\n"); TSTPOUT(GlobalOut, neg_conjectures?"CounterSatisfiable":"Satisfiable"); sat_status = "Saturation"; retval = SATISFIABLE; } else { fprintf(GlobalOut, "\n# Failure: Out of unprocessed clauses!\n"); if(!SilentTimeOut) { TSTPOUT(GlobalOut, "GaveUp"); } retval = INCOMPLETE_PROOFSTATE; } } else { fprintf(GlobalOut, "\n# Failure: User resource limit exceeded!\n"); if(!SilentTimeOut) { TSTPOUT(GlobalOut, "ResourceOut"); } retval = RESOURCE_OUT; } if(BuildProofObject && (retval!=INCOMPLETE_PROOFSTATE)&& (retval!=RESOURCE_OUT)) { ClauseSetPushClauses(proofstate->extract_roots, proofstate->processed_pos_rules); ClauseSetPushClauses(proofstate->extract_roots, proofstate->processed_pos_eqns); ClauseSetPushClauses(proofstate->extract_roots, proofstate->processed_neg_units); ClauseSetPushClauses(proofstate->extract_roots, proofstate->processed_non_units); if(cnf_only) { ClauseSetPushClauses(proofstate->extract_roots, proofstate->unprocessed); print_sat = false; } DerivationComputeAndPrint(GlobalOut, proofstate->extract_roots, proofstate->signature, proof_graph); } } /* ClauseSetDerivationStackStatistics(proofstate->unprocessed); */ if(print_sat) { if(proofstate->non_redundant_deleted) { fprintf(GlobalOut, "\n# Saturated system is incomplete!\n"); } if(success) { fprintf(GlobalOut, "# Saturated system contains the empty clause:\n"); ClausePrint(GlobalOut, success, true); fputc('\n',GlobalOut); fputc('\n',GlobalOut); } ProofStatePrintSelective(GlobalOut, proofstate, outdesc, outinfo); fprintf(GlobalOut, "\n"); } if(success) { ClauseFree(success); } fflush(GlobalOut); print_proof_stats(proofstate, parsed_ax_no, relevancy_pruned, raw_clause_no, preproc_removed); #ifndef FAST_EXIT #ifdef FULL_MEM_STATS fprintf(GlobalOut, "# sizeof TermCell : %ld\n" "# sizeof EqnCell : %ld\n" "# sizeof ClauseCell : %ld\n" "# sizeof PTreeCell : %ld\n" "# sizeof PDTNodeCell : %ld\n" "# sizeof EvalCell : %ld\n" "# sizeof ClausePosCell: %ld\n" "# sizeof PDArrayCell : %ld\n", sizeof(TermCell), sizeof(EqnCell), sizeof(ClauseCell), sizeof(PTreeCell), sizeof(PDTNodeCell), sizeof(EvalCell), sizeof(ClausePosCell), sizeof(PDArrayCell)); fprintf(GlobalOut, "# Estimated memory usage: %ld\n", ProofStateStorage(proofstate)); MemFreeListPrint(GlobalOut); #endif ProofControlFree(proofcontrol); #endif cleanup1: #ifndef FAST_EXIT ProofStateFree(proofstate); CLStateFree(state); PStackFree(hcb_definitions); PStackFree(wfcb_definitions); FVIndexParmsFree(fvi_parms); HeuristicParmsFree(h_parms); #ifdef FULL_MEM_STATS MemFreeListPrint(GlobalOut); #endif #endif if(print_rusage && !SilentTimeOut) { PrintRusage(GlobalOut); } #ifdef CLB_MEMORY_DEBUG RegMemCleanUp(); MemFlushFreeList(); MemDebugPrintStats(stdout); #endif OutClose(GlobalOut); return retval; }
int main(int argc, char* argv[]) { /* Scanner_p in; */ CLState_p state; Scanner_p in; PCLProt_p prot; long steps, proof_steps, neg_steps; int i; assert(argv[0]); InitIO(NAME); ESignalSetup(SIGTERM); ESignalSetup(SIGINT); /* We need consistent name->var mappings here because we potentially read the compressed input format. */ ClausesHaveLocalVariables = false; state = process_options(argc, argv); GlobalOut = OutOpen(outname); OpenGlobalOut(outname); prot = PCLProtAlloc(); if(state->argc == 0) { CLStateInsertArg(state, "-"); } steps = 0; for(i=0; state->argv[i]; i++) { in = CreateScanner(StreamTypeFile, state->argv[i], true, NULL); ScannerSetFormat(in, TPTPFormat); steps+=PCLProtParse(in, prot); CheckInpTok(in, NoToken); DestroyScanner(in); } VERBOUT2("PCL input read\n"); PCLProtStripFOF(prot); PCLProtResetTreeData(prot, false); PCLProtMarkProofClauses(prot); PCLProtProofDistance(prot); PCLProtUpdateGRefs(prot); proof_steps = PCLProtCountProp(prot, PCLIsProofStep); neg_steps = proof_steps?neg_proportion*proof_steps:neg_examples; PCLProtSelectExamples(prot, neg_steps); fprintf(GlobalOut, "# Axioms:\n"); PCLProtPrintPropClauses(GlobalOut, prot, PCLIsInitial, lop_format); fprintf(GlobalOut, ".\n\n# Examples:\n"); PCLProtPrintExamples(GlobalOut, prot); PCLProtFree(prot); CLStateFree(state); fflush(GlobalOut); OutClose(GlobalOut); ExitIO(); #ifdef CLB_MEMORY_DEBUG MemFlushFreeList(); MemDebugPrintStats(stdout); #endif return EXIT_SUCCESS; }
int main(int argc, char* argv[]) { CLState_p state; StructFOFSpec_p ctrl; PStack_p prob_names = PStackAlloc(); int i; AxFilterSet_p filters; Scanner_p in; DStr_p corename; char *tname; assert(argv[0]); InitIO(NAME); DocOutputFormat = tstp_format; OutputFormat = TSTPFormat; state = process_options(argc, argv); OpenGlobalOut(outname); if(filtername) { filters = AxFilterSetAlloc(); in = CreateScanner(StreamTypeFile, filtername, true, NULL); AxFilterSetParse(in, filters); DestroyScanner(in); } else { filters = AxFilterSetCreateInternal(AxFilterDefaultSet); } if(dumpfilter) { AxFilterSetPrint(GlobalOut, filters); } if(state->argc < 1) { Error("Usage: e_axfilter <problem> [<options>]\n", USAGE_ERROR); } for(i=0; state->argv[i]; i++) { PStackPushP(prob_names, state->argv[i]); } /* Base name is the stripped base of the first argument */ tname = FileNameStrip(state->argv[0]); corename = DStrAlloc(); DStrAppendStr(corename, tname); FREE(tname); ctrl = StructFOFSpecAlloc(); StructFOFSpecParseAxioms(ctrl, prob_names, parse_format); StructFOFSpecInitDistrib(ctrl); StructFOFSpecResetShared(ctrl); for(i=0; i<AxFilterSetElements(filters); i++) { /* SigPrint(stdout,ctrl->sig); */ filter_problem(ctrl, AxFilterSetGetFilter(filters,i), DStrView(corename)); } StructFOFSpecFree(ctrl); DStrFree(corename); AxFilterSetFree(filters); CLStateFree(state); PStackFree(prob_names); OutClose(GlobalOut); ExitIO(); #ifdef CLB_MEMORY_DEBUG MemFlushFreeList(); MemDebugPrintStats(stdout); #endif return 0; }