void TrueTimeSourceVisitor::Visit_Task( const Semantics::Task &task ) { // Get the task name std::string taskName = task.name(); DEBUGOUT( "\tTask: " << taskName << std::endl ); // Process messages for this task QualifiedMessageSet messageSet = GetQualifiedMessages( task ); QualifiedMessageSet::iterator messageIter = messageSet.begin(); for ( ; messageIter != messageSet.end() ; messageIter++ ) { // Visit the message to generate template section Visit_QualifiedMessageStructure( *messageIter, task ); } // Get the exec info and schedule ExecInfoSet execInfoSet = task.info(); ExecInfoSet::iterator execInfoIter = execInfoSet.begin(); Semantics::Duration duration = execInfoIter->Duration_child(); double wcet = duration.exectimesecs(); // Add a section for the task execution AddSectionDictionary( "TASK_SECTION" ); string wcet_symbol = taskName + "_WCET"; GetTemplateDictionary().SetValue( "TASK_WCET_STR", wcet_symbol ); GetTemplateDictionary().SetFormattedValue( "TASK_WCET", "%f", wcet ); ostringstream out1; out1 << "#define " << wcet_symbol << " " << wcet; _SchedHeaderLines.push_back( out1.str() ); // Setup the peripheral schedule Semantics::Schedule schedule = execInfoIter->Schedule_child(); std::string sched = schedule.sched(); int count = sched_count( sched ); vector< double > start_times = sched_values( sched ); ostringstream symbolic_array; for ( int idx = 0; idx < count; idx++ ) { ostringstream out2; out2 << "#define " << taskName << "_" << idx << " " << start_times[idx]; _SchedHeaderLines.push_back( out2.str() ); if ( idx > 0 ) { symbolic_array << ", "; } symbolic_array << taskName << "_" << idx; } GetTemplateDictionary().SetIntValue( "TASK_COUNT", count ); //GetTemplateDictionary().SetValue( "TASK_SCHEDULE", sched ); GetTemplateDictionary().SetValue( "TASK_SCHEDULE", symbolic_array.str() ); // Get the set of components this task invokes ComponentSet componentSet = task.invokes(); // If there are components... if ( !componentSet.empty() ) { // Start with the first component Semantics::Component component = *componentSet.begin(); // Get the component name std::string compName = component.name(); GetTemplateDictionary().SetValue( "TASK_NAME", compName + "_task" ); GetTemplateDictionary().SetValue( "TASK_FUNCTION", compName + "_code" ); // Create the list of component header files StringList headerList = Split( component.cfiles() ); StringList::iterator headerIter = headerList.begin(); // Iterate through the list for( ; headerIter != headerList.end() ; headerIter++ ) { if ( _already_included.find( *headerIter ) == _already_included.end() ) { // Include a header section and populate it AddSectionDictionary( "TASK_INCLUDE" ); GetTemplateDictionary().SetValue( "TASK_HEADER", *headerIter ); PopSectionDictionary(); _already_included.insert( *headerIter ); } } // Set the component function name GetTemplateDictionary().SetValue( "TASK_COMPNAME", compName ); std::string compMSubsys = component.msubsystem(); // Account for GetTemplateDictionary().SetValue( "TASK_MSUBSYS", compMSubsys ); // Setup the input signals to the component SortedSignal_ByCallIndex_Set inputSignalSet = component.consumes_sorted( SignalCallIndexSorter() ); SortedSignal_ByCallIndex_Set::iterator inputIter = inputSignalSet.begin() ; for( ; inputIter != inputSignalSet.end(); inputIter++ ) { AddSectionDictionary( "INPUT_SIGNALS" ); Visit_Signal( *inputIter ); PopSectionDictionary(); } // Setup the output signals to the component SortedSignal_ByCallIndex_Set outputSignalSet = component.generates_sorted( SignalCallIndexSorter() ); SortedSignal_ByCallIndex_Set::iterator outputIter = outputSignalSet.begin(); for ( ; outputIter != outputSignalSet.end(); outputIter++ ) { AddSectionDictionary( "OUTPUT_SIGNALS" ); Visit_Signal( *outputIter ); PopSectionDictionary(); } } // Done with section dictionary PopSectionDictionary(); }