04.11.2011 - adjust for Windows & QNX, multiprotocol, repeater, signals, process, codec, console input
This commit is contained in:
104
main.cpp
104
main.cpp
@@ -28,11 +28,107 @@ public:
|
||||
|
||||
};
|
||||
|
||||
PIConsole c(false);
|
||||
//Prot p;
|
||||
|
||||
struct BitsStruct {
|
||||
uchar b1: 1;
|
||||
uchar b2: 2;
|
||||
uchar b4: 4;
|
||||
};
|
||||
|
||||
int i = 1;
|
||||
BitsStruct bits;
|
||||
|
||||
void keyFunc(char key, void * );
|
||||
|
||||
PIConsole c(false, keyFunc);
|
||||
|
||||
void keyFunc(char key, void * ) {
|
||||
switch (key) {
|
||||
case '-': i--; break;
|
||||
case '+': i++; break;
|
||||
case '[': bits.b1--; break;
|
||||
case ']': bits.b1++; break;
|
||||
case ';': bits.b2--; break;
|
||||
case '\'': bits.b2++; break;
|
||||
case ',': bits.b4--; break;
|
||||
case '.': bits.b4++; break;
|
||||
case 'i': i = c.getInt(1, 2); break;
|
||||
}
|
||||
};
|
||||
|
||||
void signalFunc(PISignals::Signal signal) {
|
||||
if (signal == PISignals::Interrupt) cout << "Ctrl+C pressed" << endl;
|
||||
};
|
||||
|
||||
void timerEvent(void*, int delim) {
|
||||
cout << "tick " << delim << endl;
|
||||
};
|
||||
|
||||
PITimer timer(timerEvent);
|
||||
|
||||
void timerEvent2(void*, int delim) {
|
||||
cout << "tick2 " << delim << endl;
|
||||
};
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
MProt mp;
|
||||
/*PICLI cli(argc, argv);
|
||||
cli.addArgument("debug");
|
||||
cli.addArgument("value", "V", "Val", true);
|
||||
if (cli.hasArgument("debug"))
|
||||
cout << "has debug" << endl;
|
||||
if (cli.hasArgument("value"))
|
||||
cout << "value = " << cli.argumentValue("value") << endl;*/
|
||||
/*
|
||||
timer.start(100);
|
||||
timer.addDelimiter(2, timerEvent2);
|
||||
timer.addDelimiter(5, timerEvent2);
|
||||
FOREVER_WAIT
|
||||
*/
|
||||
/*PISignals::setSlot(signalFunc);
|
||||
PISignals::grabSignals(PISignals::Interrupt);
|
||||
FOREVER_WAIT*/
|
||||
|
||||
/*PIString ip;
|
||||
int port;
|
||||
PIConfig conf("protocols.conf~");
|
||||
ip = conf.getValue("mcp1.receiver.ip");
|
||||
port = conf.getValue("mcp1.receiver.port");
|
||||
cout << ip << ":" << port << endl;*/
|
||||
|
||||
c.addString("PIConsole example");
|
||||
c.addEmptyLine();
|
||||
|
||||
c.addTab("colors", '1');
|
||||
c.addString("Red string", 1, PIConsole::Red);
|
||||
c.addString("Blue on yellow", 1, PIConsole::Blue | PIConsole::BackYellow);
|
||||
c.addEmptyLine();
|
||||
|
||||
c.addTab("columns", '2');
|
||||
c.addString("column 1", 1, PIConsole::BackYellow);
|
||||
c.addString("column 2", 2, PIConsole::BackCyan);
|
||||
c.addString("column 3", 3, PIConsole::BackMagenta);
|
||||
c.addEmptyLine();
|
||||
|
||||
c.addTab("bits", '3');
|
||||
c.addBitVariable("b1", &bits, 0, 1);
|
||||
c.addBitVariable("b2", &bits, 1, 2);
|
||||
c.addBitVariable("b4", &bits, 3, 4);
|
||||
c.addCustomStatus("[] - -/+ b1, ;\' - -/+ b2, ,. - -/+ b4");
|
||||
c.addEmptyLine();
|
||||
|
||||
c.addTab("formats", '4');
|
||||
c.addVariable("our int", &i);
|
||||
c.addVariable("dec", &i);
|
||||
c.addVariable("oct", &i, 1, PIConsole::Oct);
|
||||
c.addVariable("hex", &i, 1, PIConsole::Hex);
|
||||
c.addCustomStatus("-+ - -/+ number");
|
||||
c.addEmptyLine();
|
||||
|
||||
c.setTab(0);
|
||||
c.enableExitCapture();
|
||||
c.start(true);
|
||||
|
||||
/*MProt mp;
|
||||
Prot p;
|
||||
PIRepeater r("protocols.conf", "r", 1024);
|
||||
mp.addProtocol(p);
|
||||
@@ -49,6 +145,6 @@ int main(int argc, char * argv[]) {
|
||||
c.addVariable(r.secondChannelName() + ", send", r.sendCount_ptr());
|
||||
c.enableExitCapture();
|
||||
mp.start();
|
||||
c.start(false);
|
||||
c.start(false);*/
|
||||
c.waitForFinish();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user