Provide a way to configure a simulated motor if it identifies itself as being simulated
r3638 | dcl | 2012-07-11 15:11:41 +1000 (Wed, 11 Jul 2012) | 1 line
This commit is contained in:
@@ -108,6 +108,7 @@ struct EvtEvent_s {
|
||||
#define VAR_SWI (1<<7)
|
||||
#define VAR_HOM (1<<8)
|
||||
#define VAR_STP (1<<9)
|
||||
#define VAR_SIM (1<<10)
|
||||
|
||||
static pAsyncProtocol DMC2280_Protocol = NULL;
|
||||
|
||||
@@ -1237,6 +1238,20 @@ static int cmdVars(pDMC2280Driv self) {
|
||||
return DMC_SendReq(self, cmd);
|
||||
}
|
||||
|
||||
static void cmdConfig(pDMC2280Driv self) {
|
||||
char cmd[CMDLEN];
|
||||
snprintf(cmd, CMDLEN, "MG \"CONFIG%c=SPX=%g,CPX=%g,RL=%g,FL=%g,UH=%g,%s=%d\"",
|
||||
self->axisLabel,
|
||||
self->stepsPerX,
|
||||
self->cntsPerX,
|
||||
self->fLower,
|
||||
self->fUpper,
|
||||
self->fHome,
|
||||
self->abs_encoder ? "EH" : "MH",
|
||||
self->abs_encoder ? self->absEncHome : self->motorHome);
|
||||
DMC_Send(self, cmd);
|
||||
}
|
||||
|
||||
static int cmdOn(pDMC2280Driv self) {
|
||||
char cmd[CMDLEN];
|
||||
if (self->protocol == 1) {
|
||||
@@ -1439,6 +1454,8 @@ static int rspStatus(pDMC2280Driv self, const char* text) {
|
||||
|
||||
static int rspVars(pDMC2280Driv self, const char* text) {
|
||||
self->variables = 0;
|
||||
if (has_var(self, text, "SIMULATE"))
|
||||
self->variables |= VAR_SIM;
|
||||
if (has_var(self, text, "HOMERUN"))
|
||||
self->variables |= VAR_HOM;
|
||||
if (has_var_x(self, text, "REQ"))
|
||||
@@ -1794,6 +1811,8 @@ static void DMCState_Unknown(pDMC2280Driv self, pEvtEvent event) {
|
||||
}
|
||||
if (self->subState == 1) { /* Vars */
|
||||
rspVars(self, pCmd->inp_buf);
|
||||
if (self->variables & VAR_SIM)
|
||||
cmdConfig(self);
|
||||
cmdStatus(self);
|
||||
self->subState = 2;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user