M.Z.
This commit is contained in:
83
tecs/tecs.c
83
tecs/tecs.c
@ -1115,6 +1115,49 @@ void CalcMaxPower(void) {
|
||||
}
|
||||
}
|
||||
|
||||
int PutFloat(StrBuf *buf, int prec, float f) {
|
||||
char num[32], fmt[32];
|
||||
int l;
|
||||
|
||||
if (f == DATA_UNDEF) {
|
||||
return StrPut(buf, "NaN", StrNONE);
|
||||
} else {
|
||||
sprintf(fmt, "%%.%dg", prec);
|
||||
sprintf(num, fmt, f);
|
||||
return StrPut(buf, num, StrNONE);
|
||||
}
|
||||
}
|
||||
|
||||
int PidSumHdl(int mode, void *base, int fd) {
|
||||
StrBuf buf;
|
||||
|
||||
readTemp=1;
|
||||
StrLink(&buf, pid);
|
||||
StrClear(&buf);
|
||||
ERR_I(PutFloat(&buf, 5, prop));
|
||||
ERR_I(StrPut(&buf, " ", StrNONE));
|
||||
ERR_I(PutFloat(&buf, 5, integ));
|
||||
ERR_I(StrPut(&buf, " ", StrNONE));
|
||||
ERR_I(PutFloat(&buf, 4, deriv));
|
||||
ERR_I(StrPut(&buf, " /", ' '));
|
||||
ERR_I(PutFloat(&buf, 4, prop*sqrt(scalPower/resist)/600));
|
||||
ERR_I(StrPut(&buf, " A/K,", ' '));
|
||||
ERR_I(PutFloat(&buf, 4, 1000.0/integ));
|
||||
ERR_I(StrPut(&buf, " sec,", ' '));
|
||||
ERR_I(PutFloat(&buf, 4, deriv));
|
||||
ERR_I(StrPut(&buf, " sec/scalPower", ' '));
|
||||
if (scalPower>0.5) {
|
||||
ERR_I(PutFloat(&buf, 4, scalPower));
|
||||
ERR_I(StrPut(&buf, " W", StrNONE));
|
||||
} else {
|
||||
ERR_I(PutFloat(&buf, 4, scalPower*1000));
|
||||
ERR_I(StrPut(&buf, " mW", StrNONE));
|
||||
}
|
||||
return 0;
|
||||
OnError:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int SetMaxPower(void) {
|
||||
static float p0, pold;
|
||||
float plim;
|
||||
@ -1142,6 +1185,8 @@ int SetMaxPower(void) {
|
||||
}
|
||||
p0=scalPower;
|
||||
pold=maxPower;
|
||||
PidSumHdl(COC_RD, NULL, 0);
|
||||
logfileOut(LOG_MAIN, "pid: %s\n", pid);
|
||||
return 0;
|
||||
OnError: return -1;
|
||||
}
|
||||
@ -1755,6 +1800,8 @@ int PidHdl(int mode, void *base, int fd) {
|
||||
return COC_DWR;
|
||||
} else if (mode==COC_DWR) {
|
||||
ERR_P(LscCmd(ser,"PID [loop]:[prop],[integ],[deriv]"));
|
||||
PidSumHdl(COC_RD, base, fd);
|
||||
logfileOut(LOG_MAIN, "pid: %s\n", pid);
|
||||
}
|
||||
return 0;
|
||||
OnError: return -1;
|
||||
@ -1860,19 +1907,6 @@ int GraHdl(int mode, void *base, int fd) {
|
||||
OnError: return -1;
|
||||
}
|
||||
|
||||
int PutFloat(StrBuf *buf, int prec, float f) {
|
||||
char num[32], fmt[32];
|
||||
int l;
|
||||
|
||||
if (f == DATA_UNDEF) {
|
||||
return StrPut(buf, "NaN", StrNONE);
|
||||
} else {
|
||||
sprintf(fmt, "%%.%dg", prec);
|
||||
sprintf(num, fmt, f);
|
||||
return StrPut(buf, num, StrNONE);
|
||||
}
|
||||
}
|
||||
|
||||
int ShowSensor(StrBuf *buf, SensorT *s, char *name, char *units, char lim) {
|
||||
|
||||
if (s->present!=1) return 0;
|
||||
@ -2042,29 +2076,6 @@ EndStatus:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int PidSumHdl(int mode, void *base, int fd) {
|
||||
StrBuf buf;
|
||||
|
||||
readTemp=1;
|
||||
StrLink(&buf, pid);
|
||||
StrClear(&buf);
|
||||
ERR_I(PutFloat(&buf, 5, prop));
|
||||
ERR_I(StrPut(&buf, " ", StrNONE));
|
||||
ERR_I(PutFloat(&buf, 5, integ));
|
||||
ERR_I(StrPut(&buf, " ", StrNONE));
|
||||
ERR_I(PutFloat(&buf, 4, deriv));
|
||||
ERR_I(StrPut(&buf, " /", ' '));
|
||||
ERR_I(PutFloat(&buf, 4, prop*sqrt(scalPower/resist)/600));
|
||||
ERR_I(StrPut(&buf, " A/K,", ' '));
|
||||
ERR_I(PutFloat(&buf, 4, 1000.0/integ));
|
||||
ERR_I(StrPut(&buf, " sec,", ' '));
|
||||
ERR_I(PutFloat(&buf, 4, deriv));
|
||||
ERR_I(StrPut(&buf, " sec", StrNONE));
|
||||
return 0;
|
||||
OnError:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int RemoteHdl(int mode, void *base, int fd) {
|
||||
if (mode==COC_WR) {
|
||||
return COC_DWR;
|
||||
|
Reference in New Issue
Block a user