//! In this file we define the IOC commands //! for initializzing Brooks0254 chassis. #ifndef _IOC_COMMS_BROOKS_ #define _IOC_COMMS_BROOKS_ extern "C" { #include #include #include #include #include } ; #include "epicsExit.h" #include "epicsThread.h" #include "iocsh.h" #include "registryFunction.h" #include "epicsExport.h" #include "epicsTimer.h" #include #include using namespace std; #include "Brooks0254Port.hh" #include "Brooks0254Set.hh" /* Define Arguments descriptors for "Init" Command */ static const iocshArg InitArgs[3] = { {"Chassis Number", iocshArgInt }, {"Chassis Address", iocshArgInt }, {"Port's device name", iocshArgString } }; /* Define the array of the pointers to the Arguments descriptors for "Init" command */ static const iocshArg* const InitArgs_ptr[3] = { &InitArgs[0], &InitArgs[1], &InitArgs[2] }; /* Define Arguments descriptors for "Stop" Command */ static const iocshArg StopArgs[1] = { {"Chassis Number", iocshArgInt } }; /* Define the array of the pointers to the Arguments descriptors for "Stop" command */ static const iocshArg* const StopArgs_ptr[1] = { &StopArgs[0] }; /* Define Arguments descriptors for "Send" Command */ static const iocshArg SendArgs[3] = { {"Chassis Number", iocshArgInt }, {"Command String", iocshArgString }, {"Readback Flag" , iocshArgInt } }; /* Define the array of the pointers to the Arguments descriptors for "Send" command */ static const iocshArg* const SendArgs_ptr[3] = { &SendArgs[0], &SendArgs[1], &SendArgs[2] }; /* Define arguments structures for Brooks0254 Init Command */ static const iocshFuncDef InitBrooks_commDef = {"InitBrooks", 3, InitArgs_ptr }; static const iocshFuncDef StopBrooks_commDef = {"StopBrooks", 2, StopArgs_ptr }; static const iocshFuncDef SendBrooks_commDef = {"SendBrooks", 3, SendArgs_ptr }; /* Brooks0254 Init function */ static void runInitBrooks( const iocshArgBuf* args ) { cout << "Initializing Brooks Application for chassis " << args[0].ival << " with address " << args[1].ival << " at " << args[2].sval << endl; Brooks0254Set::StartDevice( args[0].ival, args[1].ival, args[2].sval ); return; } /* Brooks0254 Stop function */ static void runStopBrooks( const iocshArgBuf* args ) { cout << "Brooks application for port " << args[0].ival << " is being stopped" << endl; Brooks0254Set::StopDevice( args[0].ival ); return; } /* Brooks0254 Send function */ static void runSendBrooks( const iocshArgBuf* args ) { cout << "Sending to Brooks chassis #" << args[0].ival << " message >" << args[1].sval << "< " << " with readback flag " << args[2].ival << endl; if( Brooks0254Set::bsDevMap[args[0].ival].second != 0 ) { Brooks0254Set::bsDevMap[args[0].ival].second->GetPort()->Send( args[1].sval, args[2].ival ); } else { cerr << "Failed... Brooks chassis #" << args[0].ival << " does not seem to exist" << endl; } return; } /* Define a class whos constructor registers Init and Stop commands */ class IocShellComReg { public: IocShellComReg() { iocshRegister( &InitBrooks_commDef, runInitBrooks ); iocshRegister( &StopBrooks_commDef, runStopBrooks ); iocshRegister( &SendBrooks_commDef, runSendBrooks ); } }; /* Define a dummy global variable to register commands before the execution starts */ static IocShellComReg dummyObj; #endif