command rewritten for AC

This commit is contained in:
Ren RenJuan 2014-01-13 01:29:22 +00:00
parent 633a9992b7
commit a6bac1335c
10 changed files with 459 additions and 172 deletions

View File

@ -23,17 +23,17 @@ BOSTLIB=-L/usr/lib/boost
BOSINCL=-L/usr/include/boost BOSINCL=-L/usr/include/boost
LOG4LIB=-L/usr/lib LOG4LIB=-L/usr/lib
#DEF_XML_RPC=-DXMLRPC-C #DEF_XML_RPC=-DXMLRPC_C
#XMLRPC_INCL= #XMLRPC_INCL=-I/usr/include/xmlrpc-c
#XMLRPC_LIB= #XMLRPC_LIB=-I/usr/lib
CLIENT=drde CLIENT=drde
SLIBS= -L/usr/lib $(BOSTLIB) $(LOG4LIB) -l boost_system -l boost_thread -l log4cpp SLIBS= -L/usr/lib $(BOSTLIB) $(LOG4LIB) -l boost_system -l boost_thread -l log4cpp -l ncurses
ifeq ($(LOCATION),authoring) ifeq ($(LOCATION),authoring)
SINCL= -I include -I ../AusRegCliever/include -I /usr/include/log4cpp $(BOSINCL) SINCL= -I include -I ../AusRegCliever/include -I /usr/include/log4cpp $(BOSINCL)
CFLAGS= -DCURRENT_DEBUG=1000 CFLAGS= -DCURRENT_DEBUG=1000 -ggdb3
endif endif
CLIBS= -L$(USRLIB) CLIBS= -L$(USRLIB)
@ -86,7 +86,7 @@ build/cdLogger.o: client/cdLogger.cpp include/cdLogger.h
$(CC) $(CFLAGS) client/cdLogger.cpp -c -o build/cdLogger.o $(SINCL) $(CC) $(CFLAGS) client/cdLogger.cpp -c -o build/cdLogger.o $(SINCL)
build/cliever.o: client/ausreg-cd.cpp include/*.h build/cliever.o: client/ausreg-cd.cpp include/*.h
$(CC) $(CFLAGS) client/ausreg-cd.cpp -c -o build/cliever.o $(SINCL) $(CC) $(CFLAGS) client/ausreg-cd.cpp -c -o build/cliever.o $(SINCL) $(DEF_XML_RPC) $(XMLRPC_INCL)
build/clientDaemonConfig.o: client/clientDaemonConfig.cpp include/*.h build/clientDaemonConfig.o: client/clientDaemonConfig.cpp include/*.h
$(CC) $(CFLAGS) client/clientDaemonConfig.cpp -c -o build/clientDaemonConfig.o $(SINCL) $(CC) $(CFLAGS) client/clientDaemonConfig.cpp -c -o build/clientDaemonConfig.o $(SINCL)
@ -101,12 +101,12 @@ build/commander.o: client/commander.cpp include/mdCommander.h
$(CC) $(CFLAGS) client/commander.cpp $(SINCL) -c -o build/commander.o $(CC) $(CFLAGS) client/commander.cpp $(SINCL) -c -o build/commander.o
build/$(CLIENT)-cd: $(ACOBJS) build/$(CLIENT)-cd: $(ACOBJS)
$(CC) $(CFLAGS) -o build/$(CLIENT)-cd $(SINCL) $(LIBS) $(ACOBJS) $(SLIBS) $(CC) $(CFLAGS) -o build/$(CLIENT)-cd $(SINCL) $(LIBS) $(ACOBJS) $(SLIBS) $(XMLRPC_LIB)
build/apig-cli: build/mdClientBehavior.o build/mdClientState.o build/mdClientDevice.o \ build/apig-cli: build/mdClientBehavior.o build/mdClientState.o build/mdClientDevice.o \
build/tools.o build/coretestbucket.o client/apig-cli.cpp build/tools.o build/coretestbucket.o client/apig-cli.cpp
$(CC) $(CFLAGS) client/apig-cli.cpp $(CLIBS) $(CINCL) -o build/apig-cli build/tools.o build/coretestbucket.o \ $(CC) $(CFLAGS) client/apig-cli.cpp $(CLIBS) $(CINCL) -o build/apig-cli build/tools.o build/coretestbucket.o \
build/mdClientBehavior.o build/mdClientState.o build/mdClientDevice.o build/mdClientBehavior.o build/mdClientState.o build/mdClientDevice.o $(XMLRPC_LIB)
doxygen/index.html: etc/doxygen.config doxygen/index.html: etc/doxygen.config
doxygen etc/doxygen.config doxygen etc/doxygen.config

Binary file not shown.

View File

@ -72,7 +72,7 @@ void acClientServer() { // AKA "Cliever"
boost::thread cliever(runCliever); boost::thread cliever(runCliever);
boost::thread apiLayer(runAPILayer); boost::thread apiLayer(runAPILayer);
#ifdef XMLRPC-C #ifdef XMLRPC_C
xmlrpc_c::serverAbyss myAbyssServer( xmlrpc_c::serverAbyss myAbyssServer(
thisConfig->api_registry, thisConfig->api_registry,
@ -80,7 +80,6 @@ void acClientServer() { // AKA "Cliever"
thisConfig->xmlrpcLogpath thisConfig->xmlrpcLogpath
); );
#endif #endif
if (!apiLayer.joinable() || !cliever.joinable()) { if (!apiLayer.joinable() || !cliever.joinable()) {
@ -91,7 +90,7 @@ void acClientServer() { // AKA "Cliever"
} }
else { else {
theseLogs.logN(0,"Cliever started OK."); theseLogs.logN(0,"Cliever started OK.");
#ifdef XMLRPC-C #ifdef XMLRPC_C
theseLogs->logN(2,"%s %d","Accepting XMLRPC API Requests on Port",thisConfig->xmlrpcPort); theseLogs->logN(2,"%s %d","Accepting XMLRPC API Requests on Port",thisConfig->xmlrpcPort);
myAbyssServer.run(); myAbyssServer.run();
#endif #endif

View File

@ -1,5 +1,14 @@
#include <ncurses.h>
#include "ausreg-cd.h" #include "ausreg-cd.h"
const char *banner = CD_NAME " " CD_VERSION " compiled on " __DATE__ " @ " __TIME__ " (%d)";
const char *cmdNames[9] = { "check", "info", "poll", "transfer query",
"create", "renew", "update", "delete", "transfer" };
char theBanner[256];
int targetHost = 0;
mdDG mdg;
int is_numeric(const char *p) { int i = strlen(p),j=0; int is_numeric(const char *p) { int i = strlen(p),j=0;
if (*p) { if (*p) {
char c; char c;
@ -13,190 +22,463 @@ int is_numeric(const char *p) { int i = strlen(p),j=0;
} }
return 0; return 0;
} }
void mdCommander::doHeader() {
int displayCmd = cmdsNow ? cmdNow + 1 : 0;
clear();
mvprintw(0,(col-strlen(banner))/2,"%s",theBanner);
sprintf(wwork,"Target AC host: %d this one: %d commmands: %d current: %d",
targetHost,mdStdDevIdx,activeCommands,displayCmd);
mvprintw(1,(col-strlen(wwork))/2,"%s",wwork);
}
void mdCommander::digestibleLines() {
char *sp;
int nLines=0, wrow=5;
nocbreak();
for (;argsNow[cmdNow] < MAX_CMD_ARGS;argsNow[cmdNow]++)
{sp = commandArgs[cmdNow][argsNow[cmdNow]++] = (char *) malloc(256);
mvgetstr(wrow++,2,sp);
if (!strlen(sp)) break;
}
cbreak();
prompt(false);
}
void mdCommander::prompt(bool forStrings) {
if (forStrings)
mvprintw(row-1,1,">>");
else
mvprintw(row-1,1,"> ");
}
void mdCommander::driver() { void mdCommander::driver() {
bool rc; bool rc, x;
char instrinsic[16],next,rawString[4096],work[4096]; char next,rawString[128],work[128];
const char *mdErrCode = ""; const char *mdErrCode = "";
int i,commandLength; int i,commandLength;
activeCommands = 0;
cmdNow = 0;
cmdsNow = 0;
memset(commandsNow,0,sizeof(commandsNow));
memset(argsNow,0,sizeof(argsNow));
initscr();
cbreak();
greet(); greet();
while(acceptingInput) { while(acceptingInput) {
putchar('>'); mvprintw(row-1,1,"> ");
next=0; next=0;
i=0; i=0;
memset(rawString,0,sizeof(rawString)); memset(rawString,0,sizeof(rawString));
while(next != '\012') { while(next != '\012') {
next = getchar(); next = mvgetch(row-1,2+i);
rawString[i++] = next; rawString[i++] = next;
if (i > (sizeof(rawString) - 1)) { if (i > (sizeof(rawString) - 1)) {
puts("Max length exceeded!"); say((char *)"Max length exceeded!");
continue; continue;
} }
if (next == '\012')
rawString[strlen(rawString)-1] = 0;
} }
if (!strlen(rawString)) continue; if (!strlen(rawString)) continue;
if (strlen(rawString) == 2) { if (strlen(rawString) == 1) {
switch(rawString[0]) { switch(rawString[0]) {
case '1': ; case '2': ; case '3': ; case '4': ; case '5': ;
case '6': ; case '7': ; case '8': ; case '9':
goto retarget ;
case '!': runCommand(false);
break;
case '?': help(); case '?': help();
break; break;
case 'e': eppMainMenu(); case 'e': eppMainMenu();
break; break;
case '!': sendCommand();
break;
case 'X': flushCommand();
break;
case 'a': acMainMenu(); case 'a': acMainMenu();
break; break;
case 'c': check(); case 'c': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
check(false);
break; break;
case 'i': info(); case 'p': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
poll(false);
break; break;
case 't': transferCheck(); case 'i': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
info(false);
break; break;
case 'C': create(); case 't': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
queryTransfer(false);
break; break;
case 'R': renew(); case 'C': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
create(false);
break; break;
case 'U': update(); case 'R': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
renew(false);
break; break;
case 'D': trash(); case 'U': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
update(false);
break; break;
case 'T': transfer(); case 'D': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
trash(false);
break;
case 'T': commandsNow[(cmdNow=cmdsNow++)]; activeCommands++;
transfer(false);
break; break;
} }
continue; continue;
} }
if (strlen(rawString) == 3) { if (strlen(rawString) == 2) {
if (!strcmp(rawString,"??")) { if (!strcmp(rawString,"??")) {
showCommand(); showCommand(true);
continue;
}
if (!strcmp(rawString,"!!")) {
runCommand(true);
continue; continue;
} }
} }
if (is_numeric(rawString) == 2) { if (is_numeric(rawString) >= 1) {
rawString[strlen(rawString)] = 0; retarget:
mdStdDevIdx = atoi(rawString); targetHost = atoi(rawString);
doHeader();
continue; continue;
} }
if (strlen(rawString) >= 4 && strlen(rawString) <= 6 ) if (is_numeric(rawString+1) >= 1) {
{if (!strcmp(rawString,"log\n")) { int targetCmd = atoi(rawString+1);
system("less /tmp/ausreg-cd.log"); switch(rawString[0]) {
case 'C':
if (isValidCmd(targetCmd,false)) {
cmdNow = --targetCmd;
doHeader();}
else say((char *)"Invalid Command Index");
break;
case 'E':
if (isValidCmd(targetCmd,false)) {
cmdNow = --targetCmd;
editingCommand(false);
doHeader();}
break;
case 'S':
if (isValidCmd(targetCmd,false)) {
cmdNow = --targetCmd;
sendCommand(cmdNow);
doHeader();
}
else say((char *)"Invalid Command Index");
break;
case 'X':
if (!targetCmd) {targetCmd = 0; x = true;}
else {targetCmd--; x = false;}
if (isValidCmd(targetCmd,true)) {
flushCommand(targetCmd,x);
doHeader();
}
else say((char *)"Invalid Command Index");
break;
}
continue; continue;
} }
if (!strcmp(rawString,"done\n")) {
return; if (strlen(rawString) >= 3 && strlen(rawString) <= 5 )
} {if (!strcmp(rawString,"log")) {
if (!strcmp(rawString,"mdapi\n")) { sprintf(wwork,"cut -b 1-%d /tmp/ausreg-cd.log | less",col);
system("mdclient "); system(wwork);
clear();
continue; continue;
} }
if (!strcmp(rawString,"quit\n")) { if (!strcmp(rawString,"mlog")) {
sprintf(wwork,"cut -b 1-%d /tmp/drde-cliever.log | less",col);
system(wwork);
clear();
continue;
}
if (!strcmp(rawString,"done")) {
goto done;
}
if (!strcmp(rawString,"quit")) {
thisConfig->terminateRequest = true; thisConfig->terminateRequest = true;
return; goto done;
} }
if (!strcmp(rawString,"mdapi\n")) {
continue;
}
if (strlen(rawString) < 3) {
puts("That SCPI command is too short!");
continue;
}
rc = epp(rawString);
if (!rc) puts("Command transmitted: OK.");
else printf("Command result: %s.",mdErrCode);
continue; continue;
} }
} }
done:
nocbreak();
endwin();
}
void mdCommander::say(char *what)
{ memset(wwork,' ',sizeof(wwork));
mvprintw(row-2,1,wwork);
mvprintw(row-2,1,what);
} }
void mdCommander::greet() { void mdCommander::greet() {
puts(" AC Commander "); const char *title="AusReg Cliever Commander",
puts("Enter ? for help or an AC command"); *prompt="? for main menu or enter commander command now";
sprintf(theBanner,banner,thisConfig->shellProcess);
getmaxyx(stdscr,row,col);
mvprintw(0,(col-strlen(banner))/2,"%s",theBanner);
mvprintw(row/2,(col-strlen(title))/2,"%s",title);
mvprintw(row-2,1,"%s",prompt);
refresh();
acceptingInput = true; acceptingInput = true;
EPPmode = true; EPPmode = true;
currentDevice = std::string("ALX");
} }
void mdCommander::help() { void mdCommander::help() {
const char *banner = "\n" CD_NAME " " CD_VERSION " compiled on " __DATE__ " @ " __TIME__ " (%d)\n\n"; doHeader();
mvprintw(5,10," a - AC system control menu");
system("clear"); mvprintw(6,10," e - standard EPP command menu");
printf(banner,thisConfig->shellProcess); mvprintw(7,10," ? - display this screen");
printf(" target acEPPDevIdx-> %d this acEPPDevIdx: %d \n\n",0,mdStdDevIdx); mvprintw(8,10," ?? - display commands");
puts(" ? - display this screen"); mvprintw(9,10," ! - run the active command");
puts(" ! - send the pending command"); mvprintw(10,10," !! - run active commands");
puts(" ?? - display the pending command"); mvprintw(11,10," C<n> - make <n> the active command");
puts(" X - discard the pending command"); mvprintw(12,10," E<n> - display/edit command <n> ");
puts(" <n> - make <n> (an integer) the target acEPPDevIdx"); mvprintw(13,10," S<n> - send command <n>");
puts(" done - terminate this command loop but not ausreg-cd"); mvprintw(14,10," X<n> - discard the command(s)");
puts(" e - standard EPP command menu"); mvprintw(15,10," <n> - make <n> the target EPP server");
puts(" a - AC system control menu"); mvprintw(16,10," log - display this cliever's log");
puts(" log - display this cliever's log"); mvprintw(17,10," mlog - display the master daemon log");
puts(" rlog - pull and display the master daemon log"); mvprintw(18,10," done - terminate commander but not process");
puts(" quit - terminate this process tree\n\n"); mvprintw(19,10," quit - terminate this process and its' children");
puts("Any command valid outside command data loop(>>)."); mvprintw(23,5,"<n> is an integer, above active everywhere outside data entry (>>)");
mvprintw(24,5,"no space before <n>, X0 to delete all commands.");
} }
void mdCommander::eppMainMenu() { void mdCommander::eppMainMenu() {
const char *banner = "\n" CD_NAME " " CD_VERSION " compiled on " __DATE__ " @ " __TIME__ " (%d)\n\n"; doHeader();
mvprintw(5,10," Create a new EPP command");
system("clear"); mvprintw(10,10," Queries ");
printf(banner,thisConfig->shellProcess); mvprintw(12,10," c - check");
printf(" target acEPPDevIdx-> %d this acEPPDevIdx: %d \n\n",0,mdStdDevIdx); mvprintw(13,10," i - info");
puts(" Queries \n"); mvprintw(14,10," p - poll");
puts(" c - check"); mvprintw(15,10," t - transfer query");
puts(" i - info"); mvprintw(17,10," Transactions");
puts(" t - transfer\n"); mvprintw(19,10," C - create");
puts(" Commands \n"); mvprintw(20,10," R - renew");
puts(" C - create"); mvprintw(21,10," U - update");
puts(" R - renew"); mvprintw(22,10," D - delete");
puts(" U - update\n"); mvprintw(23,10," T - transfer");
puts(" D - delete");
puts(" T - transfer");
} }
void mdCommander::acMainMenu() { void mdCommander::acMainMenu() {
const char *banner = "\n" CD_NAME " " CD_VERSION " compiled on " __DATE__ " @ " __TIME__ " (%d)\n\n"; doHeader();
mvprintw(5,(col-strlen("AC System Directives"))/2,"AC System Directives");
system("clear"); mvprintw(15,10," (H)ALT - Flush queues, stop, ignore incoming requests");
printf(banner,thisConfig->shellProcess); mvprintw(16,10," (L)OAD - Resume execution, accept work");
printf(" target acEPPDevIdx-> %d this acEPPDevIdx: %d \n\n",0,mdStdDevIdx); mvprintw(17,10," (B)ANG - Force reload the entire AC system");
puts(" Directives \n\n"); mvprintw(20,10,"These are only active on this screen, there's no confirmation.");
puts(" RST - followed by quit resets entire AC system");
} }
bool mdCommander::epp(char *cmd) { bool sendEPPCommand() {
char *command,work[256];
bool isDirect=false,rc=true;
if (!mdStdDevIdx && !strncmp(cmd,"RST",3)) {
mdDG mdg;
mdg.dg.hdr.sourceHandle = thisCliever->myHandle; mdg.dg.hdr.sourceHandle = thisCliever->myHandle;
mdg.dg.hdr.payloadSize = 0; mdg.dg.hdr.payloadSize = 0;
mdg.dg.hdr.msgType = MDDG_CDRESET; mdg.dg.hdr.msgType = MDDG_CDRESET;
if (thisCliever->fg->send(mdg.dg)) rc = false; return thisCliever->fg->send(mdg.dg);
}
bool mdCommander::runCommand(bool allOfEm) {
bool value=false;
if (!activeCommands) {say((char *)"There is no active command."); goto done;}
say((char *)"Command execution temporarily disabled.");
done: return value;
}
//--------------------------------
void mdCommander::flushCommand(int which,bool allOfEm){
int i,j;
if (!allOfEm) {
if (argsNow[which]) {
for (i=0;i<argsNow[which];i++)
free(commandArgs[which][i]);
}
argsNow[which] = 0;
deleted[which] = true;
activeCommands--;
} else for (i=0;i<cmdsNow;i++) {
if (!deleted[i]) {
if (argsNow[i]) {
for (j=0;j<argsNow[i];j++)
free(commandArgs[i][j]);
}
}
cmdNow = 0;
cmdsNow = 0;
activeCommands = 0;
memset(commandArgs,0,sizeof(commandArgs));
memset(argsNow,0,sizeof(argsNow));
}
};
void mdCommander::sendCommand(int which){
say((char *)"Command processing disabled here during OTE Basic Testing");
};
void mdCommander::showCommand(bool allOfEm){
int activethCommand=0,i,nthItem;
const char *befehlJetzt = cmdNames[commandsNow[cmdNow]];
doHeader();
if (!activeCommands) {say((char *)"There is no active command."); goto done;}
if (!allOfEm) {
sprintf(wwork,"EPP directive: %s",befehlJetzt);
mvprintw(5,2,wwork);
for (nthItem=0;nthItem < argsNow[cmdNow];nthItem++) {
mvprintw(7+nthItem,2,(char *)commandArgs[cmdNow][nthItem]);
}
} else {
mvprintw(5,2,"These commands are pending/active: ");
for (i=0, nthItem=0; nthItem < cmdsNow;nthItem++ ) {
if (!deleted[0]) {
sprintf(wwork,"%d %s %s",i+1,cmdNames[commandsNow[nthItem]],commandArgs[nthItem][0]);
mvprintw(7+(i++),2,wwork);
}
} }
return rc; }
done: return;
};
//--------------------------------
// EPP Queries and Commands
//-------------------------------
bool mdCommander::editingCommand(bool run){
const char *befehlJetzt = cmdNames[commandsNow[cmdNow]];
char *sp;
int editLine;
bool editing=true;
doHeader();
mvprintw(3,(col-strlen(befehlJetzt))/2,befehlJetzt);
if (!run) {
if (!argsNow[cmdNow]) {
say((char *)"Enter strings for command or just enter to end data entry");
prompt(true);
digestibleLines();
} else {
while(editing) {
say((char *)"<n> of arg to replace, A to add, -<n> to erase, just enter to finish");
prompt(true);
mvgetstr(row-1,2,sp);
if (!strlen(sp)) editing = false;
else {
if (*sp == 'A' || *sp == 'a') {
if (strlen(sp)) {
sp = commandArgs[cmdNow][argsNow[cmdNow]++] = (char *) malloc(256);
mvgetstr(row-1,2,sp);
}
continue;
}
editLine = atoi(sp);
if (editLine>0) {
mvgetstr(row-1,2,sp);
if (strlen(sp)) {
free (commandArgs[cmdNow][editLine]);
commandArgs[cmdNow][editLine] = (char *) malloc(strlen(sp)+1);
strcpy(commandArgs[cmdNow][editLine],sp);
}
}
else { editLine = editLine * -1 ;
memset(commandArgs[cmdNow][editLine],0,strlen(commandArgs[cmdNow][editLine]));
}
} // editing body
} // editing loop
} // new / existing
} // run / execute
else {
say((char *)"Press 'Y' to confirm");
}
};
void mdCommander::check(bool run) {
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 0;
if (!editingCommand(run)) {
}
} }
void mdCommander::check(){}; void mdCommander::create(bool run){
void mdCommander::create(){};
void mdCommander::flushCommand(){}; if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 4;
void mdCommander::info(){}; if (!editingCommand(run)) {
void mdCommander::renew(){};
void mdCommander::sendCommand(){}; }
void mdCommander::showCommand(){}; };
void mdCommander::trash(){}; void mdCommander::info(bool run){
void mdCommander::transfer(){};
void mdCommander::transferCheck(){}; if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 1;
void mdCommander::update(){}; if (!editingCommand(run)) {
}
};
void mdCommander::renew(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 5;
if (!editingCommand(run)) {
}
};
void mdCommander::queryTransfer(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 3;
if (!editingCommand(run)) {
}
};
void mdCommander::trash(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 7;
if (!editingCommand(run)) {
}
};
void mdCommander::transfer(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 8;
if (!editingCommand(run)) {
}
};
void mdCommander::poll(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 2;
if (!editingCommand(run)) {
}
};
void mdCommander::update(bool run){
if (!commandsNow[cmdNow]) commandsNow[cmdNow] = 6;
if (!editingCommand(run)) {
}
};

View File

@ -7,21 +7,21 @@ typedef struct _DE {
char sig; char sig;
const char * name; } newDEs; const char * name; } newDEs;
// Test bogus name last. // Lots to do here, need to complete migration to the EPP context which is
const char *predefinedObservables[5] = { "spintime", "omega-squared", "pressure", "temperature", "adsfasdf" }; // enoromously better better bounded than the original. In the end will have
// a test suite here that can be generated from the XMLRPC registry.
const char *standardEPPDirectives[8] =
{ "check", "infod", "transfer", "create", "renew, "update", "delete", "transfer" };
const char *randomValues[4] = { "333.333", "111.111", "34.43", "7777.777" }; const char *randomValues[4] = { "333.333", "111.111", "34.43", "7777.777" };
const char *requiredCmdSubSys[2] = { "SYSTEM", "STATUS" }; const char *requiredCmdSubSys[2] = { "SYSTEM", "STATUS" };
string debug1,debug2,success("OK"); string debug1,debug2,success("OK");
newDEs otherP1Elements[6] = { {'d', "absorbance"}, {'d', "acceleration"},
{'b', "_powered" }, {'t', "_uptime"},
{'i', "_vacuum" }, {'d', "_rotorspeed"}
};
void mdCoreAPITestSuite::bucket01(char const *title) { void mdCoreAPITestSuite::bucket01(char const *title) {
phase = string("core API test bucket"); phase = string("core API test bucket");
int nTests=(sizeof(predefinedObservables)/sizeof(char *)),variation; int nTests=(sizeof(standardEPPDirectives)/sizeof(char *)),variation;
XmlRpcValue focus,gotten[nTests]; XmlRpcValue focus,gotten[nTests];
cout << "\nTest Bucket: " << title << endl; cout << "\nTest Bucket: " << title << endl;
@ -29,11 +29,11 @@ void mdCoreAPITestSuite::bucket01(char const *title) {
for ( variation=0; variation < nTests; variation++) { for ( variation=0; variation < nTests; variation++) {
cout << ".Get '" << predefinedObservables[variation] << "'\n"; cout << ".Get '" << standardEPPDirectives[variation] << "'\n";
gotten[variation] = testState->get(mdServerHandle,predefinedObservables[variation]).getStruct(); gotten[variation] = testState->get(mdServerHandle,standardEPPDirectives[variation]).getStruct();
focus = gotten[variation].structGetValue("dataname"); focus = gotten[variation].structGetValue("dataname");
if (variation < (nTests - 1)) if (variation < (nTests - 1))
TEST(focus.getString() == string(predefinedObservables[variation])); TEST(focus.getString() == string(standardEPPDirectives[variation]));
else TEST(focus.getString() == string("not found")); else TEST(focus.getString() == string("not found"));
} }
@ -41,7 +41,7 @@ void mdCoreAPITestSuite::bucket01(char const *title) {
// Set to some value. // Set to some value.
for (variation=0;variation < (nTests - 1);variation++) { for (variation=0;variation < (nTests - 1);variation++) {
cout << ".Set '" << predefinedObservables[variation] << "'\n"; cout << ".Set '" << standardEPPDirectives[variation] << "'\n";
gotten[variation].structSetValue("sValue",XmlRpcValue::makeString(randomValues[variation])); gotten[variation].structSetValue("sValue",XmlRpcValue::makeString(randomValues[variation]));
TEST(string("OK") == testState->set(mdServerHandle,gotten[variation])); TEST(string("OK") == testState->set(mdServerHandle,gotten[variation]));
} }
@ -50,8 +50,8 @@ void mdCoreAPITestSuite::bucket01(char const *title) {
for ( variation=0; variation < (nTests -1); variation++) { for ( variation=0; variation < (nTests -1); variation++) {
cout << ".Cmp '" << predefinedObservables[variation] << "'\n"; cout << ".Cmp '" << standardEPPDirectives[variation] << "'\n";
gotten[variation] = testState->get(mdServerHandle,predefinedObservables[variation]).getStruct(); gotten[variation] = testState->get(mdServerHandle,standardEPPDirectives[variation]).getStruct();
focus = gotten[variation].structGetValue("sValue"); focus = gotten[variation].structGetValue("sValue");
debug1 = focus.getString(); debug1 = focus.getString();
debug2 = string(randomValues[variation]); debug2 = string(randomValues[variation]);

View File

@ -37,7 +37,7 @@
#define MD_NAME CLIEVER_APP " " MD_COMPONENT #define MD_NAME CLIEVER_APP " " MD_COMPONENT
#define MD_VERSION " 1.0 " // Version #define MD_VERSION " 1.0 " // Version
#define MD_DEFAULT_IP "188.138.106.163" #define MD_DEFAULT_IP "188.138.106.163"
#include "mdconstants.h"
#include "mdcommon.h" #include "mdcommon.h"
#include "cdEvents.h" #include "cdEvents.h"
@ -50,7 +50,7 @@
#define CD_EPOCH date() #define CD_EPOCH date()
#define CD_GLOBAL_SIZE 4096 #define CD_GLOBAL_SIZE 4096
#define CD_LOCK_FILE "ausreg-cd.lock" #define CD_LOCK_FILE "ausreg-cd.lock"
#define CD_NAME CLIEVER_APP " ausreg-cd" #define CD_NAME CLIEVER_APP " drde-cd"
#define CD_VERSION "1.0" #define CD_VERSION "1.0"
#define CD_REFRESH MD_HEARTBEAT // default milliseconds between telemetry frame updates #define CD_REFRESH MD_HEARTBEAT // default milliseconds between telemetry frame updates
#define CD_MAX_DEVICE 4 // including ourselves #define CD_MAX_DEVICE 4 // including ourselves

View File

@ -1,36 +1,56 @@
#ifndef MD_CHARGUI #ifndef MD_CHARGUI
#define MD_CHARGUI #define MD_CHARGUI
#define MAX_CMDS 20
class mdCommander { class mdCommander {
bool acceptingInput; bool acceptingInput,deleted[MAX_CMDS];
bool EPPmode; // RFC 8 bool EPPmode; // RFC 9
int mdStdDevIdx; int activeCommands, argsNow[MAX_CMDS], cmdNow, cmdsNow, mdStdDevIdx;
std::string currentDevice; std::string currentDevice;
int row,col;
int commandsNow[MAX_CMDS]; // type index into cmdNames
char *commandArgs[MAX_CMDS][MAX_CMD_ARGS];
char wwork[1024];
public: public:
mdCommander() {mdStdDevIdx=0;} mdCommander() {mdStdDevIdx=0; cmdsNow=0; cmdNow = 0;}
~mdCommander() {} ~mdCommander() {}
void say(char *what) ;
void acMainMenu(); void acMainMenu();
void check(); void check(bool run);
void create(); void create(bool run);
void doHeader();
void driver(); void driver();
void digestibleLines();
void eppMainMenu(); void eppMainMenu();
void flushCommand(); void flushCommand(int which,bool allowsZero);
void greet(); void greet();
void help(); void help();
void info(); void info(bool run);
void renew(); bool isValidCmd(int which,bool isX)
void sendCommand(); { if (which == 0 && !isX) return false;
void showCommand(); if (which > cmdsNow) return false;
void trash(); if (!isX && which < 1) return false;
void transfer(); if (which && deleted[which-1]) return false;
void transferCheck(); return true;
void update(); }
void poll(bool run);
void prompt(bool forStrings);
void queryTransfer(bool run);
void renew(bool run);
void sendCommand(int which);
void showCommand(bool all);
void trash(bool run);
void transfer(bool run);
void update(bool run);
bool epp(char *command); bool editingCommand(bool run);
bool runCommand(bool all);
}; };

View File

@ -78,7 +78,9 @@ using boost::asio::ip::udp;
#define CURRENT_DEBUG NORMAL_DEBUG #define CURRENT_DEBUG NORMAL_DEBUG
#endif #endif
#define NOT_OK -1 #define NOT_OK -1
#ifndef OK
#define OK 0 #define OK 0
#endif
#define RUNNING_DIR "/tmp" #define RUNNING_DIR "/tmp"
#define theMachine thisConfig->machine[thisConfig->thisMachineContext] #define theMachine thisConfig->machine[thisConfig->thisMachineContext]

View File

@ -4,37 +4,21 @@
*/ */
#define MAX_CMD_ARGS 20
#define N_EPP_VERBS 9
#define INSTRUMENT 1 #define INSTRUMENT 1
#define MAX_DEVICE 5 // Machine, Up to 3 optical instruments and the US i/f (Phase II and later)
#define MD_DATAGRAM_RESPONSE_SIZE 16 // First three bytes after header are ACK or NAK #define MD_DATAGRAM_RESPONSE_SIZE 16 // First three bytes after header are ACK or NAK
#define MD_DEFAULT_RULE 0 #define MD_DEFAULT_RULE 0
// Our rendering of SCPI-99 // Our rendering of SCPI-99
// Custom behaviors greater than this // Custom behaviors greater than this
#define MD_DEFAULT_DEVICE_PROTOCOL 1
#define MD_DEFAULT_IP "208.109.106.127"
#define MD_EPOCH date() #define MD_EPOCH date()
#define MD_HEARTBEAT 1 // Network peer heartbeat in seconds. #define MD_HEARTBEAT 1 // Network peer heartbeat in seconds.
#define MD_HEARTBEAT_SIZE 8 // Network peer heartbeat in seconds. #define MD_HEARTBEAT_SIZE 8 // Network peer heartbeat in seconds.
#define MD_MAX_DATAGRAM (63*1024) // 1K short of the IPV4 max
#define MD_NAME "AusReg Cliever"
#define MD_VERSION " 1.0 " #define MD_VERSION " 1.0 "
#define MD_REFRESH 10 // default milliseconds between telemetry frame updates #define MD_REFRESH 10 // default milliseconds between telemetry frame updates
#define MD_TYPE "EPP CLIENT-SERVER" // Change per your MD derivation
#define MACHINE 0 // Null machine type impliss MD_TYPE
#define OK 0
#define OTHERCLIENT 2 #define OTHERCLIENT 2
enum md_units {
centimeters,
millimeters,
microns,
nanometers,
angstroms,
volts,
cubiccentemeter
};
enum md_datagrams { enum md_datagrams {

2
README
View File

@ -24,7 +24,7 @@
boost boost
libxmlrpc-c and c++ libxmlrpc-c and c++
xmlrpc-api-utils xmlrpc-api-utils
swig SWIG
msgpack msgpack
The EPP toolkit also has dependencis. The EPP toolkit also has dependencis.