
/// Copyright 2014 MBARI.                                                    
/// MBARI Proprietary Information. All rights reserved.                      
#include <stddef.h>

#include "cwgsys.h"
#include "commands.h"
#include "actions.h"
#include "iofile.h"
#include "proto.h"
#include "log.h"

/// command structures    

/// Commands are not case sensitive but can only use alphanumeric and '_'    
/// alternate names may be separated by '|'                                  
/// pointed to functions must take a char* and return an ErrCode                 

const CmdStruct cmdsRoot[] ={
    {"HELP|?", actHelpCmd},
    {"GET", actGetCmd},
    {"SET", actSetCmd},
    {"CTR", actCtrCmd},
    {"FLAG", actFlagCmd},
    {"PULSE", actPulseCmd},
    {"CLEAR|CLR", actClrCmd},
//    {"TASKS|TK", tskShowStatus},
//    {"NEXT|+", tskAdvance},
    {"LOG", actLogCmd},
    {"CFGEX",actCfgExportCmd},
    {"UPTIME", actUptimeCmd},
    {"RESET", actResetCmd},
    {"CON", actConCmd},
    // file system
    {"LI", actLiCmd},
    {"LS|DIR", fcList},
    {"CAT|PRINT", actCatCmd},
    {"LC", actLineCountCmd},
    {"COPY|MV", fcCopy},
    {"REN", fcRename},
    {"STATS", fcShowS},
    {"RM|DELETE", fcUnlink},
    // debug command(s)  
    {"DEBUG", actSetDebugCmd},
    {"PMEM", pshow},    
    {"HELLO", actHelloCmd},
    {"ECHO", actEchoCmd},
    {"SWEEP", actSweep},
    {"PROTO", proto_test},
    {"SCR", actScriptCmd},
    {"UPLOAD", actUploadCmd},
    {"VER", actVersionCmd},
    {"QSHOW", log_qshow_cmd},
    {"QCOUNT", actQCountCmd},
    {"QPOP", actQPopCmd},
    {"QPEEK", actQPeekCmd},
    {"", NULL}
};

const CmdStruct cmdsGet[] ={
    {"TIME", actGetTime},
    {"BITS", actGetBitCmd},
    {"ANALOG|AD", actGetAnalogCmd},
    {"SER", actGetSerCmd},
    {"VAR", actGetVarCmd},
    {"DATA", actGetDataCmd},
    {"NEXT", actGetNextRun},
    {"", NULL}
};

const CmdStruct cmdsSet[] ={
    {"TIME", actSetTime},
    {"BITS", actSetBitsCmd},
    {"VAR", actSetVarCmd},
    {"SER", actSetSerCmd},
//    {"TASK", tskEnable},
    {"BAUD", actSetBaudCmd},
    {"", NULL}
};

const CmdStruct cmdsClr[] ={
    {"BITS", actClrBitsCmd},
//    {"TASK", tskDisable},
    {"", NULL}
};

const CmdStruct cmdsPulse[] ={
//    {"BIT", actPulseBitCmd},
    {"BITS", actPulseBitsCmd},
};


const ScrCmdStruct cmdsScr[] ={
    {"LOAD", actScrLoadCmd},
    {"UNLOAD", actScrUnloadCmd},
    {"RUN", actScrRunCmd},
    {"JOG", actScrJogCmd},
    {"DELAY", actScrDelayCmd},
    {"RESET", actScrResetCmd},
    {"END", actScrEndCmd},
    {"SHOW", actScrShowCmd},
    {"DEBUG", actScrDebugCmd},
    {"MACRO", actScrMacroCmd},
    {"SCH|SCHEDULE", actScrScheduleCmd},
    {"SYNC", actScrSyncCmd},
    {"GOTO", actScrGotoCmd},
    {"IF", actScrIfCmd},
//    {"FWD|+", actScrNOPCmd},
//    {"REV|-", actScrNOPCmd},
//
//    {"LAST", actScrNOPCmd},
//    {"LIST", actScrNOPCmd},
//    {"CALL", actScrNOPCmd},
     {"", NULL}
};

const CmdStruct cmdsLi[] ={
//    {"DUMP", liDumpCmd},
    {"INIT", actLicorInitCmd},
    // take measurement type out n delay
    {"OR", actLicorORCmd},
    {"TM", actLicorTMCmd},
//    {"DATA", liPrintCmd},
    // get last measurement
    {"LAST", actLicorLastCmd},
    {"NMEAS", actLicorNMEASCmd},
//    {"VALVE", liValveCmd},
//    {"PUMP", liPumpCmd},
//    {"STANDARD|STD", liGetStdCmd},
    {"CAL", actLicorCalCmd},
    {"", NULL}
};
