/** * @par Detailed Design: * Since the Variable Server is unable to access elements within the standard template objects, the data contained in * #slaves must be duplicated here for applications that wish to query the Variable Server for information on slaves, * such as @ref MonteMonitor and @ref TrickView. This function ensures that the slave pointers within #slaves_head point * to the same memory addresses that the slave pointers in #slaves do. */ void Trick::MonteCarlo::sync_slaves_head() { num_slaves = slaves.size(); if (!slaves_head) { slaves_head = (MonteSlave**)TMM_declare_var_s("Trick::MonteSlave*[1]"); } else { slaves_head = (MonteSlave**)TMM_resize_array_1d_a(slaves_head, num_slaves); } for (std::vector<MonteSlave *>::size_type i = 0; i < slaves.size(); ++i) { slaves_head[i] = slaves[i]; } }
int ip_test_init( /* RETURN: -- Always return zero */ LINKED_LIST** L) /* INOUT: -- Parameter */ { LINKED_LIST * new_item ; /* Allocate memory for a LINKED_LIST struct. */ new_item = (LINKED_LIST *)TMM_declare_var_s( "LINKED_LIST" ) ; new_item->i = 1000 ; *L = new_item ; /* Allocate memory for an array of 1 LINKED_LIST struct. */ /* Same as above, but can be resized if desired. */ new_item = (LINKED_LIST *)TMM_declare_var_s( "LINKED_LIST[1]" ) ; new_item->i = 2000 ; new_item->prev = *L ; (*L)->next = new_item ; /* Allocate memory for an array of LINKED_LIST structures. */ new_item = (LINKED_LIST *)TMM_declare_var_s( "LINKED_LIST[2]" ) ; new_item->i = 500 ; new_item[1].i = 501 ; /* Resize one-dimensional array if given an address and new size. */ /* Note: Memory reallocation is only possible for arrays. */ new_item = TMM_resize_array_1d_a( new_item, 8 ) ; new_item->prev = *L ; (*L)->next->next = new_item ; new_item[2].i = 502 ; new_item[3].i = 503 ; new_item[4].i = 504 ; new_item[5].i = 505 ; new_item[6].i = 506 ; /* new_item = (LINKED_LIST *)ip_alloc( 1 , sizeof(LINKED_LIST), attrLINKED_LIST ) ; new_item = (LINKED_LIST *)TMM_declare_var_s( "LINKED_LIST" ) ; new_item->i = 500 ; (*L)->prev = new_item ; new_item = (LINKED_LIST *)ip_alloc( 1 , sizeof(LINKED_LIST), attrLINKED_LIST ) ; new_item = (LINKED_LIST *)TMM_declare_var_s( "LINKED_LIST" ) ; new_item->i = 4000 ; (*L)->next->next = new_item ; */ return ( 0 ); }
/** @details Adds an event to mtv list. -# Check to see if the event is already in the mtv list, return if it is. -# Increment the number of events in the mtv list. -# Reallocate the mtv_list to accomodate the new event. -# Assign the last element of mtv_list to the incoming event. -# Increment the update ticker so mtv knows something changed. */ int Trick::MTV::add_event( Trick::IPPythonEvent * in_event ) { for ( unsigned int ii = 0 ; ii < mtv_count ; ii++ ) { if (in_event == mtv_list[ii]) { return (0) ; } } mtv_count++; if (mtv_count == 1) { mtv_list = (Trick::IPPythonEvent **)TMM_declare_var_s("Trick::IPPythonEvent* mtv_list[1]"); } else { mtv_list = (Trick::IPPythonEvent **)TMM_resize_array_1d_a(mtv_list, mtv_count); } mtv_list[mtv_count-1] = in_event ; mtv_update_ticker++; return 0 ; }
//Command to create a new condition and set its input string (or reset an existing condition string), num is index starting at 0. int Trick::IPPythonEvent::condition(int num, std::string str, std::string comment, REF2* ref, JobData* job) { /** @par Detailed Design: */ if (num == condition_count) { /** @li Add a new condition when num is sequential, i.e. it is equal to condition_count */ condition_count++; if (condition_count == 1) { condition_list = (Trick::condition_t **)TMM_declare_var_s("Trick::condition_t*[1]"); } else { condition_list = (Trick::condition_t **)TMM_resize_array_1d_a(condition_list, condition_count); } condition_list[num] = (Trick::condition_t *)TMM_declare_var_s("Trick::condition_t"); condition_list[num]->fired_count = 0; condition_list[num]->fired_time = -1.0; } if ((num >=0) && (num < condition_count)) { /** @li This is either a new condition or user is changing the condition. */ /** @li Initialize condition variables - default as enabled. */ condition_list[num]->ref = ref ; condition_list[num]->job = job ; condition_list[num]->enabled = true; condition_list[num]->hold = false; condition_list[num]->fired = false; if (ref != NULL) { condition_list[num]->cond_type = 1; } else if (job != NULL) { condition_list[num]->cond_type = 2; } else condition_list[num]->cond_type = 0; condition_list[num]->str = str; // comment is for display in mtv, if not supplied create a comment containing up to 50 characters of cond string if (comment.empty()) { condition_list[num]->comment = str.substr(0,50); } else { condition_list[num]->comment = comment; } // dummy must contain max conditions used in any event so it can replace any event in mtv when deleted } else { /** @li Emit an error if specified index num is not sequential. */ message_publish(MSG_WARNING, "Event condition not added: condition number %d is not sequential.\n", num) ; } return(0); }
//Command to create a new action and set its input string (or reset an existing action string), num is index starting at 0. int Trick::IPPythonEvent::action(int num, std::string str, std::string comment, JobData *job, int act_type) { /** @par Detailed Design: */ if (num == action_count) { /** @li Add a new action when num is sequential, i.e. it is equal to action_count */ action_count++; if (action_count == 1) { action_list = (Trick::action_t **)TMM_declare_var_s("Trick::action_t*[1]"); } else { action_list = (Trick::action_t **)TMM_resize_array_1d_a(action_list, action_count); } action_list[num] = (Trick::action_t *)TMM_declare_var_s("Trick::action_t"); action_list[num]->ran_count = 0; action_list[num]->ran_time = -1.0; } if ((num >=0) && (num < action_count)) { /** @li This is either a new action or user is changing the action. */ /** @li Initialize action variables - default as enabled. */ action_list[num]->job = job ; action_list[num]->act_type = act_type ; action_list[num]->enabled = true; action_list[num]->ran = false; action_list[num]->str = str; // comment is for display in mtv, if not supplied create a comment containing up to 50 characters of act string if (comment.empty()) { action_list[num]->comment = str.substr(0,50); } else { action_list[num]->comment = comment; } // dummy must contain max actions used in any event so it can replace any event in mtv when deleted #if 0 if (num == ip->dummy_event.action_count) { ip->dummy_event.action(num, "XXX_DELETED_ACT"); } #endif } else { /** @li Emit an error if specified index num is not sequential. */ message_publish(MSG_WARNING, "Event action not added: action number %d is not sequential.\n", num) ; } return(0); }