Commit df0831a3 authored by Marcus Nordenberg's avatar Marcus Nordenberg

format code

parent ce758cd3
This diff is collapsed.
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
printk(fmt, function, lineno, ##args) printk(fmt, function, lineno, ##args)
#define DBG_PRN(fmt, args...) \ #define DBG_PRN(fmt, args...) \
CIF_PRN((__FUNCTION__), (__LINE__), KERN_INFO __FILE__ "::%s(L%.4d): " fmt, \ CIF_PRN((__FUNCTION__), (__LINE__), KERN_INFO __FILE__ "::%s(L%.4d): " fmt, \
##args) ##args)
#else #else
#define DBG_PRN(fmt, args...) /* not debugging: nothing */ #define DBG_PRN(fmt, args...) /* not debugging: nothing */
#endif #endif
......
This diff is collapsed.
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#endif #endif
#if defined(_MSC_VER) /* Microsoft C */ #if defined(_MSC_VER) /* Microsoft C */
#pragma pack(1) /* Byte Alignment */ #pragma pack(1) /* Byte Alignment */
#endif #endif
/* ======================================================================== */ /* ======================================================================== */
...@@ -171,61 +171,66 @@ ...@@ -171,61 +171,66 @@
/* ------------------------ RCS message definition ------------------------ */ /* ------------------------ RCS message definition ------------------------ */
typedef struct RCS_MESSAGEHEADERtag { typedef struct RCS_MESSAGEHEADERtag
{
unsigned char rx; /* receiver */ unsigned char rx; /* receiver */
unsigned char tx; /* transmitter */ unsigned char tx; /* transmitter */
unsigned char ln; /* lenght */ unsigned char ln; /* lenght */
unsigned char nr; /* number */ unsigned char nr; /* number */
unsigned char a; /* answer */ unsigned char a; /* answer */
unsigned char f; /* fault */ unsigned char f; /* fault */
unsigned char b; /* command */ unsigned char b; /* command */
unsigned char e; /* extension */ unsigned char e; /* extension */
} RCS_MESSAGEHEADER; } RCS_MESSAGEHEADER;
typedef struct RCS_MESSAGEtag { typedef struct RCS_MESSAGEtag
{
unsigned char rx; /* receiver */ unsigned char rx; /* receiver */
unsigned char tx; /* transmitter */ unsigned char tx; /* transmitter */
unsigned char ln; /* lenght */ unsigned char ln; /* lenght */
unsigned char nr; /* number */ unsigned char nr; /* number */
unsigned char a; /* answer */ unsigned char a; /* answer */
unsigned char f; /* fault */ unsigned char f; /* fault */
unsigned char b; /* command */ unsigned char b; /* command */
unsigned char e; /* extension */ unsigned char e; /* extension */
unsigned char d[RCS_SEGMENT_LEN - RCS_MESSAGEHEADER_LEN]; /* data */ unsigned char d[RCS_SEGMENT_LEN - RCS_MESSAGEHEADER_LEN]; /* data */
} RCS_MESSAGE; } RCS_MESSAGE;
/* ----------------- Standard telegram header ----------------------------- */ /* ----------------- Standard telegram header ----------------------------- */
/* Keyword: MESSAGE, TASK_B_10 --------------------------------------------*/ /* Keyword: MESSAGE, TASK_B_10 --------------------------------------------*/
typedef struct RCS_TELEGRAMHEADER_10tag { typedef struct RCS_TELEGRAMHEADER_10tag
{
unsigned char device_adr; /* device address */ unsigned char device_adr; /* device address */
unsigned char data_area; /* data area */ unsigned char data_area; /* data area */
unsigned short data_adr; /* data address */ unsigned short data_adr; /* data address */
unsigned char data_idx; /* data index */ unsigned char data_idx; /* data index */
unsigned char data_cnt; /* data count */ unsigned char data_cnt; /* data count */
unsigned char data_type; /* data type */ unsigned char data_type; /* data type */
unsigned char function; /* function */ unsigned char function; /* function */
} RCS_TELEGRAMHEADER_10; } RCS_TELEGRAMHEADER_10;
typedef struct RCS_MESSAGETELEGRAMHEADER_10_tag { typedef struct RCS_MESSAGETELEGRAMHEADER_10_tag
unsigned char rx; /* receiver */ {
unsigned char tx; /* transmitter */ unsigned char rx; /* receiver */
unsigned char ln; /* lenght */ unsigned char tx; /* transmitter */
unsigned char nr; /* number */ unsigned char ln; /* lenght */
unsigned char a; /* answer */ unsigned char nr; /* number */
unsigned char f; /* fault */ unsigned char a; /* answer */
unsigned char b; /* command */ unsigned char f; /* fault */
unsigned char e; /* extension */ unsigned char b; /* command */
unsigned char e; /* extension */
unsigned char device_adr; /* device address */ unsigned char device_adr; /* device address */
unsigned char data_area; /* data area */ unsigned char data_area; /* data area */
unsigned short data_adr; /* data address */ unsigned short data_adr; /* data address */
unsigned char data_idx; /* data index */ unsigned char data_idx; /* data index */
unsigned char data_cnt; /* data count */ unsigned char data_cnt; /* data count */
unsigned char data_type; /* data type */ unsigned char data_type; /* data type */
unsigned char function; /* function */ unsigned char function; /* function */
} RCS_MESSAGETELEGRAMHEADER_10; } RCS_MESSAGETELEGRAMHEADER_10;
typedef struct RCS_TELEGRAMHEADERDATA_10tag { typedef struct RCS_TELEGRAMHEADERDATA_10tag
{
unsigned char device_adr; unsigned char device_adr;
unsigned char data_area; unsigned char data_area;
unsigned short data_adr; unsigned short data_adr;
...@@ -237,28 +242,29 @@ typedef struct RCS_TELEGRAMHEADERDATA_10tag { ...@@ -237,28 +242,29 @@ typedef struct RCS_TELEGRAMHEADERDATA_10tag {
d[RCS_SEGMENT_LEN - RCS_MESSAGEHEADER_LEN - RCS_TELEGRAMHEADER_LEN]; d[RCS_SEGMENT_LEN - RCS_MESSAGEHEADER_LEN - RCS_TELEGRAMHEADER_LEN];
} RCS_TELEGRAMHEADERDATA_10; } RCS_TELEGRAMHEADERDATA_10;
typedef struct RCS_MESSAGETELEGRAM_10tag { typedef struct RCS_MESSAGETELEGRAM_10tag
unsigned char rx; /* receiver */ {
unsigned char tx; /* transmitter */ unsigned char rx; /* receiver */
unsigned char ln; /* lenght */ unsigned char tx; /* transmitter */
unsigned char nr; /* number */ unsigned char ln; /* lenght */
unsigned char a; /* answer */ unsigned char nr; /* number */
unsigned char f; /* fault */ unsigned char a; /* answer */
unsigned char b; /* command */ unsigned char f; /* fault */
unsigned char e; /* extension */ unsigned char b; /* command */
unsigned char e; /* extension */
unsigned char device_adr; /* device address */ unsigned char device_adr; /* device address */
unsigned char data_area; /* data area */ unsigned char data_area; /* data area */
unsigned short data_adr; /* data address */ unsigned short data_adr; /* data address */
unsigned char data_idx; /* data index */ unsigned char data_idx; /* data index */
unsigned char data_cnt; /* data count */ unsigned char data_cnt; /* data count */
unsigned char data_type; /* data type */ unsigned char data_type; /* data type */
unsigned char function; /* function */ unsigned char function; /* function */
unsigned char unsigned char
d[RCS_SEGMENT_LEN - RCS_MESSAGEHEADER_LEN - RCS_TELEGRAMHEADER_LEN]; d[RCS_SEGMENT_LEN - RCS_MESSAGEHEADER_LEN - RCS_TELEGRAMHEADER_LEN];
} RCS_MESSAGETELEGRAM_10; } RCS_MESSAGETELEGRAM_10;
#if defined(_MSC_VER) /* Microsoft C */ #if defined(_MSC_VER) /* Microsoft C */
#pragma pack() /* Byte Alignment */ #pragma pack() /* Byte Alignment */
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -91,64 +91,64 @@ extern "C" { ...@@ -91,64 +91,64 @@ extern "C" {
/* Mode definitions */ /* Mode definitions */
/* ------------------ */ /* ------------------ */
#define MODE_NEUSTART 0 /* Command: B_SYSFKT */ #define MODE_NEUSTART 0 /* Command: B_SYSFKT */
#define MODE_KALTSTART 1 /* Command: B_SYSFKT */ #define MODE_KALTSTART 1 /* Command: B_SYSFKT */
#define MODE_WARMSTART 2 /* Command: B_SYSFKT */ #define MODE_WARMSTART 2 /* Command: B_SYSFKT */
#define MODE_ZYKL_STATUS_STOP 3 /* Command: B_SYSFKT */ #define MODE_ZYKL_STATUS_STOP 3 /* Command: B_SYSFKT */
#define MODE_FWVERSION 4 /* Command: B_SYSFKT */ #define MODE_FWVERSION 4 /* Command: B_SYSFKT */
#define MODE_GET_PROJ_WERTE_HW 5 /* Command: B_SYSFKT */ #define MODE_GET_PROJ_WERTE_HW 5 /* Command: B_SYSFKT */
#define MODE_GET_PROJ_WERTE_SW 6 /* Command: B_SYSFKT */ #define MODE_GET_PROJ_WERTE_SW 6 /* Command: B_SYSFKT */
#define MODE_SHOW_DYN_SYSSTAT 7 /* Command: B_SYSFKT */ #define MODE_SHOW_DYN_SYSSTAT 7 /* Command: B_SYSFKT */
#define MODE_SETTIME 9 /* not implemented yet */ #define MODE_SETTIME 9 /* not implemented yet */
#define MODE_SET_DEVICE_DATA 9 /* not implemented yet */ #define MODE_SET_DEVICE_DATA 9 /* not implemented yet */
#define MODE_MODUL_RCS 11 /* Command: B_SYSFKT */ #define MODE_MODUL_RCS 11 /* Command: B_SYSFKT */
#define MODE_MODUL_LIB 12 /* Command: B_SYSFKT */ #define MODE_MODUL_LIB 12 /* Command: B_SYSFKT */
#define MODE_MODUL_MCL 13 /* Command: B_SYSFKT */ #define MODE_MODUL_MCL 13 /* Command: B_SYSFKT */
#define MODE_MODUL_LIB 12 /* Command: B_SYSFKT */ #define MODE_MODUL_LIB 12 /* Command: B_SYSFKT */
#define MODE_MODUL_MCL 13 /* Command: B_SYSFKT */ #define MODE_MODUL_MCL 13 /* Command: B_SYSFKT */
#define MODE_DISTRIBUTOR_DRIVER \ #define MODE_DISTRIBUTOR_DRIVER \
14 /* Command: B_SYSFKT ->function 1 = insert \ 14 /* Command: B_SYSFKT ->function 1 = insert \
*/ */
#define MODE_PRINT_DRIVER 15 /* Command: B_SYSFKT */ #define MODE_PRINT_DRIVER 15 /* Command: B_SYSFKT */
#define MODE_GET_RCS_ERROR 16 /* Command: B_SYSFKT */ #define MODE_GET_RCS_ERROR 16 /* Command: B_SYSFKT */
#define MODE_PRINT_DEVICE 1 /* NO mode, only for MENU.H */ #define MODE_PRINT_DEVICE 1 /* NO mode, only for MENU.H */
#define MODE_PRINT_DEVICE_DRIVER 2 /* NO mode, only for MENU.H */ #define MODE_PRINT_DEVICE_DRIVER 2 /* NO mode, only for MENU.H */
#define MODE_START_STOP_STAT 0 /* Command: B_TASKFKT */ #define MODE_START_STOP_STAT 0 /* Command: B_TASKFKT */
#define MODE_START_STOP 1 /* Command: B_TASKFKT */ #define MODE_START_STOP 1 /* Command: B_TASKFKT */
#define MODE_TASK_VERSION 2 /* Command: B_TASKFKT */ #define MODE_TASK_VERSION 2 /* Command: B_TASKFKT */
#define MODE_ZYKL_STATUS 3 /* Command: B_TASKFKT */ #define MODE_ZYKL_STATUS 3 /* Command: B_TASKFKT */
#define MODE_SHOW_FUELLST 4 /* Command: B_TASKFKT */ #define MODE_SHOW_FUELLST 4 /* Command: B_TASKFKT */
#define MODE_SHOW_TIMER 5 /* Command: B_TASKFKT */ #define MODE_SHOW_TIMER 5 /* Command: B_TASKFKT */
#define MODE_DIAG_MEM_READ_SINGLE 0x0 /* Command: B_DIAGNOSE */ #define MODE_DIAG_MEM_READ_SINGLE 0x0 /* Command: B_DIAGNOSE */
#define MODE_DIAG_MEM_WRITE_SINGLE 0x1 /* Command: B_DIAGNOSE */ #define MODE_DIAG_MEM_WRITE_SINGLE 0x1 /* Command: B_DIAGNOSE */
#define MODE_DIAG_IO_READ_SINGLE 0x2 /* Command: B_STRUKTFKT */ #define MODE_DIAG_IO_READ_SINGLE 0x2 /* Command: B_STRUKTFKT */
#define MODE_DIAG_IO_WRITE_SINGLE 0x3 /* Command: B_STRUKTFKT */ #define MODE_DIAG_IO_WRITE_SINGLE 0x3 /* Command: B_STRUKTFKT */
#define MODE_DIAG_ZYKL 0x10 /* Command: B_STRUKTFKT */ #define MODE_DIAG_ZYKL 0x10 /* Command: B_STRUKTFKT */
#define MODE_DIAG_MEM_READ_ZYKL 0x10 /* Command: B_STRUKTFKT */ #define MODE_DIAG_MEM_READ_ZYKL 0x10 /* Command: B_STRUKTFKT */
#define MODE_DIAG_MEM_WRITE_ZYKL 0x11 /* Command: B_STRUKTFKT */ #define MODE_DIAG_MEM_WRITE_ZYKL 0x11 /* Command: B_STRUKTFKT */
#define MODE_DIAG_IO_READ_ZYKL 0x12 /* Command: B_STRUKTFKT */ #define MODE_DIAG_IO_READ_ZYKL 0x12 /* Command: B_STRUKTFKT */
#define MODE_DIAG_IO_WRITE_ZYKL 0x13 /* Command: B_STRUKTFKT */ #define MODE_DIAG_IO_WRITE_ZYKL 0x13 /* Command: B_STRUKTFKT */
#define MODE_ZYKL_TASK_STRUK 0 /* Command: B_STRUKTFKT */ #define MODE_ZYKL_TASK_STRUK 0 /* Command: B_STRUKTFKT */
#define MODE_INIT_INFO_STRUK 1 /* Command: B_STRUKTFKT */ #define MODE_INIT_INFO_STRUK 1 /* Command: B_STRUKTFKT */
#define MODE_WRITE_STRUK 2 /* Command: B_STRUKTFKT */ #define MODE_WRITE_STRUK 2 /* Command: B_STRUKTFKT */
#define MODE_START_TRACE 0 /* Command: B_TRACE */ #define MODE_START_TRACE 0 /* Command: B_TRACE */
#define MODE_DEL_TRACE_PUF 1 /* Command: B_TRACE */ #define MODE_DEL_TRACE_PUF 1 /* Command: B_TRACE */
#define MODE_UPLOAD_BINAER 0 /* Command: B_LOADFKT */ #define MODE_UPLOAD_BINAER 0 /* Command: B_LOADFKT */
#define MODE_DOWNLOAD_BINAER 1 /* Command: B_LOADFKT */ #define MODE_DOWNLOAD_BINAER 1 /* Command: B_LOADFKT */
#define MODE_UPLOAD_DBM 2 /* Command: B_LOADFKT */ #define MODE_UPLOAD_DBM 2 /* Command: B_LOADFKT */
#define MODE_DOWNLOAD_DBM 3 /* Command: B_LOADFKT */ #define MODE_DOWNLOAD_DBM 3 /* Command: B_LOADFKT */
#define MODE_DEL_FLASH 4 /* Command: B_LOADFKT */ #define MODE_DEL_FLASH 4 /* Command: B_LOADFKT */
#define MODE_GET_FLASH_DIR 5 /* Command: B_LOADFKT */ #define MODE_GET_FLASH_DIR 5 /* Command: B_LOADFKT */
#define MODE_URLADEN 6 /* Command: B_LOADFKT */ #define MODE_URLADEN 6 /* Command: B_LOADFKT */
#define MODE_LONG_BINLOAD 7 /* Command: B_LOADFKT */ #define MODE_LONG_BINLOAD 7 /* Command: B_LOADFKT */
#define MODE_FREE_DRIVER 8 /* Command: B_LOADFKT */ #define MODE_FREE_DRIVER 8 /* Command: B_LOADFKT */
#define MODE_RESET_DEVICE 10 /* Command: B_LOADFKT */ #define MODE_RESET_DEVICE 10 /* Command: B_LOADFKT */
/* ------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------
*/ */
......
This diff is collapsed.
...@@ -52,8 +52,8 @@ ...@@ -52,8 +52,8 @@
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Ao Init method for the Pb module Ao
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Ao* op; pwr_sClass_Pb_Ao* op;
...@@ -63,20 +63,24 @@ static pwr_tStatus IoCardInit( ...@@ -63,20 +63,24 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Ao*)cp->op; op = (pwr_sClass_Pb_Ao*)cp->op;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
if (rp->Class != pwr_cClass_Pb_DP_Slave) { if (rp->Class != pwr_cClass_Pb_DP_Slave)
{
errh_Info("Illegal object type %s", cp->Name); errh_Info("Illegal object type %s", cp->Name);
return IO__SUCCESS; return IO__SUCCESS;
} }
if (op->Status >= PB_MODULE_STATE_OPERATE) { if (op->Status >= PB_MODULE_STATE_OPERATE)
{
// Calculate polycoeff // Calculate polycoeff
for (i = 0; i < cp->ChanListSize; i++) { for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i]; chanp = &cp->chanlist[i];
if (!chanp->cop) if (!chanp->cop)
continue; continue;
io_AoRangeToCoef(chanp); io_AoRangeToCoef(chanp);
} }
} else }
else
errh_Info("Error initializing Pb module Ao %s", cp->Name); errh_Info("Error initializing Pb module Ao %s", cp->Name);
return IO__SUCCESS; return IO__SUCCESS;
...@@ -85,8 +89,8 @@ static pwr_tStatus IoCardInit( ...@@ -85,8 +89,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Write method for the Pb module Ao Write method for the Pb module Ao
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite( static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Ao* op; pwr_sClass_Pb_Ao* op;
...@@ -109,10 +113,12 @@ static pwr_tStatus IoCardWrite( ...@@ -109,10 +113,12 @@ static pwr_tStatus IoCardWrite(
op = (pwr_sClass_Pb_Ao*)cp->op; op = (pwr_sClass_Pb_Ao*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op; slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) { if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
fixout = ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT; fixout = ctx->Node->EmergBreakTrue && ctx->Node->EmergBreakSelect == FIXOUT;
for (i = 0; i < cp->ChanListSize; i++) { for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i]; chanp = &cp->chanlist[i];
if (!chanp->cop || !chanp->sop) if (!chanp->cop || !chanp->sop)
continue; continue;
...@@ -125,7 +131,8 @@ static pwr_tStatus IoCardWrite( ...@@ -125,7 +131,8 @@ static pwr_tStatus IoCardWrite(
value = cop->FixedOutValue; value = cop->FixedOutValue;
else if (cop->TestOn) else if (cop->TestOn)
value = cop->TestValue; value = cop->TestValue;
else { else
{
value = *(pwr_tFloat32*)chanp->vbp; value = *(pwr_tFloat32*)chanp->vbp;
} }
...@@ -152,50 +159,66 @@ static pwr_tStatus IoCardWrite( ...@@ -152,50 +159,66 @@ static pwr_tStatus IoCardWrite(
// Calculate signal value // Calculate signal value
sop->SigValue = cop->SigValPolyCoef1 * value + cop->SigValPolyCoef0; sop->SigValue = cop->SigValPolyCoef1 * value + cop->SigValPolyCoef0;
if (op->BytesPerChannel == 4) { if (op->BytesPerChannel == 4)
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata32 = (pwr_tUInt32)rawvalue; udata32 = (pwr_tUInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata32 = swap32(udata32); udata32 = swap32(udata32);
memcpy(local->output_area + op->OffsetOutputs + 4 * i, &udata32, 4); memcpy(local->output_area + op->OffsetOutputs + 4 * i, &udata32, 4);
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data32 = (pwr_tInt32)rawvalue; data32 = (pwr_tInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32); data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 4 * i, &data32, 4); memcpy(local->output_area + op->OffsetOutputs + 4 * i, &data32, 4);
} }
}
} else if (op->BytesPerChannel == 3) { else if (op->BytesPerChannel == 3)
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata32 = (pwr_tUInt32)rawvalue; udata32 = (pwr_tUInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata32 = swap32(udata32); udata32 = swap32(udata32);
memcpy(local->output_area + op->OffsetOutputs + 3 * i, &udata32, 3); memcpy(local->output_area + op->OffsetOutputs + 3 * i, &udata32, 3);
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data32 = (pwr_tInt32)rawvalue; data32 = (pwr_tInt32)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32); data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 3 * i, &data32, 3); memcpy(local->output_area + op->OffsetOutputs + 3 * i, &data32, 3);
} }
}
} else if (op->BytesPerChannel == 2) { else if (op->BytesPerChannel == 2)
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata16 = (pwr_tUInt16)rawvalue; udata16 = (pwr_tUInt16)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata16 = swap16(udata16); udata16 = swap16(udata16);
memcpy(local->output_area + op->OffsetOutputs + 2 * i, &udata16, 2); memcpy(local->output_area + op->OffsetOutputs + 2 * i, &udata16, 2);
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data16 = (pwr_tInt16)rawvalue; data16 = (pwr_tInt16)rawvalue;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data16 = swap16(data16); data16 = swap16(data16);
memcpy(local->output_area + op->OffsetOutputs + 2 * i, &data16, 2); memcpy(local->output_area + op->OffsetOutputs + 2 * i, &data16, 2);
} }
}
} else if (op->BytesPerChannel == 1) { else if (op->BytesPerChannel == 1)
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata8 = (pwr_tUInt8)rawvalue; udata8 = (pwr_tUInt8)rawvalue;
memcpy(local->output_area + op->OffsetOutputs + i, &udata8, 1); memcpy(local->output_area + op->OffsetOutputs + i, &udata8, 1);
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data8 = (pwr_tInt8)rawvalue; data8 = (pwr_tInt8)rawvalue;
memcpy(local->output_area + op->OffsetOutputs + i, &data8, 1); memcpy(local->output_area + op->OffsetOutputs + i, &data8, 1);
} }
...@@ -209,8 +232,8 @@ static pwr_tStatus IoCardWrite( ...@@ -209,8 +232,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -224,6 +247,6 @@ static pwr_tStatus IoCardClose( ...@@ -224,6 +247,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Ao) pwr_dExport pwr_BindIoMethods(Pb_Ao) = {
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod }; pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
...@@ -54,8 +54,8 @@ ...@@ -54,8 +54,8 @@
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Move di data word to valuebase. Move di data word to valuebase.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
void pbio_DiUnpackWord( void pbio_DiUnpackWord(io_sCard* cp, pwr_tUInt16 data, pwr_tUInt16 mask,
io_sCard* cp, pwr_tUInt16 data, pwr_tUInt16 mask, int index) int index)
{ {
io_sChannel* chanp; io_sChannel* chanp;
...@@ -64,7 +64,8 @@ void pbio_DiUnpackWord( ...@@ -64,7 +64,8 @@ void pbio_DiUnpackWord(
else else
chanp = &cp->chanlist[16]; chanp = &cp->chanlist[16];
if (mask == IO_CONVMASK_ALL) { if (mask == IO_CONVMASK_ALL)
{
/* No conversion test */ /* No conversion test */
if (chanp->cop && chanp->sop) if (chanp->cop && chanp->sop)
*(pwr_tUInt16*)(chanp->vbp) = ((data & 1) != 0); *(pwr_tUInt16*)(chanp->vbp) = ((data & 1) != 0);
...@@ -114,7 +115,9 @@ void pbio_DiUnpackWord( ...@@ -114,7 +115,9 @@ void pbio_DiUnpackWord(
if (chanp->cop && chanp->sop) if (chanp->cop && chanp->sop)
*(pwr_tUInt16*)(chanp->vbp) = ((data & 32768) != 0); *(pwr_tUInt16*)(chanp->vbp) = ((data & 32768) != 0);
chanp++; chanp++;
} else { }
else
{
if (chanp->cop && chanp->sop && mask & 1) if (chanp->cop && chanp->sop && mask & 1)
*(pwr_tUInt16*)(chanp->vbp) = ((data & 1) != 0); *(pwr_tUInt16*)(chanp->vbp) = ((data & 1) != 0);
chanp++; chanp++;
...@@ -169,8 +172,8 @@ void pbio_DiUnpackWord( ...@@ -169,8 +172,8 @@ void pbio_DiUnpackWord(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Di Init method for the Pb module Di
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Di* op; pwr_sClass_Pb_Di* op;
...@@ -180,8 +183,8 @@ static pwr_tStatus IoCardInit( ...@@ -180,8 +183,8 @@ static pwr_tStatus IoCardInit(
// Check configuration // Check configuration
if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16 if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16 &&
&& op->NumberOfChannels != 32) op->NumberOfChannels != 32)
op->Status = PB_MODULE_STATE_NOTINIT; op->Status = PB_MODULE_STATE_NOTINIT;
if (op->Orientation > op->NumberOfChannels) if (op->Orientation > op->NumberOfChannels)
...@@ -196,8 +199,8 @@ static pwr_tStatus IoCardInit( ...@@ -196,8 +199,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Read method for the Pb module Di Read method for the Pb module Di
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead( static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Di* op; pwr_sClass_Pb_Di* op;
...@@ -208,22 +211,27 @@ static pwr_tStatus IoCardRead( ...@@ -208,22 +211,27 @@ static pwr_tStatus IoCardRead(
pwr_sClass_Di* sig_di; pwr_sClass_Di* sig_di;
pwr_tUInt32 mask = 0; pwr_tUInt32 mask = 0;
pwr_tUInt16 data[2] = { 0, 0 }; pwr_tUInt16 data[2] = {0, 0};
pwr_tUInt32* data32; pwr_tUInt32* data32;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
op = (pwr_sClass_Pb_Di*)cp->op; op = (pwr_sClass_Pb_Di*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op; slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) { if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
memcpy(&data, local->input_area + op->OffsetInputs, op->BytesOfInput); memcpy(&data, local->input_area + op->OffsetInputs, op->BytesOfInput);
data32 = (pwr_tUInt32*)&data; data32 = (pwr_tUInt32*)&data;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) { if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (op->Orientation == PB_ORIENTATION_WORD) { {
if (op->Orientation == PB_ORIENTATION_WORD)
{
data[0] = swap16(data[0]); data[0] = swap16(data[0]);
data[1] = swap16(data[1]); data[1] = swap16(data[1]);
} else if (op->Orientation == PB_ORIENTATION_DWORD) { }
else if (op->Orientation == PB_ORIENTATION_DWORD)
{
*data32 = swap32(*data32); *data32 = swap32(*data32);
} }
} }
...@@ -233,11 +241,13 @@ static pwr_tStatus IoCardRead( ...@@ -233,11 +241,13 @@ static pwr_tStatus IoCardRead(
data[1] = data[1] ^ op->InvMask2; data[1] = data[1] ^ op->InvMask2;
// Packa upp // Packa upp
for (i = 0; i < cp->ChanListSize; i++) { for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i]; chanp = &cp->chanlist[i];
chan_di = (pwr_sClass_ChanDi*)chanp->cop; chan_di = (pwr_sClass_ChanDi*)chanp->cop;
sig_di = (pwr_sClass_Di*)chanp->sop; sig_di = (pwr_sClass_Di*)chanp->sop;
if (chan_di && sig_di) { if (chan_di && sig_di)
{
mask = 1 << chan_di->Number; mask = 1 << chan_di->Number;
*(pwr_tUInt16*)(chanp->vbp) = ((*data32 & mask) != 0); *(pwr_tUInt16*)(chanp->vbp) = ((*data32 & mask) != 0);
} }
...@@ -258,8 +268,8 @@ static pwr_tStatus IoCardRead( ...@@ -258,8 +268,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -273,5 +283,6 @@ static pwr_tStatus IoCardClose( ...@@ -273,5 +283,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Di) = { pwr_BindIoMethod(IoCardInit), pwr_dExport pwr_BindIoMethods(Pb_Di) = {
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardClose), pwr_NullMethod }; pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
...@@ -52,8 +52,8 @@ ...@@ -52,8 +52,8 @@
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Do Init method for the Pb module Do
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Do* op; pwr_sClass_Pb_Do* op;
...@@ -61,8 +61,8 @@ static pwr_tStatus IoCardInit( ...@@ -61,8 +61,8 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Do*)cp->op; op = (pwr_sClass_Pb_Do*)cp->op;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16 if (op->NumberOfChannels != 8 && op->NumberOfChannels != 16 &&
&& op->NumberOfChannels != 32) op->NumberOfChannels != 32)
op->Status = PB_MODULE_STATE_NOTINIT; op->Status = PB_MODULE_STATE_NOTINIT;
if (op->Orientation > op->NumberOfChannels) if (op->Orientation > op->NumberOfChannels)
...@@ -77,8 +77,8 @@ static pwr_tStatus IoCardInit( ...@@ -77,8 +77,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Write method for the Pb module Do Write method for the Pb module Do
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite( static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Do* op; pwr_sClass_Pb_Do* op;
...@@ -90,22 +90,25 @@ static pwr_tStatus IoCardWrite( ...@@ -90,22 +90,25 @@ static pwr_tStatus IoCardWrite(
pwr_tUInt32 mask = 0; pwr_tUInt32 mask = 0;
pwr_tInt32 do_actval; pwr_tInt32 do_actval;
pwr_tUInt16 data[2] = { 0, 0 }; pwr_tUInt16 data[2] = {0, 0};
pwr_tUInt32* data32; pwr_tUInt32* data32;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
op = (pwr_sClass_Pb_Do*)cp->op; op = (pwr_sClass_Pb_Do*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op; slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) { if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
{
data32 = (pwr_tUInt32*)&data; data32 = (pwr_tUInt32*)&data;
// Packa ner // Packa ner
for (i = 0; i < cp->ChanListSize; i++) { for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i]; chanp = &cp->chanlist[i];
chan_do = (pwr_sClass_ChanDo*)chanp->cop; chan_do = (pwr_sClass_ChanDo*)chanp->cop;
sig_do = (pwr_sClass_Do*)chanp->sop; sig_do = (pwr_sClass_Do*)chanp->sop;
if (chan_do && sig_do) { if (chan_do && sig_do)
{
mask = 1 << chan_do->Number; mask = 1 << chan_do->Number;
do_actval = *(pwr_tInt32*)chanp->vbp; do_actval = *(pwr_tInt32*)chanp->vbp;
if (do_actval != 0) if (do_actval != 0)
...@@ -118,11 +121,15 @@ static pwr_tStatus IoCardWrite( ...@@ -118,11 +121,15 @@ static pwr_tStatus IoCardWrite(
io_DoPackWord(cp, &data[0], 0); io_DoPackWord(cp, &data[0], 0);
if (op->NumberOfChannels > 16) io_DoPackWord(cp, &data[1], 1); if (op->NumberOfChannels > 16) io_DoPackWord(cp, &data[1], 1);
*/ */
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) { if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
if (op->Orientation == PB_ORIENTATION_WORD) { {
if (op->Orientation == PB_ORIENTATION_WORD)
{
data[0] = swap16(data[0]); data[0] = swap16(data[0]);
data[1] = swap16(data[1]); data[1] = swap16(data[1]);
} else if (op->Orientation == PB_ORIENTATION_DWORD) { }
else if (op->Orientation == PB_ORIENTATION_DWORD)
{
*data32 = swap32(*data32); *data32 = swap32(*data32);
} }
} }
...@@ -135,8 +142,8 @@ static pwr_tStatus IoCardWrite( ...@@ -135,8 +142,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -150,6 +157,6 @@ static pwr_tStatus IoCardClose( ...@@ -150,6 +157,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Do) pwr_dExport pwr_BindIoMethods(Pb_Do) = {
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod }; pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
...@@ -112,7 +112,8 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -112,7 +112,8 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
latent_input_count = 0; latent_input_count = 0;
latent_output_count = 0; latent_output_count = 0;
while (cardp) { while (cardp)
{
local_card = calloc(1, sizeof(*local_card)); local_card = calloc(1, sizeof(*local_card));
cardp->Local = local_card; cardp->Local = local_card;
local_card->input_area = (void*)&(op->Inputs); local_card->input_area = (void*)&(op->Inputs);
...@@ -124,11 +125,12 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -124,11 +125,12 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
while (ODD(gdh_GetSuperClass(cid, &cid, cardp->Objid))) while (ODD(gdh_GetSuperClass(cid, &cid, cardp->Objid)))
; ;
switch (cid) { switch (cid)
/* Old style configuring with Pb_xx objects. Still here for combatibility {
reasons. /* Old style configuring with Pb_xx objects. Still here for combatibility
New systems (from v4.1.3) should be build with Pb_Module objects or reasons.
subclasses */ New systems (from v4.1.3) should be build with Pb_Module objects or
subclasses */
case pwr_cClass_Pb_Di: case pwr_cClass_Pb_Di:
dip = (pwr_sClass_Pb_Di*)cardp->op; dip = (pwr_sClass_Pb_Di*)cardp->op;
...@@ -178,24 +180,27 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -178,24 +180,27 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
iop->Status = PB_MODULE_STATE_OPERATE; iop->Status = PB_MODULE_STATE_OPERATE;
break; break;
/* New style configuring (from v4.1.3) with Pb_Module objects or subclass. /* New style configuring (from v4.1.3) with Pb_Module objects or subclass.
Loop all channels Loop all channels
in the module and set channel size and offset. */ in the module and set channel size and offset. */
case pwr_cClass_Pb_Module: case pwr_cClass_Pb_Module:
mp = (pwr_sClass_Pb_Module*)cardp->op; mp = (pwr_sClass_Pb_Module*)cardp->op;
mp->Status = PB__INITFAIL; mp->Status = PB__INITFAIL;
cardp->offset = 0; cardp->offset = 0;
for (i = 0; i < cardp->ChanListSize; i++) { for (i = 0; i < cardp->ChanListSize; i++)
{
chanp = &cardp->chanlist[i]; chanp = &cardp->chanlist[i];
if (is_diag(&chanp->ChanAref)) { if (is_diag(&chanp->ChanAref))
{
chanp->udata |= PB_UDATA_DIAG; chanp->udata |= PB_UDATA_DIAG;
switch (chanp->ChanClass) { switch (chanp->ChanClass)
{
case pwr_cClass_ChanIi: case pwr_cClass_ChanIi:
chanp->offset = ((pwr_sClass_ChanIi*)chanp->cop)->Number; chanp->offset = ((pwr_sClass_ChanIi*)chanp->cop)->Number;
chanp->size chanp->size =
= GetChanSize(((pwr_sClass_ChanIi*)chanp->cop)->Representation); GetChanSize(((pwr_sClass_ChanIi*)chanp->cop)->Representation);
break; break;
default: default:
errh_Error("Diagnostic channel class, card %s", cardp->Name); errh_Error("Diagnostic channel class, card %s", cardp->Name);
...@@ -203,30 +208,34 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -203,30 +208,34 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
continue; continue;
} }
if (chanp->ChanClass != pwr_cClass_ChanDi) { if (chanp->ChanClass != pwr_cClass_ChanDi)
{
input_counter += latent_input_count; input_counter += latent_input_count;
latent_input_count = 0; latent_input_count = 0;
} }
if (chanp->ChanClass != pwr_cClass_ChanDo) { if (chanp->ChanClass != pwr_cClass_ChanDo)
{
output_counter += latent_output_count; output_counter += latent_output_count;
latent_output_count = 0; latent_output_count = 0;
} }
switch (chanp->ChanClass) { switch (chanp->ChanClass)
{
case pwr_cClass_ChanDi: case pwr_cClass_ChanDi:
chan_di = (pwr_sClass_ChanDi*)chanp->cop; chan_di = (pwr_sClass_ChanDi*)chanp->cop;
if (chan_di->Number == 0) { if (chan_di->Number == 0)
{
input_counter += latent_input_count; input_counter += latent_input_count;
latent_input_count = 0; latent_input_count = 0;
} }
chanp->offset = input_counter; chanp->offset = input_counter;
chanp->mask = 1 << chan_di->Number; chanp->mask = 1 << chan_di->Number;
if (chan_di->Representation == pwr_eDataRepEnum_Bit16 if (chan_di->Representation == pwr_eDataRepEnum_Bit16 &&
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap16(chanp->mask); chanp->mask = swap16(chanp->mask);
if (chan_di->Representation == pwr_eDataRepEnum_Bit32 if (chan_di->Representation == pwr_eDataRepEnum_Bit32 &&
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap32(chanp->mask); chanp->mask = swap32(chanp->mask);
if (chan_di->Number == 0) if (chan_di->Number == 0)
latent_input_count = GetChanSize(chan_di->Representation); latent_input_count = GetChanSize(chan_di->Representation);
...@@ -269,18 +278,19 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -269,18 +278,19 @@ static pwr_tStatus IoRackInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
case pwr_cClass_ChanDo: case pwr_cClass_ChanDo:
chan_do = (pwr_sClass_ChanDo*)chanp->cop; chan_do = (pwr_sClass_ChanDo*)chanp->cop;
if (chan_do->Number == 0) { if (chan_do->Number == 0)
{
output_counter += latent_output_count; output_counter += latent_output_count;
latent_output_count = 0; latent_output_count = 0;
} }
chanp->offset = output_counter; chanp->offset = output_counter;
chan_size = GetChanSize(chan_do->Representation); chan_size = GetChanSize(chan_do->Representation);
chanp->mask = 1 << chan_do->Number; chanp->mask = 1 << chan_do->Number;
if (chan_do->Representation == pwr_eDataRepEnum_Bit16 if (chan_do->Representation == pwr_eDataRepEnum_Bit16 &&
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap16(chanp->mask); chanp->mask = swap16(chanp->mask);
if (chan_do->Representation == pwr_eDataRepEnum_Bit32 if (chan_do->Representation == pwr_eDataRepEnum_Bit32 &&
&& op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) op->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
chanp->mask = swap32(chanp->mask); chanp->mask = swap32(chanp->mask);
if (chan_do->Number == 0) if (chan_do->Number == 0)
latent_output_count = GetChanSize(chan_do->Representation); latent_output_count = GetChanSize(chan_do->Representation);
...@@ -342,35 +352,45 @@ static pwr_tStatus IoRackRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -342,35 +352,45 @@ static pwr_tStatus IoRackRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
/* The reading of the process image is now performed at the agent level, /* The reading of the process image is now performed at the agent level,
this eliminates the need for board specific code at the rack level. */ this eliminates the need for board specific code at the rack level. */
if (sp->DisableSlave != 1 && mp->DisableBus != 1) { if (sp->DisableSlave != 1 && mp->DisableBus != 1)
if (sp->Status == PB__NORMAL) { {
if (sp->Status == PB__NORMAL)
{
sp->ErrorCount = 0; sp->ErrorCount = 0;
} else { }
else
{
if (local->start_cnt >= local->start_time) if (local->start_cnt >= local->start_time)
sp->ErrorCount++; sp->ErrorCount++;
} }
if (sp->ErrorCount == sp->ErrorSoftLimit) { if (sp->ErrorCount == sp->ErrorSoftLimit)
{
errh_Error("IO Error soft limit reached on card '%s'", rp->Name); errh_Error("IO Error soft limit reached on card '%s'", rp->Name);
ctx->IOHandler->CardErrorSoftLimit = 1; ctx->IOHandler->CardErrorSoftLimit = 1;
ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(rp->Objid); ctx->IOHandler->ErrorSoftLimitObject = cdh_ObjidToAref(rp->Objid);
} }
if (sp->ErrorCount == sp->ErrorHardLimit) { if (sp->ErrorCount == sp->ErrorHardLimit)
{
errh_Error("IO Error hard limit reached on card '%s', stall action %d", errh_Error("IO Error hard limit reached on card '%s', stall action %d",
rp->Name, sp->StallAction); rp->Name, sp->StallAction);
ctx->IOHandler->CardErrorHardLimit = 1; ctx->IOHandler->CardErrorHardLimit = 1;
ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(rp->Objid); ctx->IOHandler->ErrorHardLimitObject = cdh_ObjidToAref(rp->Objid);
} }
if (sp->ErrorCount > sp->ErrorHardLimit if (sp->ErrorCount > sp->ErrorHardLimit &&
&& sp->StallAction == pwr_ePbStallAction_ResetInputs) { sp->StallAction == pwr_ePbStallAction_ResetInputs)
{
memset(&sp->Inputs, 0, sp->BytesOfInput); memset(&sp->Inputs, 0, sp->BytesOfInput);
} }
if (sp->ErrorCount > sp->ErrorHardLimit if (sp->ErrorCount > sp->ErrorHardLimit &&
&& sp->StallAction == pwr_ePbStallAction_EmergencyBreak) { sp->StallAction == pwr_ePbStallAction_EmergencyBreak)
{
ctx->Node->EmergBreakTrue = 1; ctx->Node->EmergBreakTrue = 1;
} }
} else { }
else
{
sp->ErrorCount = 0; sp->ErrorCount = 0;
sp->Status = PB__DISABLED; sp->Status = PB__DISABLED;
} }
...@@ -410,6 +430,7 @@ static pwr_tStatus IoRackClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -410,6 +430,7 @@ static pwr_tStatus IoRackClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_DP_Slave) = { pwr_BindIoMethod(IoRackInit), pwr_dExport pwr_BindIoMethods(Pb_DP_Slave) = {
pwr_BindIoMethod(IoRackRead), pwr_BindIoMethod(IoRackWrite), pwr_BindIoMethod(IoRackInit), pwr_BindIoMethod(IoRackRead),
pwr_BindIoMethod(IoRackClose), pwr_NullMethod }; pwr_BindIoMethod(IoRackWrite), pwr_BindIoMethod(IoRackClose),
pwr_NullMethod};
...@@ -65,8 +65,9 @@ ...@@ -65,8 +65,9 @@
static unsigned char req_res_buffer[512]; static unsigned char req_res_buffer[512];
static short fdlif_sda_sdn_sdr_req(io_sAgentLocal* local_agent, static short fdlif_sda_sdn_sdr_req(io_sAgentLocal* local_agent,
pwr_sClass_Pb_FDL_SAP* sap, pwr_sClass_Pb_FDL_DataTransfer* op, pwr_sClass_Pb_FDL_SAP* sap,
io_sFDLCardLocal* local) pwr_sClass_Pb_FDL_DataTransfer* op,
io_sFDLCardLocal* local)
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION FUNCTIONAL_DESCRIPTION
...@@ -106,16 +107,20 @@ possible return values: ...@@ -106,16 +107,20 @@ possible return values:
*/ */
sdb.comm_ref = 0; sdb.comm_ref = 0;
sdb.layer = FDLIF; sdb.layer = FDLIF;
switch (op->Type) { switch (op->Type)
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDA: { {
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDA:
{
sdb.service = FDLIF_SDA; sdb.service = FDLIF_SDA;
break; break;
} }
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDN: { case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SDN:
{
sdb.service = FDLIF_SDN; sdb.service = FDLIF_SDN;
break; break;
} }
case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SRD: { case pwr_ePbFDLDataTransferTypeEnum_FDLIF_SRD:
{
sdb.service = FDLIF_SRD; sdb.service = FDLIF_SRD;
break; break;
} }
...@@ -128,15 +133,17 @@ possible return values: ...@@ -128,15 +133,17 @@ possible return values:
sdb.invoke_id = local->invoke_id = local_agent->invoke_id; sdb.invoke_id = local->invoke_id = local_agent->invoke_id;
local_agent->invoke_id = (local_agent->invoke_id + 1) % 128; local_agent->invoke_id = (local_agent->invoke_id + 1) % 128;
result = profi_snd_req_res( // result = profi_snd_req_res(
(T_PROFI_DEVICE_HANDLE*)local_agent, &sdb, (void*)req, PB_FALSE); // (T_PROFI_DEVICE_HANDLE*)local_agent, &sdb, (void*)req, PB_FALSE);
result = profi_snd_req_res(&sdb, (void*)req, PB_FALSE);
return ((pwr_tBoolean)(result == E_OK)); return ((pwr_tBoolean)(result == E_OK));
} }
static short fdlif_reply_update_mult_req(io_sAgentLocal* local_agent, static short fdlif_reply_update_mult_req(io_sAgentLocal* local_agent,
pwr_sClass_Pb_FDL_SAP* sap, pwr_sClass_Pb_FDL_DataTransfer* op, pwr_sClass_Pb_FDL_SAP* sap,
io_sFDLCardLocal* local) pwr_sClass_Pb_FDL_DataTransfer* op,
io_sFDLCardLocal* local)
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
FUNCTIONAL_DESCRIPTION FUNCTIONAL_DESCRIPTION
...@@ -179,8 +186,9 @@ possible return values: ...@@ -179,8 +186,9 @@ possible return values:
sdb.invoke_id = local->invoke_id = local_agent->invoke_id; sdb.invoke_id = local->invoke_id = local_agent->invoke_id;
local_agent->invoke_id = (local_agent->invoke_id + 1) % 128; local_agent->invoke_id = (local_agent->invoke_id + 1) % 128;
result = profi_snd_req_res( // result = profi_snd_req_res((T_PROFI_DEVICE_HANDLE*)local_agent, &sdb,
(T_PROFI_DEVICE_HANDLE*)local_agent, &sdb, (void*)req, PB_FALSE); // (void*)req, PB_FALSE);
result = profi_snd_req_res(&sdb, (void*)req, PB_FALSE);
return ((pwr_tBoolean)(result == E_OK)); return ((pwr_tBoolean)(result == E_OK));
} }
...@@ -188,8 +196,8 @@ possible return values: ...@@ -188,8 +196,8 @@ possible return values:
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Init method for the Pb module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sFDLCardLocal* local; io_sFDLCardLocal* local;
pwr_sClass_Pb_FDL_DataTransfer* op = (pwr_sClass_Pb_FDL_DataTransfer*)cp->op; pwr_sClass_Pb_FDL_DataTransfer* op = (pwr_sClass_Pb_FDL_DataTransfer*)cp->op;
...@@ -206,8 +214,8 @@ static pwr_tStatus IoCardInit( ...@@ -206,8 +214,8 @@ static pwr_tStatus IoCardInit(
local->byte_ordering = ((pwr_sClass_Pb_FDL_SAP*)rp->op)->ByteOrdering; local->byte_ordering = ((pwr_sClass_Pb_FDL_SAP*)rp->op)->ByteOrdering;
io_bus_card_init(ctx, cp, &input_area_offset, &input_area_chansize, io_bus_card_init(ctx, cp, &input_area_offset, &input_area_chansize,
&output_area_offset, &output_area_chansize, local->byte_ordering, &output_area_offset, &output_area_chansize,
io_eAlignment_Packed); local->byte_ordering, io_eAlignment_Packed);
local->input_area_size = input_area_offset + input_area_chansize; local->input_area_size = input_area_offset + input_area_chansize;
local->output_area_size = output_area_offset + output_area_chansize; local->output_area_size = output_area_offset + output_area_chansize;
...@@ -227,13 +235,13 @@ static pwr_tStatus IoCardInit( ...@@ -227,13 +235,13 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Read method for the Pb FDL Data transfer module Read method for the Pb FDL Data transfer module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead( static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sFDLCardLocal* local = (io_sFDLCardLocal*)cp->Local; io_sFDLCardLocal* local = (io_sFDLCardLocal*)cp->Local;
io_bus_card_read(ctx, rp, cp, local->input_area, 0, local->byte_ordering, io_bus_card_read(ctx, rp, cp, local->input_area, 0, local->byte_ordering,
local->float_representation); local->float_representation);
return IO__SUCCESS; return IO__SUCCESS;
} }
...@@ -241,8 +249,8 @@ static pwr_tStatus IoCardRead( ...@@ -241,8 +249,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Write method for the Pb FDL Data transfer module Write method for the Pb FDL Data transfer module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite( static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sAgentLocal* local_agent = (io_sAgentLocal*)ap->Local; io_sAgentLocal* local_agent = (io_sAgentLocal*)ap->Local;
pwr_sClass_Pb_FDL_DataTransfer* op = (pwr_sClass_Pb_FDL_DataTransfer*)cp->op; pwr_sClass_Pb_FDL_DataTransfer* op = (pwr_sClass_Pb_FDL_DataTransfer*)cp->op;
...@@ -251,16 +259,21 @@ static pwr_tStatus IoCardWrite( ...@@ -251,16 +259,21 @@ static pwr_tStatus IoCardWrite(
op->Status = sap->Status; op->Status = sap->Status;
if (op->Status == PB__NORMAL) { if (op->Status == PB__NORMAL)
{
io_bus_card_write(ctx, cp, local->output_area, local->byte_ordering, io_bus_card_write(ctx, cp, local->output_area, local->byte_ordering,
local->float_representation); local->float_representation);
if (op->SendReq) { if (op->SendReq)
{
pthread_mutex_lock(&local_agent->mutex); pthread_mutex_lock(&local_agent->mutex);
if (sap->Responder) { if (sap->Responder)
{
fdlif_reply_update_mult_req(local_agent, sap, op, local); fdlif_reply_update_mult_req(local_agent, sap, op, local);
} else { }
else
{
fdlif_sda_sdn_sdr_req(local_agent, sap, op, local); fdlif_sda_sdn_sdr_req(local_agent, sap, op, local);
} }
op->SendReq = 0; op->SendReq = 0;
...@@ -274,8 +287,8 @@ static pwr_tStatus IoCardWrite( ...@@ -274,8 +287,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Close method for the Pb module Close method for the Pb module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -290,7 +303,7 @@ static pwr_tStatus IoCardClose( ...@@ -290,7 +303,7 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_FDL_DataTransfer) pwr_dExport pwr_BindIoMethods(Pb_FDL_DataTransfer) = {
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardClose), pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardClose),
pwr_NullMethod }; pwr_NullMethod};
...@@ -85,5 +85,6 @@ static pwr_tStatus IoRackClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp) ...@@ -85,5 +85,6 @@ static pwr_tStatus IoRackClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp)
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_FDL_SAP) = { pwr_BindIoMethod(IoRackInit), pwr_dExport pwr_BindIoMethods(Pb_FDL_SAP) = {pwr_BindIoMethod(IoRackInit),
pwr_BindIoMethod(IoRackClose), pwr_NullMethod }; pwr_BindIoMethod(IoRackClose),
pwr_NullMethod};
This diff is collapsed.
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Ii Init method for the Pb module Ii
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Ii* op; pwr_sClass_Pb_Ii* op;
...@@ -60,7 +60,8 @@ static pwr_tStatus IoCardInit( ...@@ -60,7 +60,8 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Ii*)cp->op; op = (pwr_sClass_Pb_Ii*)cp->op;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
if (rp->Class != pwr_cClass_Pb_DP_Slave) { if (rp->Class != pwr_cClass_Pb_DP_Slave)
{
errh_Info("Illegal object type %s", cp->Name); errh_Info("Illegal object type %s", cp->Name);
return IO__SUCCESS; return IO__SUCCESS;
} }
...@@ -74,8 +75,8 @@ static pwr_tStatus IoCardInit( ...@@ -74,8 +75,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Read method for the Pb Ii card Read method for the Pb Ii card
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead( static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Ii* op; pwr_sClass_Pb_Ii* op;
...@@ -95,8 +96,10 @@ static pwr_tStatus IoCardRead( ...@@ -95,8 +96,10 @@ static pwr_tStatus IoCardRead(
op = (pwr_sClass_Pb_Ii*)cp->op; op = (pwr_sClass_Pb_Ii*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op; slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) { if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
for (i = 0; i < cp->ChanListSize; i++) { {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i]; chanp = &cp->chanlist[i];
if (!chanp->cop || !chanp->sop) if (!chanp->cop || !chanp->sop)
continue; continue;
...@@ -104,54 +107,76 @@ static pwr_tStatus IoCardRead( ...@@ -104,54 +107,76 @@ static pwr_tStatus IoCardRead(
cop = (pwr_sClass_ChanIi*)chanp->cop; cop = (pwr_sClass_ChanIi*)chanp->cop;
sop = (pwr_sClass_Ii*)chanp->sop; sop = (pwr_sClass_Ii*)chanp->sop;
if (cop->ConversionOn) { if (cop->ConversionOn)
if (op->BytesPerChannel == 4) { {
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { if (op->BytesPerChannel == 4)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
memcpy(&udata32, local->input_area + op->OffsetInputs + 4 * i, 4); memcpy(&udata32, local->input_area + op->OffsetInputs + 4 * i, 4);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata32 = swap32(udata32); udata32 = swap32(udata32);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata32; *(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata32;
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
memcpy(&data32, local->input_area + op->OffsetInputs + 4 * i, 4); memcpy(&data32, local->input_area + op->OffsetInputs + 4 * i, 4);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32); data32 = swap32(data32);
*(pwr_tInt32*)chanp->vbp = data32; *(pwr_tInt32*)chanp->vbp = data32;
} }
} else if (op->BytesPerChannel == 3) { }
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { else if (op->BytesPerChannel == 3)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
udata32 = 0; udata32 = 0;
memcpy(&udata32, local->input_area + op->OffsetInputs + 3 * i, 3); memcpy(&udata32, local->input_area + op->OffsetInputs + 3 * i, 3);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) { if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
{
udata32 = swap32(udata32); udata32 = swap32(udata32);
udata32 = udata32 >> 8; udata32 = udata32 >> 8;
} }
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata32; *(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata32;
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
data32 = 0; data32 = 0;
memcpy(&data32, local->input_area + op->OffsetInputs + 3 * i, 3); memcpy(&data32, local->input_area + op->OffsetInputs + 3 * i, 3);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) { if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
{
data32 = swap32(data32); data32 = swap32(data32);
data32 = data32 >> 8; data32 = data32 >> 8;
} }
*(pwr_tInt32*)chanp->vbp = data32; *(pwr_tInt32*)chanp->vbp = data32;
} }
} else if (op->BytesPerChannel == 2) { }
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { else if (op->BytesPerChannel == 2)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
memcpy(&udata16, local->input_area + op->OffsetInputs + 2 * i, 2); memcpy(&udata16, local->input_area + op->OffsetInputs + 2 * i, 2);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
udata16 = swap16(udata16); udata16 = swap16(udata16);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata16; *(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata16;
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
memcpy(&data16, local->input_area + op->OffsetInputs + 2 * i, 2); memcpy(&data16, local->input_area + op->OffsetInputs + 2 * i, 2);
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data16 = swap16(data16); data16 = swap16(data16);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)data16; *(pwr_tInt32*)chanp->vbp = (pwr_tInt32)data16;
} }
} else if (op->BytesPerChannel == 1) { }
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT) { else if (op->BytesPerChannel == 1)
{
if (op->NumberRepresentation == PB_NUMREP_UNSIGNEDINT)
{
memcpy(&udata8, local->input_area + op->OffsetInputs + i, 1); memcpy(&udata8, local->input_area + op->OffsetInputs + i, 1);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata8; *(pwr_tInt32*)chanp->vbp = (pwr_tInt32)udata8;
} else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT) { }
else if (op->NumberRepresentation == PB_NUMREP_SIGNEDINT)
{
memcpy(&data8, local->input_area + op->OffsetInputs + i, 1); memcpy(&data8, local->input_area + op->OffsetInputs + i, 1);
*(pwr_tInt32*)chanp->vbp = (pwr_tInt32)data8; *(pwr_tInt32*)chanp->vbp = (pwr_tInt32)data8;
} }
...@@ -166,8 +191,8 @@ static pwr_tStatus IoCardRead( ...@@ -166,8 +191,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Close method for the Pb Ii card Close method for the Pb Ii card
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -181,5 +206,6 @@ static pwr_tStatus IoCardClose( ...@@ -181,5 +206,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Ii) = { pwr_BindIoMethod(IoCardInit), pwr_dExport pwr_BindIoMethods(Pb_Ii) = {
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardClose), pwr_NullMethod }; pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Io Init method for the Pb module Io
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Io* op; pwr_sClass_Pb_Io* op;
...@@ -58,12 +58,14 @@ static pwr_tStatus IoCardInit( ...@@ -58,12 +58,14 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Io*)cp->op; op = (pwr_sClass_Pb_Io*)cp->op;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
if (rp->Class != pwr_cClass_Pb_DP_Slave) { if (rp->Class != pwr_cClass_Pb_DP_Slave)
{
errh_Info("Illegal object type %s", cp->Name); errh_Info("Illegal object type %s", cp->Name);
return IO__SUCCESS; return IO__SUCCESS;
} }
if (op->Status < PB_MODULE_STATE_OPERATE) { if (op->Status < PB_MODULE_STATE_OPERATE)
{
errh_Info("Error initializing Pb module Io %s", cp->Name); errh_Info("Error initializing Pb module Io %s", cp->Name);
} }
...@@ -73,8 +75,8 @@ static pwr_tStatus IoCardInit( ...@@ -73,8 +75,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Write method for the Pb module Io Write method for the Pb module Io
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite( static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Io* op; pwr_sClass_Pb_Io* op;
...@@ -91,8 +93,10 @@ static pwr_tStatus IoCardWrite( ...@@ -91,8 +93,10 @@ static pwr_tStatus IoCardWrite(
op = (pwr_sClass_Pb_Io*)cp->op; op = (pwr_sClass_Pb_Io*)cp->op;
slave = (pwr_sClass_Pb_DP_Slave*)rp->op; slave = (pwr_sClass_Pb_DP_Slave*)rp->op;
if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1) { if (op->Status >= PB_MODULE_STATE_OPERATE && slave->DisableSlave != 1)
for (i = 0; i < cp->ChanListSize; i++) { {
for (i = 0; i < cp->ChanListSize; i++)
{
chanp = &cp->chanlist[i]; chanp = &cp->chanlist[i];
if (!chanp->cop || !chanp->sop) if (!chanp->cop || !chanp->sop)
continue; continue;
...@@ -105,20 +109,27 @@ static pwr_tStatus IoCardWrite( ...@@ -105,20 +109,27 @@ static pwr_tStatus IoCardWrite(
data32 = *(pwr_tInt32*)chanp->vbp; data32 = *(pwr_tInt32*)chanp->vbp;
if (op->BytesPerChannel == 4) { if (op->BytesPerChannel == 4)
{
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32); data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 4 * i, &data32, 4); memcpy(local->output_area + op->OffsetOutputs + 4 * i, &data32, 4);
} else if (op->BytesPerChannel == 3) { }
else if (op->BytesPerChannel == 3)
{
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data32 = swap32(data32); data32 = swap32(data32);
memcpy(local->output_area + op->OffsetOutputs + 3 * i, &data32, 3); memcpy(local->output_area + op->OffsetOutputs + 3 * i, &data32, 3);
} else if (op->BytesPerChannel == 2) { }
else if (op->BytesPerChannel == 2)
{
data16 = (pwr_tInt16)data32; data16 = (pwr_tInt16)data32;
if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian) if (slave->ByteOrdering == pwr_eByteOrderingEnum_BigEndian)
data16 = swap16(data16); data16 = swap16(data16);
memcpy(local->output_area + op->OffsetOutputs + 2 * i, &data16, 2); memcpy(local->output_area + op->OffsetOutputs + 2 * i, &data16, 2);
} else if (op->BytesPerChannel == 1) { }
else if (op->BytesPerChannel == 1)
{
data8 = (pwr_tInt8)data32; data8 = (pwr_tInt8)data32;
memcpy(local->output_area + op->OffsetOutputs + i, &data8, 1); memcpy(local->output_area + op->OffsetOutputs + i, &data8, 1);
} }
...@@ -130,8 +141,8 @@ static pwr_tStatus IoCardWrite( ...@@ -130,8 +141,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -145,6 +156,6 @@ static pwr_tStatus IoCardClose( ...@@ -145,6 +156,6 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Io) pwr_dExport pwr_BindIoMethods(Pb_Io) = {
= { pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardWrite),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod }; pwr_BindIoMethod(IoCardClose), pwr_NullMethod};
...@@ -52,8 +52,8 @@ ...@@ -52,8 +52,8 @@
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Init method for the Pb module Init method for the Pb module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardInit( static pwr_tStatus IoCardInit(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Module* op; pwr_sClass_Pb_Module* op;
...@@ -62,7 +62,8 @@ static pwr_tStatus IoCardInit( ...@@ -62,7 +62,8 @@ static pwr_tStatus IoCardInit(
op = (pwr_sClass_Pb_Module*)cp->op; op = (pwr_sClass_Pb_Module*)cp->op;
local = (io_sCardLocal*)cp->Local; local = (io_sCardLocal*)cp->Local;
for (i = 0; i < IO_MAXCHAN; i++) { for (i = 0; i < IO_MAXCHAN; i++)
{
local->scancount[i] = 0; local->scancount[i] = 0;
} }
...@@ -74,8 +75,8 @@ static pwr_tStatus IoCardInit( ...@@ -74,8 +75,8 @@ static pwr_tStatus IoCardInit(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Read method for the Pb module Read method for the Pb module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardRead( static pwr_tStatus IoCardRead(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Module* op; pwr_sClass_Pb_Module* op;
...@@ -92,7 +93,7 @@ static pwr_tStatus IoCardRead( ...@@ -92,7 +93,7 @@ static pwr_tStatus IoCardRead(
/* all inputs will be zeroed */ /* all inputs will be zeroed */
io_bus_card_read(ctx, rp, cp, local->input_area, slave->Diag, io_bus_card_read(ctx, rp, cp, local->input_area, slave->Diag,
slave->ByteOrdering, slave->FloatRepresentation); slave->ByteOrdering, slave->FloatRepresentation);
// printf("Method Pb_Module-IoCardRead\n"); // printf("Method Pb_Module-IoCardRead\n");
return IO__SUCCESS; return IO__SUCCESS;
...@@ -101,8 +102,8 @@ static pwr_tStatus IoCardRead( ...@@ -101,8 +102,8 @@ static pwr_tStatus IoCardRead(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Write method for the Pb module Write method for the Pb module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardWrite( static pwr_tStatus IoCardWrite(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
pwr_sClass_Pb_Module* op; pwr_sClass_Pb_Module* op;
...@@ -114,9 +115,10 @@ static pwr_tStatus IoCardWrite( ...@@ -114,9 +115,10 @@ static pwr_tStatus IoCardWrite(
op->Status = slave->Status; op->Status = slave->Status;
if (op->Status == PB__NORMAL) { if (op->Status == PB__NORMAL)
{
io_bus_card_write(ctx, cp, local->output_area, slave->ByteOrdering, io_bus_card_write(ctx, cp, local->output_area, slave->ByteOrdering,
slave->FloatRepresentation); slave->FloatRepresentation);
} }
// printf("Method Pb_Module-IoCardWrite\n"); // printf("Method Pb_Module-IoCardWrite\n");
return IO__SUCCESS; return IO__SUCCESS;
...@@ -125,8 +127,8 @@ static pwr_tStatus IoCardWrite( ...@@ -125,8 +127,8 @@ static pwr_tStatus IoCardWrite(
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Close method for the Pb module Close method for the Pb module
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoCardClose( static pwr_tStatus IoCardClose(io_tCtx ctx, io_sAgent* ap, io_sRack* rp,
io_tCtx ctx, io_sAgent* ap, io_sRack* rp, io_sCard* cp) io_sCard* cp)
{ {
io_sCardLocal* local; io_sCardLocal* local;
local = cp->Local; local = cp->Local;
...@@ -141,6 +143,7 @@ static pwr_tStatus IoCardClose( ...@@ -141,6 +143,7 @@ static pwr_tStatus IoCardClose(
Every method to be exported to the workbench should be registred here. Every method to be exported to the workbench should be registred here.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_dExport pwr_BindIoMethods(Pb_Module) = { pwr_BindIoMethod(IoCardInit), pwr_dExport pwr_BindIoMethods(Pb_Module) = {
pwr_BindIoMethod(IoCardRead), pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardInit), pwr_BindIoMethod(IoCardRead),
pwr_BindIoMethod(IoCardClose), pwr_NullMethod }; pwr_BindIoMethod(IoCardWrite), pwr_BindIoMethod(IoCardClose),
pwr_NullMethod};
This diff is collapsed.
...@@ -72,20 +72,23 @@ ...@@ -72,20 +72,23 @@
/* io_sAgentLocal now lives in the respective agent modules. */ /* io_sAgentLocal now lives in the respective agent modules. */
typedef struct _io_sRackLocal { typedef struct _io_sRackLocal
{
unsigned char fdl; unsigned char fdl;
unsigned char dp; unsigned char dp;
unsigned int start_time; unsigned int start_time;
unsigned int start_cnt; unsigned int start_cnt;
} io_sRackLocal; } io_sRackLocal;
typedef struct { typedef struct
{
void* input_area; void* input_area;
void* output_area; void* output_area;
int scancount[IO_MAXCHAN]; int scancount[IO_MAXCHAN];
} io_sCardLocal; } io_sCardLocal;
typedef struct { typedef struct
{
unsigned short invoke_id; unsigned short invoke_id;
unsigned short input_area_size; unsigned short input_area_size;
unsigned short output_area_size; unsigned short output_area_size;
...@@ -95,21 +98,24 @@ typedef struct { ...@@ -95,21 +98,24 @@ typedef struct {
unsigned short float_representation; unsigned short float_representation;
} io_sFDLCardLocal; } io_sFDLCardLocal;
typedef struct _agent_args { typedef struct _agent_args
{
void* local; void* local;
io_sAgent* ap; io_sAgent* ap;
io_tCtx ctx;
} agent_args; } agent_args;
typedef struct { typedef struct
int hServiceReadDevice; // Handle for Service device {
int hServiceWriteDevice; // Handle for Service device int hServiceReadDevice; // Handle for Service device
int hDpDataDevice; // Handle for DP-Data device int hServiceWriteDevice; // Handle for Service device
int hDpsInputDataDevice; // Handle for DP-Slave Input-Data device int hDpDataDevice; // Handle for DP-Data device
int hDpsInputDataDevice; // Handle for DP-Slave Input-Data device
int hDpsOutputDataDevice; // Handle for DP-Slave Output-Data device int hDpsOutputDataDevice; // Handle for DP-Slave Output-Data device
unsigned char CurrentBoardNumber; unsigned char CurrentBoardNumber;
int slave_diag_requested; // Slave diag requested int slave_diag_requested; // Slave diag requested
int parallel_service; // parallel activity int parallel_service; // parallel activity
int hDpsBoardDevice; // Handle for DP-Slave Output-Data device int hDpsBoardDevice; // Handle for DP-Slave Output-Data device
pthread_t events; pthread_t events;
pthread_mutex_t mutex; pthread_mutex_t mutex;
agent_args args; agent_args args;
......
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
/* rt_io_pn_locals.h -- Profinet io handling locals. */ /* rt_io_pn_locals.h -- Profinet io handling locals. */
typedef struct _io_sPnRackLocal { typedef struct _io_sPnRackLocal
{
unsigned short bytes_of_input; unsigned short bytes_of_input;
unsigned short bytes_of_output; unsigned short bytes_of_output;
unsigned char* inputs; unsigned char* inputs;
...@@ -49,7 +50,8 @@ typedef struct _io_sPnRackLocal { ...@@ -49,7 +50,8 @@ typedef struct _io_sPnRackLocal {
unsigned int start_cnt; unsigned int start_cnt;
} io_sPnRackLocal; } io_sPnRackLocal;
typedef struct _io_sPnCardLocal { typedef struct _io_sPnCardLocal
{
unsigned int input_area_size; unsigned int input_area_size;
unsigned int output_area_size; unsigned int output_area_size;
unsigned char* input_area; unsigned char* input_area;
......
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
/* rt_io_pnak_locals.h -- Profinet io handling locals. */ /* rt_io_pnak_locals.h -- Profinet io handling locals. */
typedef struct _PN_Alarm_Data { typedef struct _PN_Alarm_Data
{
unsigned short alarm_type; unsigned short alarm_type;
unsigned short alarm_prio; unsigned short alarm_prio;
unsigned short rem_alarms; unsigned short rem_alarms;
...@@ -58,12 +59,10 @@ typedef struct _PN_Alarm_Data { ...@@ -58,12 +59,10 @@ typedef struct _PN_Alarm_Data {
unsigned char* data; unsigned char* data;
} PN_Alarm_Data; } PN_Alarm_Data;
class PnApiData { class PnApiData
{
public: public:
PnApiData() PnApiData() : api(0) {}
: api(0)
{
}
unsigned int api; unsigned int api;
std::vector<unsigned int> module_index; std::vector<unsigned int> module_index;
...@@ -73,21 +72,19 @@ public: ...@@ -73,21 +72,19 @@ public:
int print(std::ofstream& fp); int print(std::ofstream& fp);
}; };
class PnIOCRData { class PnIOCRData
{
public: public:
PnIOCRData() PnIOCRData()
: type(0) : type(0), number_modules(0), identifier(0), io_data_length(0),
, number_modules(0) clean_io_data_length(0)
, identifier(0)
, io_data_length(0)
, clean_io_data_length(0)
{ {
} }
unsigned short type; unsigned short type;
unsigned short number_modules; unsigned short number_modules;
unsigned short identifier; unsigned short identifier;
unsigned short io_data_length; // bytes of io-data including status; unsigned short io_data_length; // bytes of io-data including status;
unsigned short clean_io_data_length; // bytes of io-data including status; unsigned short clean_io_data_length; // bytes of io-data including status;
unsigned char* io_data; unsigned char* io_data;
unsigned char* clean_io_data; unsigned char* clean_io_data;
...@@ -97,16 +94,12 @@ public: ...@@ -97,16 +94,12 @@ public:
int print(std::ofstream& fp); int print(std::ofstream& fp);
}; };
class PnSubmoduleData { class PnSubmoduleData
{
public: public:
PnSubmoduleData() PnSubmoduleData()
: subslot_number(0) : subslot_number(0), subslot_idx(0), type(0), state(0), ident_number(0),
, subslot_idx(0) phys_ident_number(0), api(0)
, type(0)
, state(0)
, ident_number(0)
, phys_ident_number(0)
, api(0)
{ {
} }
...@@ -118,29 +111,27 @@ public: ...@@ -118,29 +111,27 @@ public:
unsigned int phys_ident_number; unsigned int phys_ident_number;
unsigned int api; unsigned int api;
unsigned short io_in_data_length; // bytes of pure io-data unsigned short io_in_data_length; // bytes of pure io-data
unsigned short offset_io_in; // offset in io-data area for this iocr unsigned short offset_io_in; // offset in io-data area for this iocr
unsigned short offset_clean_io_in; // offset in io-data area for this iocr unsigned short offset_clean_io_in; // offset in io-data area for this iocr
unsigned short offset_status_in; // offset in io-data area for this iocr unsigned short offset_status_in; // offset in io-data area for this iocr
unsigned short io_out_data_length; // bytes of pure io-data unsigned short io_out_data_length; // bytes of pure io-data
unsigned short offset_io_out; // offset in io-data area for this iocr unsigned short offset_io_out; // offset in io-data area for this iocr
unsigned short offset_clean_io_out; // offset in io-data area for this iocr unsigned short offset_clean_io_out; // offset in io-data area for this iocr
unsigned short offset_status_out; // offset in io-data area for this iocr unsigned short offset_status_out; // offset in io-data area for this iocr
~PnSubmoduleData() {} ~PnSubmoduleData() {}
int print(std::ofstream& fp); int print(std::ofstream& fp);
}; };
class PnModuleData { class PnModuleData
{
public: public:
PnModuleData() PnModuleData()
: slot_number(0) : slot_number(0), slot_idx(0), state(0), ident_number(0),
, slot_idx(0) phys_ident_number(0)
, state(0)
, ident_number(0)
, phys_ident_number(0)
{ {
} }
...@@ -161,13 +152,11 @@ public: ...@@ -161,13 +152,11 @@ public:
int print(std::ofstream& fp); int print(std::ofstream& fp);
}; };
class PnDeviceData { class PnDeviceData
{
public: public:
PnDeviceData() PnDeviceData()
: device_ref(0) : device_ref(0), alarm_ref(0), device_state(0), no_diff_modules(0)
, alarm_ref(0)
, device_state(0)
, no_diff_modules(0)
{ {
memset(&alarm_data, 0, sizeof(PN_Alarm_Data)); memset(&alarm_data, 0, sizeof(PN_Alarm_Data));
} }
...@@ -182,10 +171,7 @@ public: ...@@ -182,10 +171,7 @@ public:
std::vector<PnModuleData*> module_data; std::vector<PnModuleData*> module_data;
std::vector<PnIOCRData*> iocr_data; std::vector<PnIOCRData*> iocr_data;
~PnDeviceData() ~PnDeviceData() { device_reset(); }
{
device_reset();
}
void device_reset() void device_reset()
{ {
for (unsigned int i = 0; i < module_data.size(); i++) for (unsigned int i = 0; i < module_data.size(); i++)
...@@ -201,7 +187,8 @@ public: ...@@ -201,7 +187,8 @@ public:
int paste_slot(unsigned int slot_idx); int paste_slot(unsigned int slot_idx);
}; };
class PnDeviceInfo { class PnDeviceInfo
{
public: public:
PnDeviceInfo() {} PnDeviceInfo() {}
unsigned char ipaddress[4]; unsigned char ipaddress[4];
...@@ -212,12 +199,14 @@ public: ...@@ -212,12 +199,14 @@ public:
int deviceid; int deviceid;
}; };
typedef struct _agent_args { typedef struct _agent_args
{
void* local; void* local;
io_sAgent* ap; io_sAgent* ap;
} agent_args; } agent_args;
class io_sAgentLocal { class io_sAgentLocal
{
public: public:
io_sAgentLocal() {} io_sAgentLocal() {}
......
...@@ -43,15 +43,12 @@ ...@@ -43,15 +43,12 @@
#include "co_xml_parser.h" #include "co_xml_parser.h"
class GsdmlDataRecord { class GsdmlDataRecord
{
public: public:
GsdmlDataRecord() GsdmlDataRecord()
: record_idx(0) : record_idx(0), data(0), data_reversed_endianess(0), data_length(0),
, data(0) index(0), transfer_sequence(0)
, data_reversed_endianess(0)
, data_length(0)
, index(0)
, transfer_sequence(0)
{ {
} }
...@@ -74,14 +71,11 @@ public: ...@@ -74,14 +71,11 @@ public:
int print(std::ofstream& fp, bool reverse_endianess); int print(std::ofstream& fp, bool reverse_endianess);
}; };
class GsdmlIOCRData { class GsdmlIOCRData
{
public: public:
GsdmlIOCRData() GsdmlIOCRData()
: type(0) : type(0), properties(0), send_clock_factor(0), phase(0), api(0)
, properties(0)
, send_clock_factor(0)
, phase(0)
, api(0)
{ {
} }
...@@ -95,16 +89,13 @@ public: ...@@ -95,16 +89,13 @@ public:
int print(std::ofstream& fp); int print(std::ofstream& fp);
}; };
class GsdmlSubslotData { class GsdmlSubslotData
{
public: public:
GsdmlSubslotData() GsdmlSubslotData()
: subslot_number(0) : subslot_number(0), subslot_idx(0), submodule_enum_number(0),
, subslot_idx(0) submodule_ident_number(0), api(0), io_input_length(0),
, submodule_enum_number(0) io_output_length(0)
, submodule_ident_number(0)
, api(0)
, io_input_length(0)
, io_output_length(0)
{ {
} }
...@@ -123,24 +114,22 @@ public: ...@@ -123,24 +114,22 @@ public:
delete data_record[i]; delete data_record[i];
} }
GsdmlSubslotData(const GsdmlSubslotData& x) GsdmlSubslotData(const GsdmlSubslotData& x)
: subslot_number(x.subslot_number) : subslot_number(x.subslot_number), subslot_idx(x.subslot_idx)
, subslot_idx(x.subslot_idx)
{ {
for (unsigned int i = 0; i < x.data_record.size(); i++) { for (unsigned int i = 0; i < x.data_record.size(); i++)
{
data_record.push_back(new GsdmlDataRecord(*x.data_record[i])); data_record.push_back(new GsdmlDataRecord(*x.data_record[i]));
} }
} }
int print(std::ofstream& fp, bool reverse_endianess); int print(std::ofstream& fp, bool reverse_endianess);
}; };
class GsdmlSlotData { class GsdmlSlotData
{
public: public:
GsdmlSlotData() GsdmlSlotData()
: module_enum_number(0) : module_enum_number(0), module_class(0), module_oid(pwr_cNOid),
, module_class(0) slot_number(0), slot_idx(0)
, module_oid(pwr_cNOid)
, slot_number(0)
, slot_idx(0)
{ {
module_text[0] = 0; module_text[0] = 0;
} }
...@@ -165,20 +154,20 @@ public: ...@@ -165,20 +154,20 @@ public:
subslot_data.clear(); subslot_data.clear();
} }
GsdmlSlotData(const GsdmlSlotData& x) GsdmlSlotData(const GsdmlSlotData& x)
: module_enum_number(x.module_enum_number) : module_enum_number(x.module_enum_number), module_class(x.module_class),
, module_class(x.module_class) module_oid(pwr_cNObjid), slot_number(x.slot_number),
, module_oid(pwr_cNObjid) slot_idx(x.slot_idx)
, slot_number(x.slot_number)
, slot_idx(x.slot_idx)
{ {
for (unsigned int i = 0; i < x.subslot_data.size(); i++) { for (unsigned int i = 0; i < x.subslot_data.size(); i++)
{
subslot_data.push_back(new GsdmlSubslotData(*x.subslot_data[i])); subslot_data.push_back(new GsdmlSubslotData(*x.subslot_data[i]));
} }
} }
int print(std::ofstream& fp, bool reverse_endianess); int print(std::ofstream& fp, bool reverse_endianess);
}; };
class GsdmlChannelDiag { class GsdmlChannelDiag
{
public: public:
GsdmlChannelDiag(); GsdmlChannelDiag();
unsigned short error_type; unsigned short error_type;
...@@ -189,15 +178,12 @@ public: ...@@ -189,15 +178,12 @@ public:
int print(std::ofstream& fp); int print(std::ofstream& fp);
}; };
class GsdmlDeviceData { class GsdmlDeviceData
{
public: public:
GsdmlDeviceData() GsdmlDeviceData()
: device_num(0) : device_num(0), vendor_id(0), device_id(0), byte_order(0),
, vendor_id(0) read_data_is_native_ordered(1), instance(0)
, device_id(0)
, byte_order(0)
, read_data_is_native_ordered(1)
, instance(0)
{ {
device_name[0] = 0; device_name[0] = 0;
ip_address[0] = 0; ip_address[0] = 0;
...@@ -254,13 +240,10 @@ public: ...@@ -254,13 +240,10 @@ public:
int get_value(const char* attr, char* buf, int bufsize); int get_value(const char* attr, char* buf, int bufsize);
}; };
class GsdmlDataReader : public co_xml_interpreter { class GsdmlDataReader : public co_xml_interpreter
{
public: public:
GsdmlDataReader(GsdmlDeviceData* d) GsdmlDataReader(GsdmlDeviceData* d) : data(d), new_filename(0) {}
: data(d)
, new_filename(0)
{
}
int tag(const char* name); int tag(const char* name);
int metatag(const char* name); int metatag(const char* name);
int tag_end(const char* name); int tag_end(const char* name);
......
...@@ -47,42 +47,42 @@ ...@@ -47,42 +47,42 @@
#define PN_MAX_MANU_SPEC_DIAGS 200 #define PN_MAX_MANU_SPEC_DIAGS 200
void pack_set_ip_settings_req( void pack_set_ip_settings_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
T_PNAK_SERVICE_REQ_RES* ServiceReqRes, PnDeviceInfo* dev_info); PnDeviceInfo* dev_info);
void pack_set_device_name_req( void pack_set_device_name_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
T_PNAK_SERVICE_REQ_RES* ServiceReqRes, PnDeviceInfo* dev_info); PnDeviceInfo* dev_info);
void pack_set_identification_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes); void pack_set_identification_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes);
void pack_get_device_state_req( void pack_get_device_state_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
T_PNAK_SERVICE_REQ_RES* ServiceReqRes, unsigned short device_ref); unsigned short device_ref);
void pack_write_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, void pack_write_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
unsigned short device_ref, pwr_sClass_PnWriteReq* wr_req); unsigned short device_ref, pwr_sClass_PnWriteReq* wr_req);
void pack_get_los_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes); void pack_get_los_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes);
void pack_get_alarm_req( void pack_get_alarm_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
T_PNAK_SERVICE_REQ_RES* ServiceReqRes, unsigned short ref); unsigned short ref);
void pack_alarm_ack_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, void pack_alarm_ack_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
unsigned short ref, unsigned short prio); unsigned short ref, unsigned short prio);
void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes, void pack_download_req(T_PNAK_SERVICE_REQ_RES* ServiceReqRes,
GsdmlDeviceData* dev_data, unsigned short device_ref); GsdmlDeviceData* dev_data, unsigned short device_ref);
int unpack_write_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local); int unpack_write_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local);
int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local); int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local);
int unpack_get_alarm_con( int unpack_get_alarm_con(T_PNAK_SERVICE_DESCRIPTION* pSdb,
T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local, io_sAgent* ap); io_sAgentLocal* local, io_sAgent* ap);
int unpack_get_device_state_con( int unpack_get_device_state_con(T_PNAK_SERVICE_DESCRIPTION* pSdb,
T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local, io_sAgent* ap); io_sAgentLocal* local, io_sAgent* ap);
int unpack_download_con( int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb,
T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal* local); io_sAgentLocal* local);
int handle_service_con(io_sAgentLocal* local, io_sAgent* ap); int handle_service_con(io_sAgentLocal* local, io_sAgent* ap);
......
This diff is collapsed.
This diff is collapsed.
/*
* ProviewR Open Source Process Control.
* Copyright (C) 2005-2019 SSAB EMEA AB.
*
* This file is part of ProviewR.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProviewR. If not, see <http://www.gnu.org/licenses/>
*
* Linking ProviewR statically or dynamically with other modules is
* making a combined work based on ProviewR. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* ProviewR give you permission to, from the build function in the
* ProviewR Configurator, combine ProviewR with modules generated by the
* ProviewR PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of ProviewR (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/*****************************************************************************/ /*****************************************************************************/
/* */ /* */
/* SOFTING AG */ /* SOFTING AG */
......
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