diff --git a/site_ansto/motor_dmc2280.c b/site_ansto/motor_dmc2280.c index 42a402ba..10ef42bb 100644 --- a/site_ansto/motor_dmc2280.c +++ b/site_ansto/motor_dmc2280.c @@ -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;