Datasheet

io_sCard *cp)
{
io_sLocal *local = cp->Local;
pwr_sClass_MotionControl_USBIO *op = (pwr_sClass_MotionControl_USBIO *)cp->op;
int value = 0;
int i;
unsigned int m;
pwr_tUInt32 error_count = op->Super.ErrorCount;
// Read Di on channel 4 - 8
op->Status = USBIO_ReadDI( &local->USB_Handle, 1, &value);
if ( op->Status)
op->Super.ErrorCount++;
else {
// Set Di value in area object
m = 1 << 4;
for ( i = 4; i < 8; i++) {
*(pwr_tBoolean *)cp->chanlist[i].vbp = ((value & m) != 0);
m = m << 1;
}
}
// Read Ai on channel 8 - 16
for ( i = 0; i < 8; i++) {
io_sChannel *chanp = &cp->chanlist[i + 8];
pwr_sClass_ChanAi *cop = (pwr_sClass_ChanAi *)chanp->cop;
pwr_sClass_Ai *sop = (pwr_sClass_Ai *)chanp->sop;
if ( cop->CalculateNewCoef)
// Request to calculate new coefficients
io_AiRangeToCoef( chanp);
op->Status = USBIO_ReadADVal( &local->USB_Handle, i + 1, &ivalue);
if ( op->Status)
op->Super.ErrorCount++;
else {
io_ConvertAi( cop, ivalue, &actvalue);
// Filter the Ai value
if ( sop->FilterType == 1 &&
sop->FilterAttribute[0] > 0 &&
sop->FilterAttribute[0] > ctx->ScanTime) {
actvalue = *(pwr_tFloat32 *)chanp->vbp +
ctx->ScanTime / sop->FilterAttribute[0] *
(actvalue - *(pwr_tFloat32 *)chanp->vbp);
}
// Set value in area object
*(pwr_tFloat32 *)chanp->vbp = actvalue;
sop->SigValue = cop->SigValPolyCoef1 * ivalue + cop->SigValPolyCoef0;
sop->RawValue = ivalue;
}
}
// Check Error Soft and Hard Limit
// Write warning message if soft limit is reached
if ( op->Super.ErrorCount >= op->Super.ErrorSoftLimit &&
error_count < op->Super.ErrorSoftLimit)
errh_Warning( "IO Card ErrorSoftLimit reached, '%s'", cp->Name);
// Stop I/O if hard limit is reached