Пример #1
0
etype::etype(const etype &var): type(ET_UNDEFINED), value(0x00)
{ set_type(var.type); set_value(var.value); }
Пример #2
0
int KVConfig::set_value(const char *key, int v)
{
    char info[64];
    snprintf(info, sizeof(info), "%d", v);
    return set_value(key, info);
}
Пример #3
0
attribute* attribute::operator = (attribute* a)
{
    set_name(a->get_name());
    set_value(a->get_value());
    return this;
}
Пример #4
0
// *************************************************************************************************
// @fn          mx_alarm
// @brief       Set alarm time.
// @param       u8 line		LINE1
// @return      none
// *************************************************************************************************
void mx_alarm(u8 line)
{
	u8 select;
	s32 hours;
	s32 minutes;
        s32 softlen;
	u8 * str;
	
	// Clear display
	clear_display_all();

	// Keep global values in case new values are discarded
	hours 		= sAlarm.hour;
	minutes 	= sAlarm.minute;
        softlen=sAlarm.softlen;

	// Display HH:MM (LINE1) 
	str = int_to_array(hours, 2, 0);
	display_chars(LCD_SEG_L1_3_2, str, SEG_ON);
	display_symbol(LCD_SEG_L1_COL, SEG_ON);
	
	str = int_to_array(minutes, 2, 0);
	display_chars(LCD_SEG_L1_1_0, str, SEG_ON);

	str = int_to_array(softlen, 2, 0);
	display_chars(LCD_SEG_L2_1_0, str, SEG_ON);        
	display_chars(LCD_SEG_L2_3_2, " L", SEG_ON);                
	
	// Display "ALARM" (LINE2)
//	display_chars(LCD_SEG_L2_4_0, (u8 *)"ALARM", SEG_ON);
		
	// Init value index
	select = 0;	
		
	// Loop values until all are set or user breaks	set
	while(1) 
	{
		// Idle timeout: exit without saving 
		if (sys.flag.idle_timeout) break;
		
		// STAR (short): save, then exit 
		if (button.flag.star) 
		{
			// Store local variables in global alarm time
			sAlarm.hour = hours;
			sAlarm.minute = minutes;
                        sAlarm.softlen=softlen;
			// Set display update flag
			display.flag.line1_full_update = 1;
			break;
		}

		switch (select)
		{
			case 0:		// Set hour
                                        set_value(&hours, 2, 0, 0, 23, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_2, display_hours);
                                        select = 1;
                                        break;

			case 1:		// Set minutes
                                        set_value(&minutes, 2, 0, 0, 59, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_1_0, display_value);
                                        select = 2;
                                        break;
			case 2:		// Set L
                                        set_value(&softlen, 2, 3, 1, 59, SETVALUE_DISPLAY_VALUE + SETVALUE_FAST_MODE, LCD_SEG_L2_1_0, display_value);
                                        select = 0;
                                        break;
		}
	}
	
	// Clear button flag
	button.all_flags = 0;
	
	// Indicate to display function that new value is available
	display.flag.update_alarm = 1;
}
Пример #5
0
decision_proceduret::resultt smt1_dect::read_result_mathsat(std::istream &in)
{
  std::string line;
  decision_proceduret::resultt res = D_ERROR;

  smt1_prop.reset_assignment();

  typedef hash_map_cont<std::string, valuet, string_hash> valuest;
  valuest values;

  while(std::getline(in, line))
  {
    if(line=="sat")
      res=D_SATISFIABLE;
    else if(line=="unsat")
      res=D_UNSATISFIABLE;
    else if(line.size()>=1 && line[0]=='(')
    {
      // (= c_h39__h39___CPROVER_malloc_size_h39_35_h39_1 bv0[64])
      // (= (select __h64_0 bv0[32]) bv5[8])
      std::size_t pos1=line.find(' ');
      std::size_t pos2=line.rfind(' ');
      if(pos1!=std::string::npos &&
         pos2!=std::string::npos &&
         pos1!=pos2)
      {
        std::string id=std::string(line, pos1+1, pos2-pos1-1);
        std::string value=std::string(line, pos2+1, line.size()-pos2-2);

        if(has_prefix(id, "(select "))
        {
          #if 0
          std::size_t pos3=id.rfind(' ');
          std::string index=std::string(pos3+1, id.size()-pos3-1);
          id=std::string(id, 8, pos3-8);
          #endif
        }
        else
          values[id].value=value;
      }
    }
  }

  for(identifier_mapt::iterator
      it=identifier_map.begin();
      it!=identifier_map.end();
      it++)
  {
    it->second.value.make_nil();
    std::string conv_id=convert_identifier(it->first);
    std::string value=mathsat_value(values[conv_id].value);

    if(value!="")
      set_value(it->second, "", value);
  }

  // Booleans
  for(unsigned v=0; v<smt1_prop.no_variables(); v++)
  {
    std::string value=values["B"+i2string(v)].value;
    if(value=="") continue;
    smt1_prop.set_assignment(literalt(v, false), value=="true");
  }

  return res;
}
Пример #6
0
SJRotation::SJRotation(const SJVec3 &axis, float degrees)
{
   set_value(axis, degrees);
}
Пример #7
0
SJRotation::SJRotation()
{
   set_value(SJVec3(0.f, 0.f, 1.f), 0.f);
}
bool C_GeneratorConfig::fromXml (C_XmlData          *P_data) {

  bool                      L_ret = true ;
  T_pXmlData_List           L_sectionList, L_subSectionList            ;
  T_XmlData_List::iterator  L_sectionListIt, L_subSectionListIt ;
  C_XmlData                *L_section, *L_subSection ;
  char                     *L_entity_value ;
  char                     *L_param_name, *L_param_value ;
  T_GeneratorConfigOption   L_param_code ;
  bool                      L_decode_param ;

  T_ConfigValue             L_configValue     ;
  
  if (P_data != NULL) {

    if ((L_sectionList = P_data->get_sub_data()) != NULL) {
      
      for(L_sectionListIt  = L_sectionList->begin() ;
	  L_sectionListIt != L_sectionList->end() ;
	  L_sectionListIt++) {
	
	L_section = *L_sectionListIt ;
	if (L_section != NULL) {
	  if (strcmp(L_section->get_name(), 
		     XML_CONFIG_SECTION) == 0) {

	    L_subSectionList = L_section->get_sub_data() ;
	    for(L_subSectionListIt  = L_subSectionList->begin() ;
		L_subSectionListIt != L_subSectionList->end() ;
		L_subSectionListIt++) {
	      L_subSection = *L_subSectionListIt ;
	      
	      if (strcmp(L_subSection->get_name(), 
			 XML_CONFIG_SUBSECTION) == 0) {

		L_entity_value = L_subSection->find_value(XML_CONFIG_ENTITY) ;
		if (L_entity_value != NULL) {

		  if (strcmp(L_entity_value, XML_CONFIG_ENTITY_VALUE) == 0) {
		    L_param_name = L_subSection->find_value(XML_CONFIG_NAME);
		    L_param_value = L_subSection->find_value(XML_CONFIG_VALUE);

		    L_param_code = get_code(L_param_name);

		    if (L_param_code != E_CFG_OPT_Number) {
		      L_decode_param = set_value (L_param_code, L_param_value) ;

		      if (L_decode_param == false) {
			GEN_ERROR(E_GEN_FATAL_ERROR, "Format incorrect for value ["
				  << L_param_value << "] for parameter ["
				  << L_param_name << "]");
			L_ret = false ;
			break ;
		      }
		    } else {
		      GEN_ERROR(E_GEN_FATAL_ERROR, "Unknown configuration parameter ["
				<< L_param_name << "]");
		      L_ret = false ;
		      break ;
		    }
		  }
		   if (strcmp(L_entity_value, XML_CONFIG_PARAM_ENTITY_VALUE) == 0) {
		    L_configValue.m_name = L_subSection->find_value(XML_CONFIG_NAME);
		    L_configValue.m_value = L_subSection->find_value(XML_CONFIG_VALUE);
		    m_configValueList->push_back(L_configValue);
		   }

		} 
	      }
	    }
	  }
	} 
      }

    } else {
      GEN_ERROR(E_GEN_FATAL_ERROR, "No Xml data");
      L_ret = false ;
    }
  } else { // P_data == NULL
    GEN_ERROR(E_GEN_FATAL_ERROR, "No Xml data");
    L_ret = false ;
  }


  return (L_ret);
}
Пример #9
0
// *************************************************************************************************
// @fn          mx_time
// @brief       Clock set routine.
// @param       u8 line		LINE1, LINE2
// @return      none
// *************************************************************************************************
void mx_time(u8 line)
{
	u8 select;
	s32 timeformat;
	s16 timeformat1;
	s32 hours;
	s32 minutes;
	s32 seconds;
	s32 DailyCorrTmp;
    s32 WeeklyCorrTmp;
    s32 DST_AutoFlagTmp;
    
	u8 * str;
	
	// Clear display
    TimeAdjustmentFlag = 1;	
	clear_display_all();
	
    // Convert global time to local variables
	// Global time keeps on ticking in background until it is overwritten
	if (sys.flag.use_metric_units)
	{
		timeformat 	= TIMEFORMAT_24H;
	}
	else
	{
		timeformat 	= TIMEFORMAT_12H;
	}
	timeformat1	= timeformat;
	hours 		= sTime.hour; 
	minutes 	= sTime.minute;
	seconds 	= sTime.second;
	DailyCorrTmp  = DailyCorr;
	WeeklyCorrTmp = WeeklyCorr;
	DST_AutoFlagTmp = DST_AutoFlag;
	
	// Init value index
	select = 0;	
		
	// Loop values until all are set or user breaks	set
	while(1) 
	{
    	// Idle timeout: exit without saving 
		if (sys.flag.idle_timeout)
		{
			// Roll back time format
			if (timeformat1 == TIMEFORMAT_24H) 	sys.flag.use_metric_units = 1;
			else								sys.flag.use_metric_units = 0;
			display_symbol(LCD_SYMB_AM, SEG_OFF);
            TimeAdjustmentFlag = 0;
			break;
		}
		
		// Button STAR (short): save, then exit 
		if (button.flag.star) 
		{
			// Stop clock timer
			Timer0_Stop();

			// Store local variables in global clock time
			sTime.hour 	 = hours;
			sTime.minute = minutes;
			sTime.second = seconds;
	        DailyCorr    = DailyCorrTmp;
	        WeeklyCorr   = WeeklyCorrTmp;
	        DST_AutoFlag = DST_AutoFlagTmp;

			// Start clock timer
			Timer0_Start();
			
			// Full display update is done when returning from function
			display_symbol(LCD_SYMB_AM, SEG_OFF);
            TimeAdjustmentFlag = 0;
			break;
		}

		switch (select)
		{
			case 0:		// Clear LINE1 and LINE2 and AM icon - required when coming back from set_value(seconds)
						clear_display();
						display_symbol(LCD_SYMB_AM, SEG_OFF);
						
						// Set 24H / 12H time format
						set_value(&timeformat, 1, 0, 0, 1, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_SELECTION + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_1, display_selection_Timeformat1);
						
						// Modify global time format variable immediately to update AM/PM icon correctly
						if (timeformat == TIMEFORMAT_24H) 	sys.flag.use_metric_units = 1;
						else								sys.flag.use_metric_units = 0;
						select = 1;
						break;
			
			case 1:		// Display HH:MM (LINE1) and .SS (LINE2)
						str = itoa(hours, 2, 0);
						display_chars(LCD_SEG_L1_3_2, str, SEG_ON);
						display_symbol(LCD_SEG_L1_COL, SEG_ON);
						
						str = itoa(minutes, 2, 0);
						display_chars(LCD_SEG_L1_1_0, str, SEG_ON);

						str = itoa(seconds, 2, 0);
						display_chars(LCD_SEG_L2_1_0, str, SEG_ON);
						display_symbol(LCD_SEG_L2_DP, SEG_ON);
									
						// Set hours
						set_value(&hours, 2, 0, 0, 23, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_2, display_hours1);
						select = 2;
						break;
			
			case 2:		// Set minutes
						set_value(&minutes, 2, 0, 0, 59, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_1_0, display_value1);
						select = 3;
						break;
			
			case 3:		// Set seconds
						set_value(&seconds, 2, 0, 0, 59, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L2_1_0, display_value1);
						select = 4;
						break;

			case 4:		// Set daily adjusting value
						clear_display();
						display_chars(LCD_SEG_L2_4_0, (u8 *)"ADJ-1", SEG_ON);
					    set_value(&DailyCorrTmp, 2, 0, -10, 10, SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE + SETVALUE_DISPLAY_ARROWS, LCD_SEG_L1_3_2, display_value1);
						select = 5;
						break;
			
			case 5:		// Set weekly adjusting value
						display_chars(LCD_SEG_L2_4_0, (u8 *)"ADJ-7", SEG_ON);
					    set_value(&WeeklyCorrTmp, 2, 0, -30, 30, SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE + SETVALUE_DISPLAY_ARROWS, LCD_SEG_L1_3_2, display_value1);
						select = 6;
						break;
			
			case 6:		// Set DST (Daylight Saving Time) automatic
						clear_display();
						display_chars(LCD_SEG_L2_4_0, (u8 *)" DST ", SEG_ON);
					    set_value(&DST_AutoFlagTmp, 0, 0, 0, 1, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_0, display_OFF_ON);
						select = 0;
						break;
		}
	}
	
	// Clear button flags
	button.all_flags = 0;
}
Пример #10
0
void ColorMapInputWidget::slot_set_value()
{
    set_value(m_line_edit->text());
}
Пример #11
0
void ColorMapInputWidget::slot_unbind()
{
    set_value(m_default_value);
}
Пример #12
0
void EntityInputWidget::slot_unbind()
{
    set_value(QString());
}
Пример #13
0
void EntityInputWidget::slot_set_value()
{
    set_value(m_line_edit->text());
}
Пример #14
0
/*
 * Copy all the attributes from one MPI object to another
 */
int ompi_attr_copy_all(ompi_attribute_type_t type, void *old_object, 
                       void *new_object, opal_hash_table_t *oldattr_hash,
                       opal_hash_table_t *newattr_hash)
{
    int ret;
    int err;
    uint32_t key;
    int flag;
    void *node, *in_node;
    attribute_value_t *old_attr, *new_attr;
    ompi_attribute_keyval_t *hash_value;

    /* If there's nothing to do, just return */

    if (NULL == oldattr_hash) {
        return MPI_SUCCESS;
    }

    /* Lock this whole sequence of events -- don't let any other
       thread modify the structure of the attrbitue hash or bitmap
       while we're traversing it */

    OPAL_THREAD_LOCK(&attr_hash_lock);
    /* Get the first attribute in the object's hash */
    ret = opal_hash_table_get_first_key_uint32(oldattr_hash, &key, 
                                               (void **) &old_attr,
                                               &node);
    OPAL_THREAD_UNLOCK(&attr_hash_lock);

    /* While we still have some attribute in the object's key hash */
    while (OMPI_SUCCESS == ret) {
        in_node = node;

        /* Get the keyval in the main keyval hash - so that we know
           what the copy_attr_fn is */

	OPAL_THREAD_LOCK(&keyval_hash_lock);
        err = opal_hash_table_get_value_uint32(keyval_hash, key, 
                                               (void **) &hash_value);
	OPAL_THREAD_UNLOCK(&keyval_hash_lock);

        new_attr = OBJ_NEW(attribute_value_t);
        switch (type) {
        case UNUSED_ATTR:  /* keep the compiler happy */
            assert(0);
            break;
        case COMM_ATTR:
            /* Now call the copy_attr_fn */
            COPY_ATTR_CALLBACKS(communicator, old_object, hash_value, 
                                old_attr, new_object, new_attr);
            break;
            
        case TYPE_ATTR:
            /* Now call the copy_attr_fn */
            COPY_ATTR_CALLBACKS(datatype, old_object, hash_value, 
                                old_attr, new_object, new_attr);
            break;

        case WIN_ATTR:
            /* Now call the copy_attr_fn */
            COPY_ATTR_CALLBACKS(win, old_object, hash_value, 
                                old_attr, new_object, new_attr);
            break;
        }

        /* Hang this off the object's hash */
            
        /* The "predefined" parameter to ompi_attr_set() is set to 1,
           so that no comparison is done for prdefined at all and it
           just falls off the error checking loop in attr_set  */

        if (1 == flag) {
            if (0 != (hash_value->attr_flag & OMPI_KEYVAL_F77)) {
                if (0 != (hash_value->attr_flag & OMPI_KEYVAL_F77_MPI1)) {
                    new_attr->av_set_from = OMPI_ATTRIBUTE_FORTRAN_MPI1;
                } else {
                    new_attr->av_set_from = OMPI_ATTRIBUTE_FORTRAN_MPI2;
                }
            } else {
                new_attr->av_set_from = OMPI_ATTRIBUTE_C;
            }
            set_value(type, new_object, &newattr_hash, key, 
                      new_attr, true);

        } else {
            OBJ_RELEASE(new_attr);
        }

	OPAL_THREAD_LOCK(&attr_hash_lock);
        ret = opal_hash_table_get_next_key_uint32(oldattr_hash, &key, 
                                                  (void **) &old_attr, 
                                                  in_node, &node);
	OPAL_THREAD_UNLOCK(&attr_hash_lock);
    }

    /* All done */

    return MPI_SUCCESS;
}
Пример #15
0
SJRotation::SJRotation(float q0, float q1, float q2, float q3)
{
   set_value(q0, q1, q2, q3);
}
Пример #16
0
/*======== void my_main() ==========
  Inputs:   int polygons  
  Returns: 

  This is the main engine of the interpreter, it should
  handle most of the commadns in mdl.

  If frames is not present in the source (and therefore 
  num_frames is 1, then process_knobs should be called.

  If frames is present, the enitre op array must be
  applied frames time. At the end of each frame iteration
  save the current screen to a file named the
  provided basename plus a numeric string such that the
  files will be listed in order, then clear the screen and
  reset any other data structures that need it.

  Important note: you cannot just name your files in 
  regular sequence, like pic0, pic1, pic2, pic3... if that
  is done, then pic1, pic10, pic11... will come before pic2
  and so on. In order to keep things clear, add leading 0s
  to the numeric portion of the name. If you use sprintf, 
  you can use "%0xd" for this purpose. It will add at most
  x 0s in front of a number, if needed, so if used correctly,
  and x = 4, you would get numbers like 0001, 0002, 0011,
  0487

  05/17/12 09:41:35
  jdyrlandweaver
  ====================*/
void my_main( int polygons ) {

    int i, f, j, x;
    double step;
    double xval, yval, zval, knob_value;
    struct matrix *transform;
    struct matrix *tmp;
    struct stack *s;
    struct vary_node ** knobs;
    struct vary_node * link;
    screen t;
    color g;
    char q;
    
    num_frames = 1;
    step = 0.05;
    
    g.red = 0;
    g.green = 255;
    g.blue = 255;
    
    s = new_stack();
    tmp = new_matrix(4, 1000);
    clear_screen( t );
    
    first_pass();
    
    if(num_frames > 1)
        knobs = second_pass();
    
    int variables;
    
    for(variables = 0; variables < num_frames; variables++){
        s = new_stack();
        tmp = new_matrix(4,1000);
        clear_screen(t);
        
        for (j = 0; j < lastsym; j++){
            if(symtab[j].type == SYM_VALUE){
                link = knobs[variables];
                while (strcmp(link->name, symtab[j].name) != 0){
                    link = link->next;
                }
                if (link){
                    (&symtab[j])->s.value = link->value;
                }
            }
        }
        for (i=0;i<lastop;i++) {
            
            switch (op[i].opcode) {
                    
                case SET:
                    x = op[i].op.set.p->s.value;
                    set_value(lookup_symbol(op[i].op.set.p->name),x);
                    break;
                    
                case SETKNOBS:
                    x = op[i].op.setknobs.value;
                    for(j = 0; j < lastsym; j++){
                        if(symtab[j].type == SYM_VALUE){
                            set_value(&(symtab[j]), x);
                        }
                    }
                    
                case SPHERE:
                    add_sphere( tmp,op[i].op.sphere.d[0], //cx
                               op[i].op.sphere.d[1],  //cy
                               op[i].op.sphere.d[2],  //cz
                               op[i].op.sphere.r,
                               step);
                    //apply the current top origin
                    matrix_mult( s->data[ s->top ], tmp );
                    draw_polygons( tmp, t, g );
                    tmp->lastcol = 0;
                    break;
                    
                case TORUS:
                    add_torus( tmp, op[i].op.torus.d[0], //cx
                              op[i].op.torus.d[1],     //cy
                              op[i].op.torus.d[2],    //cz
                              op[i].op.torus.r0,
                              op[i].op.torus.r1,
                              step);
                    matrix_mult( s->data[ s->top ], tmp );
                    draw_polygons( tmp, t, g );
                    tmp->lastcol = 0;
                    break;
                    
                case BOX:
                    add_box( tmp, op[i].op.box.d0[0],
                            op[i].op.box.d0[1],
                            op[i].op.box.d0[2],
                            op[i].op.box.d1[0],
                            op[i].op.box.d1[1],
                            op[i].op.box.d1[2]);
                    matrix_mult( s->data[ s->top ], tmp );
                    draw_polygons( tmp, t, g );
                    tmp->lastcol = 0;
                    break;
                    
                case LINE:
                    add_edge( tmp, op[i].op.line.p0[0],
                             op[i].op.line.p0[1],
                             op[i].op.line.p0[1],
                             op[i].op.line.p1[0],
                             op[i].op.line.p1[1],
                             op[i].op.line.p1[1]);
                    draw_lines( tmp, t, g );
                    tmp->lastcol = 0;
                    break;
                    
                case MOVE:
                    //get the factors
                    xval = op[i].op.move.d[0];
                    yval =  op[i].op.move.d[1];
                    zval = op[i].op.move.d[2];
                  
                    if(op[i].op.scale.p){
                        SYMTAB * variable = (lookup_symbol(op[i].op.move.p->name));
                        xval = xval * variable->s.value;
                        yval = yval * variable->s.value;
                        zval = zval * variable->s.value;
                    }
                    
                    transform = make_translate( xval, yval, zval );
                    //multiply by the existing origin
                    matrix_mult( s->data[ s->top ], transform );
                    //put the new matrix on the top
                    copy_matrix( transform, s->data[ s->top ] );
                    free_matrix( transform );
                    break;
                    
                case SCALE:
                    xval = op[i].op.scale.d[0];
                    yval = op[i].op.scale.d[1];
                    zval = op[i].op.scale.d[2];
                  
                    if(op[i].op.scale.p){
                        SYMTAB * variable = (lookup_symbol(op[i].op.move.p->name));
                        xval = xval * variable->s.value;
                        yval = yval * variable->s.value;
                        zval = zval * variable->s.value;
                    }

                    
                    transform = make_scale( xval, yval, zval );
                    matrix_mult( s->data[ s->top ], transform );
                    //put the new matrix on the top
                    copy_matrix( transform, s->data[ s->top ] );
                    free_matrix( transform );
                    break;
                    
                case ROTATE:
                    xval = op[i].op.rotate.degrees * ( M_PI / 180 );
                    
                    if(op[i].op.scale.p){
                        SYMTAB * variable = (lookup_symbol(op[i].op.move.p->name));
                        xval = xval * variable->s.value;
                    }                    

                    //get the axis
                    if ( op[i].op.rotate.axis == 0 )
                        transform = make_rotX( xval );
                    else if ( op[i].op.rotate.axis == 1 )
                        transform = make_rotY( xval );
                    else if ( op[i].op.rotate.axis == 2 )
                        transform = make_rotZ( xval );
                    
                    matrix_mult( s->data[ s->top ], transform );
                    //put the new matrix on the top
                    copy_matrix( transform, s->data[ s->top ] );
                    free_matrix( transform );
                    break;
                    
                case PUSH:
                    push( s );
                    break;
                case POP:
                    pop( s );
                    break;
                case SAVE:
                    save_extension( t, op[i].op.save.p->name );
                    break;
                case DISPLAY:
                    display( t );
                    break;
            }
        }
        char dname[256];
        char index[256];
        
        strcpy(dname, "animations/");
        strcat(dname, name);
        sprintf(index, "%03d", variables);
        strcat(dname, index);
        strcat(dname, ".png");
        save_extension(t, dname);
        printf("saved %s\n", dname);
        
    }
  
  free_stack( s );
  free_matrix( tmp );
  //free_matrix( transform );    
}
Пример #17
0
SJRotation::SJRotation(const SJMat3 &m)
{
   set_value(m);
}
Пример #18
0
  void example_matrix_utilities() {
    // Run this and look at stdout to see examples using the multi-dimensional matrix.
    // Note: MatrixF is a typedef for Matrix<float>
    cout << "Matrix utility examples." << endl;

    cout << "// 3 x 4 matrix, initialized to 0." << endl;
    cout << "MatrixF X(3,4);" << endl;
    MatrixF X(3,4);

    cout << "cout << X << endl;" << endl;
    cout << X << endl;

    cout << "// Create range of values in X." << endl;

    cout << "float i = 0;" << endl;
    float i = 0;
    cout << "// Fill up X." << endl;
    cout << R"(apply_sequential(X, [&] (float a) {
        // Ignore the value of a.
        i += 0.1f;
        return i;
      });)" << endl;
    apply_sequential(X, [&] (float a) {
        // Ignore the value of a.
        i += 0.1f;
        return i;
      });

    cout << "cout << X << endl;" << endl;
    cout << X << endl;

    cout << "// Apply sqrt() to all elements in X." << endl;
    cout << R"(apply(X, [] (float a) {
        return std::sqrt(a);
      });)" << endl;

    apply(X, [] (float a) {
        return std::sqrt(a);
      });

    cout << "cout << X << endl;" << endl;
    cout << X << endl;

    cout << "MatrixF Y(4,5);" << endl;
    MatrixF Y(4,5);

    cout << "cout << Y << endl;" << endl;
    cout << Y << endl;

    cout << "i = 0;" << endl;
    i = 0;

    cout << R"(apply_sequential(Y, [&] (float a) {
        // Ignore the value of a.
        i += 1.0f;
        return i;
      });)" << endl;
    apply_sequential(Y, [&] (float a) {
        // Ignore the value of a.
        i += 1.0f;
        return i;
      });

    cout << endl << "// map2() example:" << endl;

    cout << "cout << Y << endl;" << endl;
    cout << Y << endl;

    cout << "MatrixF A = Y;" << endl;
    MatrixF A = Y;


    cout << "cout << A << endl;" << endl;
    cout << A << endl;

    cout << "MatrixF B = Y;" << endl;
    MatrixF B = Y;

    cout << "cout << B << endl;" << endl;
    cout << B << endl;

    cout << "// Apply map2(): " << endl;
    cout << R"(map2(Y, A, B, [] (float a, float b) {
        return a + 2*b;
      });)" << endl << endl;

    map2(Y, A, B, [] (float a, float b) {
        return a + 2*b;
      });

    cout << "cout << Y << endl;" << endl;
    cout << Y << endl;

    cout << "// narrow() example:" << endl;

    i = 0;

    cout << R"(apply_sequential(Y, [&] (float a) {
        // Ignore the value of a.
        i += 1.0f;
        return i;
      });)" << endl;
    apply_sequential(Y, [&] (float a) {
        // Ignore the value of a.
        i += 1.0f;
        return i;
      });

    cout << "cout << Y << endl;" << endl;
    cout << Y << endl;

    cout << "MatrixF D = narrow(Y, 1, 1, 2);" << endl;
    MatrixF D = narrow(Y, 1, 1, 2);

    cout << "cout << D << endl;" << endl;
    cout << D << endl;

    cout << "// Now randomize D:" << endl;
    cout << "randomize_normal(D, 1.0f, 1.0f);" << endl;
    randomize_normal(D, 1.0f, 1.0f);

    cout << "cout << D << endl;" << endl;
    cout << D << endl;

    cout << "// Now copy data from D back into same locations in Y:" << endl;
    cout << "reverse_narrow(D, Y, 1, 1, 2);" << endl;
    reverse_narrow(D, Y, 1, 1, 2);

    cout << "cout << Y << endl;" << endl;
    cout << Y << endl;

    cout << "// Matrix multilication example:" << endl;
    cout << "MatrixF U(3,4);" << endl;
    MatrixF U(3,4);
    cout << "cout << U << endl;" << endl;
    cout << U << endl;
    cout << "randomize_uniform(U, -1.0f, 1.0f);" << endl;
    randomize_uniform(U, -1.0f, 1.0f);
    cout << "cout << U << endl;" << endl;
    cout << U << endl;
    cout << "MatrixF R(4,5);" << endl;
    MatrixF R(4,5);
    cout << "cout << R << endl;" << endl;
    cout << R << endl;
    cout << "set_value(R, 1.0f);" << endl;
    set_value(R, 1.0f);
    cout << "cout << R << endl;" << endl;
    cout << R << endl;    
    cout << "// Compute C = U*R:" << endl;
    cout << "MatrixF C;" << endl;
    MatrixF C;
    cout << "// Note: C has not been initialized to the required output dimensions but will be " << endl;
    cout << "// resized to the correct dimensions inside the matrix multiplication function." << endl;
    cout << "// Many of the matrix utility functions work like this (auto re-sizing of result)." << endl;
    cout << "mat_multiply(C, U, R);" << endl;
    mat_multiply(C, U, R);
    cout << "cout << C << endl;" << endl;
    cout << C << endl;

  }
Пример #19
0
SJRotation::SJRotation(const SJVec3 &rotateFrom, const SJVec3 &rotateTo)
{
   set_value(rotateFrom, rotateTo);
}
Пример #20
0
FreeResponseAnswer::FreeResponseAnswer(Util::UniqueID<Backend::Object> object_id, const string& answer) :
  Interaction(object_id)
{
  set_value(Util::kFreeResponseAnswerAttribute, answer);
}
Пример #21
0
/*
 * Reads each line from the input file, then malloc()s and populates main
 * data structures X, T, Y
 */
void compile(FILE *fin, t_clause ***X, t_clause ***T, t_clause ***Y, int *params, char *xs) {
	int r, value;
	int count = 0;
	t_fsm *fsmp = fsmparser();
	char line[LINLEN];
	char copy[LINLEN];
	char *token;
	char *op;
	char c;
	t_clause *cl;

	// used for keeping track of input and output symbols
	t_hashtable *inputs = hashtable(IN_HASHSIZE);
	t_hashtable *outputs = hashtable(OUT_HASHSIZE);
	t_hashtable *temps = hashtable(TMP_HASHSIZE);


	/* check hashtable pointers */
	if (!inputs || !outputs || !temps) {
		fprintf(stderr, "-- compile() : could not init hashtables\n");
		return;
	}

	/* process each line at a time */
	while (fgets(line, LINLEN, fin)) {
		int l = lincpy(line, copy, "\n\t\r;");

		if (l > 1) {

			/* initialize data structures */
			if (isdigit((c=copy[0]))) {

				token = strtok(copy, " ");
				value = atoi(token);
				token = strtok(NULL, " ");

				if (streq(token, "gates") || streq(token, "gate")) {
					*T = malloc(value*sizeof(t_clause*));
					params[2]=value;
					r = next(fsmp, LEN);
				} else if (streq(token, "inputs")) {
					*X = malloc(value*sizeof(t_clause*));
					params[0]=value;
					r = next(fsmp, IN);
				} else if (streq(token, "outputs")) {
					*Y = malloc(value*sizeof(t_clause*));
					params[1]=value;
					r = next(fsmp, OUT);
				} else
					r = next(fsmp, ERR);
			}

			/* line == 'begin' or line == 'end' */
			else if (streq(copy, "begin")) 		r = next(fsmp, PROG);
			else if (streq(copy, "end"))		r = next(fsmp, END);

			/* list of input symbols */
			else if (getstate(fsmp) == IN) {
				token=strtok(copy, " ");
				while (token)	{
					cl = clause(NULL, NULL, NULL, token, count);
					printf("0x%x @ %s ", cl, get_clause_name(cl));
					if (xs) {
						int xval = -48;
						bool b;
						xval += (count < strlen(xs)) ? xs[count] : 48;
						b = (!xval) ? FALSE : TRUE;
						set_value(cl, b);
						printf("= %d", b);
					}
					(*X)[count++] = cl;
					put_clause(inputs, cl);
					printf("\n");
					token = strtok(NULL, " ");
				}
				count=0;
			}

			/* list of output symbols */
			else if (getstate(fsmp) == OUT) {
				token = strtok(copy, " ");
				while (token) {
					cl = clause(NULL, NULL, NULL, token, count++);
					put_clause(outputs, cl);
					printf("0x%x @ %s\n", cl, get_clause_name(cl));
					token=strtok(NULL, " ");
				}
				count=0;
			}

			/* parse clauses */
			else if (getstate(fsmp) == PROG) {

				token = strtok(copy, "= ");
				t_clause *target = find_clause(outputs, token);
				char *lcname, *rcname, *op;
				t_clause *lcl, *rcl;
				lcname = strtok(NULL, "= ");
				op = strtok(NULL, "= ");
				rcname = strtok(NULL, "= ");

				/* composite output clause */
				if (op && lcname && rcname && target) {

					// find left and right operands
					lcl = lookup(lcname, inputs, outputs, temps);
					rcl = lookup(rcname, inputs, outputs, temps);

					if (!lcl || !rcl) {
						r = next(fsmp, ERR);
						continue;
					}

					cl = clause(lcl, rcl, op, token, count);
					printf("0x%x @ %s = %s %s %s\n", target, get_clause_name(target), get_clause_name(lcl), op, get_clause_name(rcl));
					int num = enumerate(target);
					clause_copy(cl, target);
					(*Y)[num] = target;

				}

				/* simple output clause */
				else if (target && lcname) {

					lcl = lookup(lcname, inputs, outputs, temps);

					if (!lcl) {
						r = next(fsmp, ERR);
						continue;
					}

					printf("0x%x @ %s = %s\n", target, get_clause_name(target), get_clause_name(lcl));
					int num = enumerate(target);
					clause_copy(lcl, target);
					(*Y)[num] = target;
				}


				/* just a temp clause ?! */
				else

				{
					lcl = lookup(lcname, inputs, outputs, temps);
					rcl = lookup(rcname, inputs, outputs, temps);


					if (!lcl || !rcl) {
						r = next(fsmp, ERR);
						continue;
					}

					cl = clause(lcl, rcl, op, token, count);
					put_clause(temps, cl);
					(*T)[count++]=cl;
					printf("0x%x @ %s\n", cl, get_clause_name(cl));
				}

			}

			else
			{
				/* invalid line */
				r = next(fsmp, ERR);
			}
		}

		else
		{
			/* l <= 1 means line is comment or blank */
			r = next(fsmp, IGN);
		}

		/* valid transaction? */
		if (!r || getstate(fsmp) == ERR) {
			fprintf(stderr, "compile() :: parsing error (r=%d\ts=%d)\n", r, getstate(fsmp));
			if (*T) 		free(*T);
			if (*Y) 		free(*Y);
			if (*X) 		free(*X);
			exit(1);
		}

	}


	// get rid of unnecessary hashtables
	// note that this won't affect clauses, which
	// remain available through X, Y, and T
	wipe_hashtable(inputs, FALSE);
	wipe_hashtable(outputs, FALSE);
	wipe_hashtable(temps, FALSE);
}
Пример #22
0
	void mutate_value(const std::string& key, const variant& value) {
		set_value(key, value);
	}
Пример #23
0
decision_proceduret::resultt smt1_dect::read_result_boolector(std::istream &in)
{
  std::string line;

  std::getline(in, line);

  if(line=="sat")
  {
    smt1_prop.reset_assignment();

    typedef hash_map_cont<std::string, valuet, string_hash> valuest;
    valuest values;

    while(std::getline(in, line))
    {
      std::size_t pos=line.find(' ');
      if(pos!=std::string::npos && pos!=0)
      {
        std::string id=std::string(line, 0, pos);
        std::string value=std::string(line, pos+1, std::string::npos);
      
        // Boolector offers array values as follows:
        //
        // ID[INDEX] VALUE
        //
        // There may be more than one line per ID
        
        if(id!="" && id[id.size()-1]==']') // array?
        {
          std::size_t pos2=id.find('[');
          
          if(pos2!=std::string::npos)
          {
            std::string new_id=std::string(id, 0, pos2);
            std::string index=std::string(id, pos2+1, id.size()-pos2-2);
            values[new_id].index_value_map[index]=value;
          }
        }
        else
          values[id].value=value;
      }
    }

    // Theory variables

    for(identifier_mapt::iterator
        it=identifier_map.begin();
        it!=identifier_map.end();
        it++)
    {
      it->second.value.make_nil();
      std::string conv_id=convert_identifier(it->first);
      const valuet &v=values[conv_id];

      for(valuet::index_value_mapt::const_iterator
          i_it=v.index_value_map.begin(); i_it!=v.index_value_map.end(); i_it++)
        set_value(it->second, i_it->first, i_it->second);
        
      if(v.value!="") set_value(it->second, "", v.value);
    }

    // Booleans

    for(unsigned v=0; v<smt1_prop.no_variables(); v++)
    {
      std::string value=values["B"+i2string(v)].value;
      if(value=="") continue;
      smt1_prop.set_assignment(literalt(v, false), value=="1");
    }

    return D_SATISFIABLE;
  }
  else if(line=="unsat")
    return D_UNSATISFIABLE;
  else
    error("Unexpected result from SMT-Solver: "+line);

  return D_ERROR;
}
Пример #24
0
void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {

	if (!is_editable()) {
		return;
	}

	Ref<InputEventMouseButton> mb = p_event;

	if (mb.is_valid() && mb->is_pressed()) {

		bool up = mb->get_position().y < (get_size().height / 2);

		switch (mb->get_button_index()) {

			case BUTTON_LEFT: {

				set_value(get_value() + (up ? get_step() : -get_step()));

				range_click_timer->set_wait_time(0.6);
				range_click_timer->set_one_shot(true);
				range_click_timer->start();

				line_edit->grab_focus();
			} break;
			case BUTTON_RIGHT: {

				set_value((up ? get_max() : get_min()));
				line_edit->grab_focus();
			} break;
			case BUTTON_WHEEL_UP: {
				if (line_edit->has_focus()) {

					set_value(get_value() + get_step() * mb->get_factor());
					accept_event();
				}
			} break;
			case BUTTON_WHEEL_DOWN: {
				if (line_edit->has_focus()) {

					set_value(get_value() - get_step() * mb->get_factor());
					accept_event();
				}
			} break;
		}
	}

	if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == 1) {

		//set_default_cursor_shape(CURSOR_VSIZE);
		Vector2 cpos = Vector2(mb->get_position().x, mb->get_position().y);
		drag.mouse_pos = cpos;
	}

	if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == 1) {

		//set_default_cursor_shape(CURSOR_ARROW);
		range_click_timer->stop();

		if (drag.enabled) {
			drag.enabled = false;
			Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
			warp_mouse(drag.capture_pos);
		}
	}

	Ref<InputEventMouseMotion> mm = p_event;

	if (mm.is_valid() && mm->get_button_mask() & 1) {

		Vector2 cpos = mm->get_position();

		if (drag.enabled) {

			float diff_y = drag.mouse_pos.y - cpos.y;
			diff_y = Math::pow(ABS(diff_y), 1.8f) * SGN(diff_y);
			diff_y *= 0.1;

			drag.mouse_pos = cpos;
			drag.base_val = CLAMP(drag.base_val + get_step() * diff_y, get_min(), get_max());

			set_value(drag.base_val);

		} else if (drag.mouse_pos.distance_to(cpos) > 2) {

			Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
			drag.enabled = true;
			drag.base_val = get_value();
			drag.mouse_pos = cpos;
			drag.capture_pos = cpos;
		}
	}
}
Пример #25
0
decision_proceduret::resultt smt1_dect::read_result_cvc3(std::istream &in)
{
  std::string line;
  decision_proceduret::resultt res = D_ERROR;

  smt1_prop.reset_assignment();

  typedef hash_map_cont<std::string, std::string, string_hash> valuest;
  valuest values;

  while(std::getline(in, line))
  {
    if(line=="sat")
      res = D_SATISFIABLE;
    else if(line=="unsat")
      res = D_UNSATISFIABLE;
    else if(line.find("Current scope level")!=std::string::npos ||
            line.find("Variable Assignment")!=std::string::npos)
      ; //ignore
    else
    {
      assert(line.substr(0,13)=="  :assumption");
      std::size_t pos=line.find('(');

      if(pos!=std::string::npos)
      {
        std::string var;
        std::string val;

        if(line[pos+1]=='=')
        {
          std::string ops = line.substr(pos+3, line.length()-pos-4);
          std::size_t blank=ops.find(' ');
          var = ops.substr(0, blank);
          val = ops.substr(blank+1, ops.length()-blank);

          if((var.length()>=4 && var.substr(0,4)=="cvc3") ||
             (val.length()>=4 && val.substr(0,4)=="cvc3") ||
             var==val)
            continue;
          else if((var.substr(0,9)=="array_of'") ||
                  (var.substr(0,2)=="bv" && val.substr(0,2)!="bv"))
          {
            std::string t=var; var=val; val=t;
          }
        }
        else if(line.substr(pos+1,3)=="not")
        {
          var = line.substr(pos+5, line.length()-pos-6);
          val = "false";
        }
        else
        {
          var = line.substr(pos+1, line.length()-pos-2);
          assert(var.find(' ')==std::string::npos);
          val = "true";
        }

        values[var]=val;
      }
    }
  }

  for(identifier_mapt::iterator
      it=identifier_map.begin();
      it!=identifier_map.end();
      it++)
  {
    it->second.value.make_nil();
    std::string conv_id=convert_identifier(it->first);
    std::string value=values[conv_id];
    if(value=="") continue;

    if(value.substr(0,2)=="bv")
    {
      std::string v=value.substr(2, value.find('[')-2);
      size_t p = value.find('[')+1;
      std::string w=value.substr(p, value.find(']')-p);

      std::string binary=integer2binary(string2integer(v,10),
                                        string2integer(w,10).to_ulong());

      set_value(it->second, "", binary);
    }
    else if(value=="false")
      it->second.value.make_false();
    else if(value=="true")
      it->second.value.make_true();
    else if(value.substr(0,8)=="array_of")
    {
      // We assume that array_of has only concrete arguments...
      irep_idt id(value);
      array_of_mapt::const_iterator fit=array_of_map.begin();
      while(fit!=array_of_map.end() && fit->second!=id) fit++;

      if(fit!=array_of_map.end())
        it->second.value = fit->first;
    }
    else
      set_value(it->second, "", value);
  }

  // Booleans
  for(unsigned v=0; v<smt1_prop.no_variables(); v++)
  {
    std::string value=values["B"+i2string(v)];
    if(value=="") continue;
    smt1_prop.set_assignment(literalt(v, false), value=="true");
  }

  return res;
}
Пример #26
0
// *************************************************************************************************
// @fn          mx_altitude
// @brief       Mx button handler to set the altitude offset. 
// @param       u8 line		LINE1
// @return      none
// *************************************************************************************************
void mx_altitude(u8 line)
{
	s32 altitude;
	s32	limit_high, limit_low;

	// Clear display
	clear_display_all();

	// Set lower and upper limits for offset correction
	if (sys.flag.use_metric_units)
	{
		// Display "m" symbol
		display_symbol(LCD_UNIT_L1_M, SEG_ON);

		// Convert global variable to local variable
		altitude  = sAlt.altitude; 

		// Limits for set_value function
		limit_low = -100;
		limit_high = 4000;
	}
	else // English units
	{
		// Display "ft" symbol
		display_symbol(LCD_UNIT_L1_FT, SEG_ON);
		
		// Convert altitude in meters to feet
		altitude = sAlt.altitude;

 		// Convert from meters to feet
		altitude = convert_m_to_ft(altitude);		

		// Limits for set_value function
		limit_low = -500;
		limit_high = 9999;
	}

	// Loop values until all are set or user breaks	set
	while(1) 
	{
		// Idle timeout: exit without saving 
		if (sys.flag.idle_timeout) break;

		// Button STAR (short): save, then exit 
		if (button.flag.star) 
		{
			// When using English units, convert ft back to m before updating pressure table
			if (!sys.flag.use_metric_units) altitude = convert_ft_to_m((s16)altitude);

			// Update pressure table
			update_pressure_table((s16)altitude, sAlt.pressure, sAlt.temperature);
			
			// Set display update flag
			display.flag.line1_full_update = 1;

			break;
		}

		// Set current altitude - offset is set when leaving function
		set_value(&altitude, 4, 3, limit_low, limit_high, SETVALUE_DISPLAY_VALUE + SETVALUE_FAST_MODE + SETVALUE_DISPLAY_ARROWS, LCD_SEG_L1_3_0, display_value1);
	}		
	
	// Clear button flags
	button.all_flags = 0;
}
Пример #27
0
attribute& attribute::operator=(attribute& a)
{
    set_name(a.get_name());
    set_value(a.get_value());
    return *this;
}
Пример #28
0
SJRotation::SJRotation(const float v[4])
{
   set_value(v);
}
Пример #29
0
bool attribute::set_value(std::string value) {
  return set_value((char *)value.c_str());
}
Пример #30
0
etype &etype::operator=(const etype &var)
{
  set_type(var.type);
  set_value(var.value);
  return(*this);
}