Pseudo code pour mt_TEMPORALCONSTRAINTNAME.h et mt_TEMPORALCONSTRAINTNAME.C

  • NOMENMAJUSCULE : partie a remplacer via generation de code
    • Sauf pour: FUNCPTR, SYNC_TYPE, CONSTRAINT_TYPE, RT, FALSE, WAIT_FOREVER, TAKE_EVENT, SET_EVENT, TRANSITE, PHR_ACCESS, ACTIVE, TRANSIT
  • __foreach xxxxx___
    • traitement a faire en boucle via generation de code

Fichier mt_TEMPORALCONSTRAINTNAME.h

#ifndef __mt_TEMPORALCONSTRAINTNAME_h
#define __mt_TEMPORALCONSTRAINTNAME_h

#include "Exec/mt.h"
__foreach ModuleAlgo in TemporalConstraint write :
#include "module_NOMMODULEALGO_INDEX.h"
__
#include "PhR_PHYSICALRESOURCENAME.h"

class RobotTask;
class orc_RT_ROBOTASKNAME;
class orc_Mt_TEMPORALCONSTRAINTNAME;
extern void fct_TEMPORALCONSTRAINTNAME(orc_Mt_TEMPORALCONSTRAINTNAME*);

class orc_Mt_TEMPORALCONSTRAINTNAME: public ModuleTask
{
    friend void fct_TEMPORALCONSTRAINTNAME(orc_Mt_TEMPORALCONSTRAINTNAME*);
protected:
__foreach ModuleAlgo in TemporalConstraint write :
    orc_Mod_MODULEALGONAME MODULEALGONAME_INDEX;
__
    orc_PhR_PHYSICALRESOURCENAME* PHYSICALRESOURCENAME;
    orc_RT_ROBOTTASKNAME *pRT;
public:
    void InitTrace();
public:

    orc_Mt_TEMPORALCONSTRAINTNAME(RobotTask *rt, char *name, int itFilter, double period, SYNC_TYPE S_Type, int priority, int nb_sem_link, CONSTRAINT_TYPE C_Type)
    : ModuleTask((FUNCPTR) fct_TEMPORALCONSTRAINTNAME, rt, name, itFilter, period, S_Type, priority, nb_sem_link, C_Type), 
__foreach ModuleAlgo in TemporalConstraint write :
MODULEALGONAME_INDEX(this, period),
__
    {
        InitTrace();
        PHYSICALRESOURCENAME = (orc_PhR_PHYSICALRESOURCENAME*) RT->GetPhR();
   //cas des PhR_SENSOR????
        pRT=(orc_RT_RTNAME *) (RT);
    }
    ~orc_Mt_TEMPORALCONSTRAINTNAME(){};
    void Param();
    void ReParam();
    int SetT1Exceptions();
};
#endif

Fichier mt_TEMPORALCONSTRAINTNAME.C

#include "Exec/mt.h"
#include "Exec/rt.h"
#include "Exec/clockgen.h"
#include "Exec/datadbg.h"

#include "rts.h"
#include "interface.h"
#include "mt_TEMPORALCONSTRAINTNAME.h"

void orc_Mt_TEMPORALCONSTRAINTNAME::InitTrace()
{
}

void orc_Mt_TEMPORALCONSTRAINTNAME::Param()
{}

void orc_Mt_TEMPORALCONSTRAINTNAME::ReParam()
{}

int orc_Mt_TEMPORALCONSTRAINTNAME::SetT1Exceptions()
{
  __foreach Param Link where T1->Param write :
  pRT->T1SOURCEEVENTNAME = 0;
   
  //foreach SentT1 write : ???
  pRT->PutT1NAME(pRT->aut_output_T1NAME);
  __
  return OK;
}

void fct_TEMPORALCONSTRAINTNAME(orc_Mt_TEMPORALCONSTRAINTNAME* mt)
{
  //declaration des variables échangées sur des liens synchronisés
  //example: double Q[7], Pos[6], D_Pos[6];
  foreach(var on a link of type AA, AS, SA or SS with another mt){
    type local_var(dim);
  }
  orc_ROBOTTASKNAME *pRT=(orc_ROBOTTASKNAME *) (mt->RT);
  int Current_Iteration;
  int status_rt, access_drv, do_reinit = FALSE;
  //init all index
    
  //example : int _mi_GPS_CtrlT1_27 = mt->GPS_CtrlT1_27.getIndexClk();
  __foreach ModuleAlgo in TemporalConstraint write :
   int _mi_MODULEALGONAME_INDEX = mt->MODULEALGONAME_INDEX.getIndexClk();
  __
  
  while (!mt->CondKill) {
    if (mt->SemaphoreGive(Create_ok) == ERROR) return;
    if (mt->SemaphoreTake(Init,WAIT_FOREVER) == ERROR) return;
    access_drv = (mt->RT->GetPhR())->GetState();
 
    // Begin Param
    mt->Param();
    mt->EndReparam();
    // End Param

    // Begin Init
    if (access_drv == PHR_ACCESS) {
    __foreach OutputDriverPort in DriverToData Links related to PhysicalResourceRobot of TemporalConstraint write :
      mt->PHYSICALRESOURCENAME->GET_OUTPUTDRIVERPORTNAME();
    __
    }
    __foreach InputDataPort source in SyncLink with another mt write :
    //example : pRT->ReadLink_1(Q);
    pRT->ReadLink_LINKNUMBER(INPUTDATAPORTVARNAME);
    __

    //mt->GPS_CtrlT1_27.init(Q, Pos, mt->X4_GPS_PhR->VmotO, mt->X4_GPS_PhR->VrelO, D_Pos, pRT->Motor_FailE);
    __foreach AlgoModule in TemporalConstraint write :
    mt->MODULEALGONAME_INDEX.init(module_signature);
    __
    // End Init
 
    //Begin write Port-Event
    __foreach event of type T2 or Precondition or SentT1 write :
    if (mt->MODULEALGONAME_INDEX.EVENTNAME == SET_EVENT) {
          (mt->EventInterface)->SendEvent(EVENTNAME, "RTROBOTTASKNAME", mt->RT->GetGlobalTime());
          mt->NOMMODULEALGO_INDEX.EVENTNAME = TAKE_EVENT;
    }
    __
    //End write Port-Event

    if (mt->SemaphoreGive(Init_ok) == ERROR) return;
    if (mt->SemaphoreTake(Compute, WAIT_FOREVER) == ERROR) return;
    Current_Iteration = 0;
    for (;;) {
        __case where SynchroLink == CLOCKSOURCEPERIODIC write :
        if (mt->SemaphoreTake(Synchro, WAIT_FOREVER) == ERROR) return;
        __
        __case where SynchroLink == LINKSOURCE
          __foreach Input SynchronizedLinksource write :
        if (mt->SynchroSemTake(LinkSync[i],ORCFOREVER) == ERROR)
          printf("ERROR semTake on syncho link \n");
          __
        __
        if (mt->CondEnd) break;
        status_rt =  mt->RT->GetState();
        // Take Unlock Parameters
        if (mt->IsReparam()) {
          mt->ReParam();
          mt->EndReparam();
        }
        // End re-Parameters
        if (mt->Filter_Iteration == Current_Iteration)
          mt->SemaphoreGive(Filter_ok);
          Current_Iteration++;
          access_drv = (mt->RT->GetPhR())->GetState();
          //Begin computation
          if ((access_drv == PHR_ACCESS) &&
              ((status_rt==ACTIVE)||(status_rt==TRANSITE)) &&
              (do_reinit == FALSE))
          {
             mt->NOMMODULEPHYS->reinit();
             do_reinit = TRUE;
          }
          //T1 Exceptions Handling
          // Compute NOMMODULEALGO_INDEX
          if (access_drv == PHR_ACCESS) {
            __foreach port data reading a PhR){
            mt->NOMMODULEPHYS->GET_OUTPUTPORTVARNAME();
            __
          }
     foreach(input var on a sync link with another mt){
     //pRT->ReadLink_1(Q);
     pRT->ReadLink_NUMLINK(VAR);
   }


   __foreach AlgoModule in TemporalConstraint write :
   if ((mt->Clock)->IsClkActive(_mi_MODULEALGONAME_INDEX) == 0)
       mt->MODULEALGONAME_INDEX.compute(module_signature);
       __foreach synchro_output write:
       pRT->WriteLink_NOMLINK(mt->NOMMODULEALGO_INDEX.OUTPUTVARNAME);)
       __
       mt->SetT1Exceptions();
   }
     __foreach event of type exception T2 or PostCond or SentT1 write :
   if (mt->MODULEALGONAME_INDEX.EVENTNAME == SET_EVENT) {
        (mt->EventInterface)->SendEvent(EVENTNAME,"ROBOTASKNAME",mt->RT->GetGlobalTime());
         mt->MODULEALGONAME_INDEX.EVENTNAME = TAKE_EVENT;
         //T1 Exceptions Handling
         __if event of type T1 write :
         mt->SetT1Exceptions();
         __ //if
   }
     __//foreach event of type exception T2 or PostCond or SentT1 
   __foreach AlgoModule in TemporalConstraint
   status_rt =  mt->RT->GetState();
   if ((access_drv == PHR_ACCESS) &&
       ((status_rt == ACTIVE) || (status_rt == TRANSITE))) {
        __foreach output var
        mt->NOMMODULEPHYS->PUT_OUTPUTVAR(mt->NOMMODULEALGO_INDEX.VAR);
        __
   }
   mt->MTEndCompute();
   __
     
   // Begin end
   __ foreach AlgoModule in TemporalConstraint write :
   mt->MODULEALGONAME_INDEX.end();
   __foreach output var write 
   mt->PHYSICALRESOURCEROBOT->PUT_OUTPUTVAR(mt->MODULEALGONAME_INDEX.OUTPUVARNAME);
   __
   __

   // End end
   if (mt->SemaphoreGive(End_ok) == ERROR) return;
   if (mt->SemaphoreTake(Continue,WAIT_FOREVER) == ERROR) return;
   __
   if (mt->SemaphoreTake(Kill,WAIT_FOREVER) == ERROR) return;
   mt->CondKill = mt->CondEnd = mt->RequestParam = FALSE;

   if (mt->SemaphoreGive(Kill_ok) == ERROR) return;
}


module_signature:

foreach (input_var){
  if(var on a sync_link with another mt) local_var
    if(var on a driver_link) mt->NOMMODULEPHYS->OUTPUTVARNAME
      if(var coming from module in same mt) mt->NOMMODULEALGODISTANT->OUTPUTVARNAME
   if(var is a T1) pRT->T1NAME
     }

dans l'exemple Drone: TCNAME = RTNAME_INDEX

s'il y a plusieurs modules dans une TC, ils doivent être appelés dans l'ordre défini par les dépendences (cf ce que Roger avait fait en V3)
-- SorayaArias - 05 May 2010
Topic revision: r2 - 06 May 2010, SorayaArias
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding SedWiki? Send feedback