Commit 12161cc9 authored by Claes Sjofors's avatar Claes Sjofors

Ssab IO ao, write every scan

parent 68dcd0c1
...@@ -70,7 +70,6 @@ typedef struct { ...@@ -70,7 +70,6 @@ typedef struct {
int Qbus_fp; int Qbus_fp;
pwr_tFloat32 OldValue[IO_MAXCHAN]; pwr_tFloat32 OldValue[IO_MAXCHAN];
pwr_tBoolean OldTestOn[IO_MAXCHAN]; pwr_tBoolean OldTestOn[IO_MAXCHAN];
int WriteFirst;
unsigned int ErrReset; unsigned int ErrReset;
unsigned int ErrScanCnt; unsigned int ErrScanCnt;
} io_sLocal; } io_sLocal;
...@@ -136,8 +135,6 @@ static pwr_tStatus IoCardInit( ...@@ -136,8 +135,6 @@ static pwr_tStatus IoCardInit(
errh_Info("Init of ao card '%s'", cp->Name); errh_Info("Init of ao card '%s'", cp->Name);
/* Write the first 50 loops */
local->WriteFirst = 50;
cp->Local = local; cp->Local = local;
/* Caluclate polycoeff */ /* Caluclate polycoeff */
...@@ -205,70 +202,65 @@ static pwr_tStatus IoCardWrite( ...@@ -205,70 +202,65 @@ static pwr_tStatus IoCardWrite(
cop = (pwr_sClass_ChanAo*)chanp->cop; cop = (pwr_sClass_ChanAo*)chanp->cop;
sop = (pwr_sClass_Ao*)chanp->sop; sop = (pwr_sClass_Ao*)chanp->sop;
if (!feqf(*(pwr_tFloat32*)chanp->vbp, local->OldValue[i]) if (fixout)
|| local->WriteFirst > 0 || cop->CalculateNewCoef || fixout value = cop->FixedOutValue;
|| cop->TestOn || local->OldTestOn[i] != cop->TestOn) { else if (cop->TestOn)
if (fixout) value = cop->TestValue;
value = cop->FixedOutValue; else
else if (cop->TestOn) value = *(pwr_tFloat32*)chanp->vbp;
value = cop->TestValue;
else if (cop->CalculateNewCoef)
value = *(pwr_tFloat32*)chanp->vbp; AoRangeToCoef(chanp);
if (cop->CalculateNewCoef) /* Convert to rawvalue */
AoRangeToCoef(chanp); if (value > cop->ActValRangeHigh)
value = cop->ActValRangeHigh;
/* Convert to rawvalue */ else if (value < cop->ActValRangeLow)
if (value > cop->ActValRangeHigh) value = cop->ActValRangeLow;
value = cop->ActValRangeHigh;
else if (value < cop->ActValRangeLow) rawvalue = cop->OutPolyCoef1 * value + cop->OutPolyCoef0;
value = cop->ActValRangeLow; if (rawvalue > 0)
sop->RawValue = rawvalue + 0.5;
rawvalue = cop->OutPolyCoef1 * value + cop->OutPolyCoef0; else
if (rawvalue > 0) sop->RawValue = rawvalue - 0.5;
sop->RawValue = rawvalue + 0.5; data = sop->RawValue;
else
sop->RawValue = rawvalue - 0.5; if (r_local->Qbus_fp != 0 && r_local->s == 0) {
data = sop->RawValue; wb.Data = data;
wb.Address = local->Address + 2 * i;
if (r_local->Qbus_fp != 0 && r_local->s == 0) { sts = write(local->Qbus_fp, &wb, sizeof(wb));
wb.Data = data; } else {
wb.Address = local->Address + 2 * i; /* Ethernet I/O, Request a write to current address */
sts = write(local->Qbus_fp, &wb, sizeof(wb)); bfbeth_set_write_req(
} else { r_local, (pwr_tUInt16)(local->Address + 2 * i), data);
/* Ethernet I/O, Request a write to current address */ sts = 1;
bfbeth_set_write_req( }
r_local, (pwr_tUInt16)(local->Address + 2 * i), data);
sts = 1; if (sts == -1) {
/* Increase error count and check error limits */
op->ErrorCount++;
if (op->ErrorCount == op->ErrorSoftLimit) {
errh_Error("IO Error soft limit reached on card '%s'", cp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(cp->Objid);
} }
if (op->ErrorCount >= op->ErrorHardLimit) {
errh_Error(
"IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(cp->Objid);
return IO__ERRDEVICE;
}
chanp++;
continue;
} else
local->OldValue[i] = value;
if (sts == -1) {
/* Increase error count and check error limits */
op->ErrorCount++;
if (op->ErrorCount == op->ErrorSoftLimit) {
errh_Error("IO Error soft limit reached on card '%s'", cp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(cp->Objid);
}
if (op->ErrorCount >= op->ErrorHardLimit) {
errh_Error(
"IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(cp->Objid);
return IO__ERRDEVICE;
}
chanp++;
continue;
} else
local->OldValue[i] = value;
}
local->OldTestOn[i] = cop->TestOn; local->OldTestOn[i] = cop->TestOn;
chanp++; chanp++;
} }
if (local->WriteFirst)
local->WriteFirst--;
/* Fix for qbus errors */ /* Fix for qbus errors */
local->ErrScanCnt++; local->ErrScanCnt++;
......
...@@ -69,7 +69,6 @@ typedef struct { ...@@ -69,7 +69,6 @@ typedef struct {
unsigned int bfb_item; unsigned int bfb_item;
pwr_tFloat32 OldValue[IO_MAXCHAN]; pwr_tFloat32 OldValue[IO_MAXCHAN];
pwr_tBoolean OldTestOn[IO_MAXCHAN]; pwr_tBoolean OldTestOn[IO_MAXCHAN];
int WriteFirst;
unsigned int ErrReset; unsigned int ErrReset;
unsigned int ErrScanCnt; unsigned int ErrScanCnt;
int FirstScan; int FirstScan;
...@@ -139,8 +138,6 @@ static pwr_tStatus IoCardInit( ...@@ -139,8 +138,6 @@ static pwr_tStatus IoCardInit(
errh_Info("Init of ao card '%s'", cp->Name); errh_Info("Init of ao card '%s'", cp->Name);
/* Write the first 50 loops */
local->WriteFirst = 50;
cp->Local = local; cp->Local = local;
/* Caluclate polycoeff */ /* Caluclate polycoeff */
...@@ -254,79 +251,74 @@ static pwr_tStatus IoCardWrite( ...@@ -254,79 +251,74 @@ static pwr_tStatus IoCardWrite(
} }
/* Convert and write */ /* Convert and write */
if (!feqf(*(pwr_tFloat32*)chanp->vbp, local->OldValue[i]) if (fixout)
|| local->WriteFirst > 0 || cop->CalculateNewCoef || fixout value = cop->FixedOutValue;
|| cop->TestOn || local->OldTestOn[i] != cop->TestOn) { else if (cop->TestOn)
if (fixout) value = cop->TestValue;
value = cop->FixedOutValue; else
else if (cop->TestOn) value = *(pwr_tFloat32*)chanp->vbp;
value = cop->TestValue;
else if (cop->CalculateNewCoef)
value = *(pwr_tFloat32*)chanp->vbp; AoRangeToCoef(chanp);
if (cop->CalculateNewCoef) /* Convert to rawvalue */
AoRangeToCoef(chanp); if (value > cop->ActValRangeHigh)
value = cop->ActValRangeHigh;
/* Convert to rawvalue */ else if (value < cop->ActValRangeLow)
if (value > cop->ActValRangeHigh) value = cop->ActValRangeLow;
value = cop->ActValRangeHigh;
else if (value < cop->ActValRangeLow) rawvalue = cop->OutPolyCoef1 * value + cop->OutPolyCoef0;
value = cop->ActValRangeLow; if (rawvalue > 0)
sop->RawValue = rawvalue + 0.5;
rawvalue = cop->OutPolyCoef1 * value + cop->OutPolyCoef0; else
if (rawvalue > 0) sop->RawValue = rawvalue - 0.5;
sop->RawValue = rawvalue + 0.5; data = sop->RawValue;
else
sop->RawValue = rawvalue - 0.5; if (!remote) {
data = sop->RawValue; wb.Data = data;
wb.Address = local->Address + 2 * i;
if (!remote) { sts = write(local->Qbus_fp, &wb, sizeof(wb));
wb.Data = data; } else {
wb.Address = local->Address + 2 * i; /* Ethernet I/O, Request a write to current address */
sts = write(local->Qbus_fp, &wb, sizeof(wb)); bfbeth_set_write_req(
} else { r_local, (pwr_tUInt16)(local->Address + 2 * i), data);
/* Ethernet I/O, Request a write to current address */ local->CheckWrite[i] = 1;
bfbeth_set_write_req(
r_local, (pwr_tUInt16)(local->Address + 2 * i), data); if (sts == 1) {
local->CheckWrite[i] = 1; op->ErrorCount = 0;
local->OldValue[i] = value;
if (sts == 1) { local->OldTestOn[i] = cop->TestOn;
op->ErrorCount = 0;
local->OldValue[i] = value;
local->OldTestOn[i] = cop->TestOn;
}
chanp++;
continue;
} }
chanp++;
continue;
}
/* Error handling for local rack */ /* Error handling for local rack */
if (sts == -1) { if (sts == -1) {
/* Increase error count and check error limits */ /* Increase error count and check error limits */
op->ErrorCount++; op->ErrorCount++;
if (op->ErrorCount == op->ErrorSoftLimit) {
errh_Error("IO Error soft limit reached on card '%s'", cp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(cp->Objid);
}
if (op->ErrorCount >= op->ErrorHardLimit) {
errh_Error(
"IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(cp->Objid);
return IO__ERRDEVICE;
}
chanp++;
continue;
} else
local->OldValue[i] = value;
if (op->ErrorCount == op->ErrorSoftLimit) {
errh_Error("IO Error soft limit reached on card '%s'", cp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(cp->Objid);
}
if (op->ErrorCount >= op->ErrorHardLimit) {
errh_Error(
"IO Error hard limit reached on card '%s', IO stopped", cp->Name);
ctx->Node->EmergBreakTrue = 1;
ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(cp->Objid);
return IO__ERRDEVICE;
}
chanp++;
continue;
} else
local->OldValue[i] = value;
}
local->OldTestOn[i] = cop->TestOn; local->OldTestOn[i] = cop->TestOn;
chanp++; chanp++;
} }
if (local->WriteFirst)
local->WriteFirst--;
if (local->FirstScan) if (local->FirstScan)
local->FirstScan = 0; local->FirstScan = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment