39 printf(
"Opening Fake Motor Device Server ...\n");
41 string local=config.check(
"local",Value(
"/fakeyServer")).asString();
42 int Ts=config.check(
"Ts",Value(10)).asInt32();
52 lim(0,0)=-180.0; lim(0,1)=180.0;
53 lim(1,0)=-90.0; lim(1,1)=90.0;
54 lim(2,0)=-45.0; lim(2,1)=45.0;
57 for (
int i=0; i<lim.rows(); i++)
58 q0.push_back((lim(i,0)+lim(i,1))/2.0);
66 setPeriod((
double)Ts/1000.0);
71 printf(
"Fake Motor Device Server successfully open\n");
126 cmd.read(connection);
130 int codeIF=
cmd.get(0).asVocab32();
131 int codeMethod=
cmd.get(1).asVocab32();
133 if (codeIF==Vocab32::encode(
"lim"))
135 if (codeMethod==Vocab32::encode(
"get"))
137 int axis=
cmd.get(2).asInt32();
141 reply.addVocab32(
"ack");
142 reply.addFloat64(min);
143 reply.addFloat64(max);
147 else if (codeIF==Vocab32::encode(
"enc"))
149 if (codeMethod==Vocab32::encode(
"axes"))
154 reply.addVocab32(
"ack");
159 else if (codeIF==Vocab32::encode(
"vel"))
161 if (codeMethod==Vocab32::encode(
"move"))
163 int axis=
cmd.get(2).asInt32();
164 double sp=
cmd.get(3).asFloat64();
166 reply.addVocab32(
"ack");
168 else if (codeMethod==Vocab32::encode(
"acc"))
170 int axis=
cmd.get(2).asInt32();
171 double acc=
cmd.get(3).asFloat64();
173 reply.addVocab32(
"ack");
175 else if (codeMethod==Vocab32::encode(
"stop"))
177 int axis=
cmd.get(2).asInt32();
179 reply.addVocab32(
"ack");
184 reply.addVocab32(
"nack");
188 if (ConnectionWriter *returnToSender=connection.getWriter())
189 reply.write(*returnToSender);