#include "ChopCtrl.h" /************************************************************************* $Archive: /PACS/OnBoard/SimChop.c $ $Revision: 1.10 $ $Date: 2009/04/23 13:51:12 $ $Author: amazy $ $Log: SimChop.c,v $ Revision 1.10 2009/04/23 13:51:12 amazy 6.029 * * 15 5/05/04 4:34p Pacs Egse * * 14 3/31/03 3:16p Pacs Egse * Compiled for MOSAIC_BOARD * * 13 28/08/02 11:49 Amazy * Added the header with the history log *************************************************************************/ #ifdef CHOP_SIM // this file doesn't compile if CHOP_SIM is not defined //#pragma seg("seg_test"); //__asm(".segment /pm seg_test;"); #ifdef SIMULATOR #include "virtuosoSim.h" #else // SIMULATOR #include "v_macro.h" #include "node1.h" #include "k_struct.h" #endif #include "params.h" #include "u_verb.h" //**************************************************************** // LOCAL PARAMETERS //**************************************************************** static K_TIMER* pChopperSimulatorTimer = NULL; /**************************************************************** FUNCTIONS DECLARATION ****************************************************************/ void SimChop(); // commands function BOOL CommandStartChopperSimulator(CommandParameter param); BOOL CommandStopChopperSimulator(CommandParameter param); /**************************************************************** FUNCTIONS IMPLEMENTATION ****************************************************************/ /* TASK_FUNCTION : void SimChop() ****************************** AUTHOR : AMazy */ void SimChop() { CommandParameter p; VERL(VER_TASK, 0, "Starting Chopper Simulator"); // start execution of chopper simulator p.Uint = 100; // period of execution (im ms) CommandStartChopperSimulator(p); while (1) { KS_SemaTestW(SEMA_TIMER_CHOP_SIM); tmp+=1; // gChopperCurrentPosition = gChopperCurrentSetPoint + tmp; // VERL1(VER_CHOP_SIM, 9, "CHOP SIM : Current position = %d", gChopperCurrentPosition); } VERL(VER_TASK, 0, "Exiting Chopper Simulator"); }; /* CMD_FUNCTION : BOOL CommandStartChopperSimulator(CommandParameter param) ************************************************************************ AUTHOR : Amazy USE : Start the Chopper Simulator. This command is defined only for test purpose. It does not send any ACK or NACK PARAMS : Uint : new period (in ms) */ BOOL CommandStartChopperSimulator(CommandParameter param) { VERL1(VER_SEQ_CMD, 2, "SEQ CMD : START CHOPPER SIMULATOR, period = %d", param.Uint); // stops the old timer if there were one. if (pChopperSimulatorTimer) { VERL(VER_SEQ_CMD, 8, "SEQ : Stopping and freeing old gpChopperSimulatorTimer"); KS_LowTimerStop(pChopperSimulatorTimer); KS_LowTimerFree(pChopperSimulatorTimer); } if ((pChopperSimulatorTimer = KS_LowTimerGet()) == NULL) { VER(VER_ERR, "CHOP SIM : could not initialize Timer"); } KS_LowTimerStart(pChopperSimulatorTimer, param.Uint, param.Uint, SEMA_TIMER_CHOP_SIM); return FALSE; }; /* CMD_FUNCTION : BOOL CommandStopChopperSimulator(CommandParameter param) *********************************************************************** AUTHOR : Amazy USE : Stop the Chopper Simulator. This command is defined only for test purpose. It does not send any ACK or NACK PARAMS : Uint : new period (in ms) */ BOOL CommandStopChopperSimulator(CommandParameter param) { VERL(VER_SEQ_CMD, 2, "SEQ CMD : STOP CHOPPER SIMULATOR"); // stops the old timer if there were one. if (pChopperSimulatorTimer) { VERL(VER_SEQ_CMD, 8, "SEQ : Stopping and freeing old gpChopperSimulatorTimer"); KS_LowTimerStop(pChopperSimulatorTimer); KS_LowTimerFree(pChopperSimulatorTimer); pChopperSimulatorTimer = NULL; } return FALSE; }; #else //CHOP_SIM void SimChop() { } #endif //CHOP_SIM