/* * call-seq: * v_next -> seq or nil * * Return the sequence vertically located in next. * Return <tt>nil</tt> if not existing. */ VALUE rb_v_next(VALUE self) { CvSeq *seq = CVSEQ(self); if (seq->v_next) return new_sequence(CLASS_OF(self), seq->v_next, seqblock_class(seq), lookup_root_object(seq)); else return Qnil; }
void main(void) { PLL_init(); lcd_init(); SCI0_init(9600); SCI1_int_init(9600); // Channel to talk to ESP8266 motor0_init(); // These functions actually control PWM outputs motor1_init(); // We use them to run the RGB LED. motor2_init(); RTI_init(); SW_enable(); initq(); DDRH = 0; // PORTH is an input. result = 0; status = 'b'; // Populate binary search tree: set_lcd_addr(0); send_at_command_sci1("ATE0"); // change to ATE1 for debug status = 'i'; // Establish connection to server. send_at_command_sci1("AT+CWMODE=1"); // Set ESP to station mode send_at_command_sci1("AT+CIPMODE=0"); // Set ESP to normal transmission mode send_at_command_sci1("AT+CIPMUX=0"); // Set ESP to single-connection mode send_at_command_sci1("AT+CWJAP=\"Freynet\",\"\""); // Connect to network send_at_command_sci1("AT+CIPSTART=\"TCP\",\"fpf3.net\",12345"); // connect to server while(1){ command = '\0'; while(qempty()); command = getq(); switch (command) { case 'n': status = 'w'; result = new_sequence(); ms_delay(500); // If we finish too quickly, we open a connection the ESP thinks is already open, and it breaks. send_at_command_sci1("AT+CIPSTART=\"TCP\",\"fpf3.net\",12345"); // connect to server break; } outchar0(result); } }
bool Project::new_sequence() { // request the new sequence infos const SequenceInfos infos = view::request_new_sequence_infos(); // create and register the sequence if( is_valid( infos ) ) return new_sequence( infos ); else return false; }
sequence_t copy_sequence(sequence_t other){ if(other == NULL){ return NULL; } sequence_t r = new_sequence(other->size); int i = 0; for(;i < other->size; i++){ r->vars[i].index = other->vars[i].index; if(other->vars[i].name){ r->vars[i].name = strdup(other->vars[i].name); } r->vars[i].params = copy_params(other->vars[i].params); } return r; }
inline State * new_sequence(char_int c, std::size_t count, State * out1 = nullptr) { return new_sequence(new_string_sequence(c, count), out1); }
inline State * new_sequence(const SequenceString & ss, State * out1 = nullptr) { return new_sequence(ss.s, ss.len, out1); }
config_t init_config(){ //TODO: in a c++ implementation this all can be done automatically //using a hashmap config_t conf = new_config(N_CONFIG_VARIABLES); config_t uspace = new_config(N_USPACE_VARS); uspace = update_entry( USPACE_BASE, new_entry_int(50176, "BASE"), uspace); uspace = update_entry( USPACE_WR, new_entry_int(0, "WR"), uspace); uspace = update_entry( USPACE_RD, new_entry_int(8, "RD"), uspace); config_t subdev = new_config(N_SUBDEV_VARS); subdev = update_entry( SUBDEV_IN, new_entry_int(0, "IN"), subdev); subdev = update_entry( SUBDEV_OUT, new_entry_int(1, "OUT"), subdev); subdev = update_entry( SUBDEV_ADC, new_entry_int(2, "ADC"), subdev); subdev = update_entry( SUBDEV_DAC, new_entry_int(3, "DAC"), subdev); config_t comedi = new_config(N_COMEDI_VARS); comedi = update_entry( COMEDI_FILE, new_entry_int(0, "FILE"), comedi); comedi = update_entry( COMEDI_SUBDEV, new_entry_map(subdev, "SUBDEV"), comedi); config_t sim = new_config(N_SIM_VARS); sim = update_entry( SIM_INPUT, new_entry_str("sim.in", "INPUT"), sim); sim = update_entry( SIM_OUTPUT, new_entry_str("sim.out", "OUTPUT"), sim); conf = update_entry( CONFIG_STEP, new_entry_int(1, "STEP"), conf); conf = update_entry( CONFIG_PIPE, new_entry_str("plcpipe", "PIPE"), conf); conf = update_entry( CONFIG_HW, new_entry_str("STDI/O", "HW"), conf); conf = update_entry( CONFIG_USPACE, new_entry_map(uspace, "USPACE"), conf); conf = update_entry( CONFIG_COMEDI, new_entry_map(comedi, "COMEDI"), conf); conf = update_entry( CONFIG_SIM, new_entry_map(sim, "SIM"), conf); /*******************************************/ conf = update_entry( CONFIG_TIMER, new_entry_seq(new_sequence(4), "TIMERS"), conf); conf = update_entry( CONFIG_PULSE, new_entry_seq(new_sequence(4), "PULSES"), conf); conf = update_entry( CONFIG_MREG, new_entry_seq(new_sequence(4), "MREG"), conf); conf = update_entry( CONFIG_MVAR, new_entry_seq(new_sequence(4), "MVAR"), conf); conf = update_entry( CONFIG_DI, new_entry_seq(new_sequence(8), "DI"), conf); conf = update_entry( CONFIG_DQ, new_entry_seq(new_sequence(8), "DQ"), conf); conf = update_entry( CONFIG_AI, new_entry_seq(new_sequence(8), "AI"), conf); conf = update_entry( CONFIG_AQ, new_entry_seq(new_sequence(8), "AQ"), conf); conf = update_entry( CONFIG_PROGRAM, new_entry_seq(new_sequence(2), "PROGRAM"), conf); return conf; }