Initial commit
[remote/remote-mci.git] / protocols / motecontrol / MsgConfirm.cc
blob74c18d1eacf40c46949f685b58fc90103d2ea4a4
1 #include "MsgConfirm.h"
2 namespace remote { namespace protocols { namespace motecontrol {
4 MsgConfirm::MsgConfirm(uint8_t command, result_t result, status_t status )
5 : command(command), result(result), status(status)
9 MsgConfirm::MsgConfirm(uint8_t*& buffer, uint32_t& buflen)
11 buffer = this->read(buffer,buflen);
14 void MsgConfirm::operator = (const MsgConfirm& o)
16 command = o.command;
17 result = o.result;
18 status = o.status;
21 uint32_t MsgConfirm::getLength()
23 return sizeof(command)+sizeof(result)+sizeof(status);
26 uint8_t* MsgConfirm::write(uint8_t* buffer, uint32_t& buflen)
28 buffer = writevalue(command,buffer,buflen);
29 buffer = writevalue(result,buffer,buflen);
30 buffer = writevalue(status,buffer,buflen);
31 return buffer;
34 uint8_t* MsgConfirm::read(uint8_t* buffer, uint32_t& buflen)
36 buffer = readvalue(command,buffer,buflen);
37 buffer = readvalue(result,buffer,buflen);
38 buffer = readvalue(status,buffer,buflen);
39 return buffer;
42 void MsgConfirm::print(_IO_FILE* s)
44 fprintf(s,"MESSAGE MsgConfirm\n");
45 fprintf(s,"command: ");
46 switch(command)
48 case MOTECOMMAND_PROGRAM:
49 fprintf(s,"MOTECOMMAND_PROGRAM\n");
50 break;
51 case MOTECOMMAND_STATUS:
52 fprintf(s,"MOTECOMMAND_STATUS\n");
53 break;
54 case MOTECOMMAND_RESET:
55 fprintf(s,"MOTECOMMAND_RESET\n");
56 break;
57 case MOTECOMMAND_STOP:
58 fprintf(s,"MOTECOMMAND_STOP\n");
59 break;
60 case MOTECOMMAND_START:
61 fprintf(s,"MOTECOMMAND_START\n");
62 break;
63 default:
64 fprintf(s,"Invalid command!\n");
65 break;
67 fprintf(s,"result: ");
68 switch(result)
70 case NOT_SUPPORTED:
71 fprintf(s,"NOT_SUPPORTED\n");
72 break;
73 case SUCCESS:
74 fprintf(s,"SUCCESS\n");
75 break;
76 case FAILURE:
77 fprintf(s,"FAILURE\n");
78 break;
79 default:
80 fprintf(s,"Invalid result!\n");
81 break;
83 fprintf(s,"status: ");
84 switch(status)
86 case MOTE_STATUS_UNKNOWN:
87 fprintf(s,"MOTE_STATUS_UNKNOWN\n");
88 break;
89 case MOTE_UNAVAILABLE:
90 fprintf(s,"MOTE_UNAVAILABLE\n");
91 break;
92 case MOTE_STOPPED:
93 fprintf(s,"MOTE_STOPPED\n");
94 break;
95 case MOTE_RUNNING:
96 fprintf(s,"MOTE_RUNNING\n");
97 break;
98 case MOTE_PROGRAMMING:
99 fprintf(s,"MOTE_PROGRAMMING\n");
100 break;
101 default:
102 fprintf(s,"Invalid status!\n");
103 break;
107 uint8_t MsgConfirm::getCommand()
109 return command;
112 result_t MsgConfirm::getResult()
114 return result;
117 status_t MsgConfirm::getStatus()
119 return status;