Alexandre Salconi-Denis / Mbed 2 deprecated ProjetOctopode

Dependencies:   debug mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TTaskCritique.cpp Source File

TTaskCritique.cpp

00001 
00002 #include "TTaskCritique.h"
00003 
00004 TTaskCritique::TTaskCritique(int priority):TTask(priority)
00005 {
00006     debug(DEBUG_INIT_TASKCRITT, "\n\r Debut init");
00007     //m_CtrlBridge = m_CtrlBridge->getInstance();
00008     
00009     
00010     m_CtrlBridge->initCom();
00011     /*#ifdef*/#ifndef DGB_FORCE_INIT
00012     //m_CtrlBridge->initCom();
00013     //#else
00014     do{
00015     //m_CtrlBridge->initCom();
00016     m_ListDesModules = m_CtrlBridge->findModule(0,0,0,0); //get all modules
00017     
00018         if(m_ListDesModules.size() != 11) //its a patch we need to delete it.
00019         {
00020             debug(DEBUG_INIT_TASKCRITT, "\n\r Init Fail");
00021             forceShutDown(false);
00022             m_CtrlBridge->clearALL();
00023             wait(1);
00024             
00025             
00026             forceShutDown(true);
00027             m_CtrlBridge->initCom();
00028         }
00029     }while(m_ListDesModules.size() != 11);
00030     #endif
00031     tymy=true;
00032     debug(DEBUG_INIT_TASKCRITT, "\n\r Init Reussi");
00033 }
00034 
00035 TTaskCritique::~TTaskCritique()
00036 {
00037 
00038 //    return;
00039 }
00040 
00041 void TTaskCritique::forceShutDown(bool offON)
00042 {
00043     DigitalOut pinA(PB_8);
00044     DigitalOut pinB(PB_9);
00045 
00046     if(offON) {
00047         pinA=1;
00048         wait(1);
00049         pinB=0;
00050     } else {
00051         pinA=0;
00052         wait(1);
00053         pinB=1;
00054     }
00055 }
00056 
00057 void TTaskCritique::criticalTreatment(char adresse)
00058 {
00059     debug("jello");
00060     //ici on debug et on traite le problemme//
00061         forceShutDown(tymy);
00062     tymy = !tymy;
00063 }
00064 
00065 void TTaskCritique::task(void)
00066 {
00067     
00068     
00069     //pas sur que c'Est tout ce qui doit etre ici mais je vois pas quoi d'autre pour le moment.
00070     string flag,data;
00071 
00072     flag.append(1,0);//0x02);
00073     for(int i=0; i<m_ListDesModules.length(); ++i)
00074     {
00075      wait_us(300);
00076      flag.clear();
00077      flag.append(1,7);  
00078      data.clear(); 
00079     debug(DEBUG_TASKCRITT,"\n\r result: %d",m_CtrlBridge->send(m_ListDesModules.at(i),flag,data));
00080     if(flag[0]== 0x02)
00081      criticalTreatment(m_ListDesModules.at(i));
00082     }
00083 
00084 }