Commit 39f8971d authored by claes's avatar claes

Merge branch 'master' of 62.20.65.89:/data1/git/pwr

parents 8135fea8 93679d5b
...@@ -107,7 +107,8 @@ static pwr_tStatus IoAgentClose ( ...@@ -107,7 +107,8 @@ static pwr_tStatus IoAgentClose (
); );
static pwr_tStatus IoAgentSwap ( static pwr_tStatus IoAgentSwap (
io_tCtx ctx, io_tCtx ctx,
io_sAgent *ap io_sAgent *ap,
io_eEvent event
); );
...@@ -784,9 +785,14 @@ static pwr_tStatus IoAgentInit ( ...@@ -784,9 +785,14 @@ static pwr_tStatus IoAgentInit (
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
static pwr_tStatus IoAgentSwap ( static pwr_tStatus IoAgentSwap (
io_tCtx ctx, io_tCtx ctx,
io_sAgent *ap io_sAgent *ap,
io_eEvent event
) )
{ {
switch ( event) {
case io_eEvent_IoCommSwapInit:
case io_eEvent_IoCommSwap: {
pwr_sClass_Pb_Profiboard *op; pwr_sClass_Pb_Profiboard *op;
char DeviceName[64]; char DeviceName[64];
io_sAgentLocal *local; io_sAgentLocal *local;
...@@ -813,6 +819,14 @@ static pwr_tStatus IoAgentSwap ( ...@@ -813,6 +819,14 @@ static pwr_tStatus IoAgentSwap (
return IO__ERRINIDEVICE; return IO__ERRINIDEVICE;
} }
} }
break;
}
case io_eEvent_EmergencyBreak:
case io_eEvent_IoCommEmergencyBreak:
IoAgentClose( ctx, ap);
break;
}
return IO__SUCCESS; return IO__SUCCESS;
} }
......
...@@ -405,6 +405,7 @@ struct sLocal { ...@@ -405,6 +405,7 @@ struct sLocal {
sNodeInfo nodeDb[cNodes]; sNodeInfo nodeDb[cNodes];
pwr_tBoolean outunitServer; pwr_tBoolean outunitServer;
pwr_sClass_IOHandler *iohp; pwr_sClass_IOHandler *iohp;
pwr_sNode *nodep;
}; };
/* Global variables */ /* Global variables */
...@@ -1253,6 +1254,7 @@ cSup_exec ( ...@@ -1253,6 +1254,7 @@ cSup_exec (
o->DelayNoted = TRUE; o->DelayNoted = TRUE;
if (o->DelayAction == 2) { if (o->DelayAction == 2) {
l.iohp->IOReadWriteFlag = FALSE; l.iohp->IOReadWriteFlag = FALSE;
l.nodep->EmergBreakTrue = TRUE;
errh_SetStatus( MH__IOSTALLED); errh_SetStatus( MH__IOSTALLED);
} }
} }
...@@ -1996,6 +1998,7 @@ getHandlerObject () ...@@ -1996,6 +1998,7 @@ getHandlerObject ()
pwr_sAttrRef aref; pwr_sAttrRef aref;
pwr_tDlid dlid; pwr_tDlid dlid;
pwr_tBoolean created = FALSE; pwr_tBoolean created = FALSE;
pwr_tOid node_oid;
sts = gdh_GetClassList(pwr_eClass_Node, &nodeOid); sts = gdh_GetClassList(pwr_eClass_Node, &nodeOid);
if (EVEN(sts)) { if (EVEN(sts)) {
...@@ -2100,6 +2103,13 @@ getHandlerObject () ...@@ -2100,6 +2103,13 @@ getHandlerObject ()
l.iohp = NULL; l.iohp = NULL;
gdh_ObjidToPointer(oid, (void *) &l.iohp); gdh_ObjidToPointer(oid, (void *) &l.iohp);
sts = gdh_GetNodeObject( 0, &node_oid);
if (ODD(sts))
sts = gdh_ObjidToPointer( node_oid, (void **)&l.nodep);
if (EVEN(sts)) {
errh_Fatal("No node object found\n%m", sts);
exit(sts);
}
} }
static mh_eAgent static mh_eAgent
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
EVENT io_comm_terminate; EVENT io_comm_terminate;
#endif #endif
static pwr_sClass_IOHandler* init(qcom_sQid*, lst_sEntry**); static pwr_sClass_IOHandler* init(qcom_sQid*, lst_sEntry**, pwr_sNode**);
static void usage() static void usage()
{ {
...@@ -100,6 +100,8 @@ int main (int argc, char **argv) ...@@ -100,6 +100,8 @@ int main (int argc, char **argv)
pwr_tDeltaTime cycle; pwr_tDeltaTime cycle;
lst_sEntry *csup_lh; lst_sEntry *csup_lh;
int delay_action = 0; int delay_action = 0;
pwr_sNode *nodep;
pwr_tBoolean old_emergency_break = 0;
if ( argc > 1) { if ( argc > 1) {
if ( strcmp( argv[1], "-m") == 0) { if ( strcmp( argv[1], "-m") == 0) {
...@@ -112,7 +114,7 @@ int main (int argc, char **argv) ...@@ -112,7 +114,7 @@ int main (int argc, char **argv)
} }
} }
ihp = init(&qid, &csup_lh); ihp = init(&qid, &csup_lh, &nodep);
plc_UtlWaitForPlc(); plc_UtlWaitForPlc();
...@@ -147,12 +149,27 @@ int main (int argc, char **argv) ...@@ -147,12 +149,27 @@ int main (int argc, char **argv)
qcom_Get(&sts,&qid, &get, tmo); qcom_Get(&sts,&qid, &get, tmo);
if (sts == QCOM__TMO || sts == QCOM__QEMPTY) { if (sts == QCOM__TMO || sts == QCOM__QEMPTY) {
if ( nodep->EmergBreakTrue && !old_emergency_break)
sts = io_swap(io_ctx_swap, io_eEvent_IoCommEmergencyBreak);
sts = io_read(io_ctx); sts = io_read(io_ctx);
if (EVEN(sts)) {
ihp->IOReadWriteFlag = FALSE;
errh_Error("IO read, %m", sts);
}
sts = io_write(io_ctx); sts = io_write(io_ctx);
if (EVEN(sts)) {
ihp->IOReadWriteFlag = FALSE;
errh_Error("IO write, %m", sts);
}
if ( nodep->EmergBreakTrue && !old_emergency_break)
sts = io_swap(io_ctx, io_eEvent_EmergencyBreak);
old_emergency_break = nodep->EmergBreakTrue;
if (swap_io) if (swap_io)
{ {
sts = io_swap(io_ctx_swap); sts = io_swap(io_ctx_swap, io_eEvent_IoCommSwap);
} }
io_ScanSupLst( io_ctx->SupCtx); io_ScanSupLst( io_ctx->SupCtx);
...@@ -193,13 +210,14 @@ int main (int argc, char **argv) ...@@ -193,13 +210,14 @@ int main (int argc, char **argv)
} }
static pwr_sClass_IOHandler * static pwr_sClass_IOHandler *
init (qcom_sQid *qid, lst_sEntry **csup_lh) init (qcom_sQid *qid, lst_sEntry **csup_lh, pwr_sNode **nodep)
{ {
pwr_tStatus sts = 1; pwr_tStatus sts = 1;
pwr_sClass_IOHandler *ihp; pwr_sClass_IOHandler *ihp;
qcom_sQattr qAttr; qcom_sQattr qAttr;
qcom_sQid qini; qcom_sQid qini;
pwr_tObjid oid; pwr_tOid oid;
pwr_tOid node_oid;
errh_Init("pwr_io", errh_eAnix_io); errh_Init("pwr_io", errh_eAnix_io);
...@@ -238,6 +256,18 @@ init (qcom_sQid *qid, lst_sEntry **csup_lh) ...@@ -238,6 +256,18 @@ init (qcom_sQid *qid, lst_sEntry **csup_lh)
exit(sts); exit(sts);
} }
sts = gdh_GetNodeObject( 0, &node_oid);
if (EVEN(sts)) {
errh_Fatal("rt_io_comm aborted, no node object found\n%m", sts);
exit(sts);
}
sts = gdh_ObjidToPointer( node_oid, (void **)nodep);
if (EVEN(sts)) {
errh_Fatal("rt_io_comm aborted, no node object found\n%m", sts);
exit(sts);
}
aproc_RegisterObject( oid); aproc_RegisterObject( oid);
*csup_lh = csup_Init(&sts, oid, ihp->CycleTimeBus); *csup_lh = csup_Init(&sts, oid, ihp->CycleTimeBus);
......
...@@ -2143,7 +2143,7 @@ static pwr_tStatus io_init_agent( ...@@ -2143,7 +2143,7 @@ static pwr_tStatus io_init_agent(
io_tCtx ctx, io_tCtx ctx,
void *dummy, void *dummy,
int agent_type, int agent_type,
int swap) int iocomm_swap)
{ {
pwr_tStatus sts; pwr_tStatus sts;
pwr_tClassId class; pwr_tClassId class;
...@@ -2181,7 +2181,7 @@ static pwr_tStatus io_init_agent( ...@@ -2181,7 +2181,7 @@ static pwr_tStatus io_init_agent(
strcat( attrname, ".Process"); strcat( attrname, ".Process");
sts = gdh_GetObjectInfo( attrname, &process, sizeof(process)); sts = gdh_GetObjectInfo( attrname, &process, sizeof(process));
if (( EVEN(sts) || if (( EVEN(sts) ||
(ODD(sts) && ctx->Process & process)) && !swap) { (ODD(sts) && ctx->Process & process)) && !iocomm_swap) {
if ( EVEN(sts)) if ( EVEN(sts))
process = io_mProcess_All; process = io_mProcess_All;
if ( ctx->Process == io_mProcess_Profibus) if ( ctx->Process == io_mProcess_Profibus)
...@@ -2199,7 +2199,7 @@ static pwr_tStatus io_init_agent( ...@@ -2199,7 +2199,7 @@ static pwr_tStatus io_init_agent(
else else
ok = 1; ok = 1;
} }
else if (ODD(sts) && swap && AgentSwap != NULL) { else if (ODD(sts) && iocomm_swap && AgentSwap != NULL) {
/* IoComm-process should always handle the Swap-method */ /* IoComm-process should always handle the Swap-method */
ok = 1; ok = 1;
} }
...@@ -2213,11 +2213,13 @@ static pwr_tStatus io_init_agent( ...@@ -2213,11 +2213,13 @@ static pwr_tStatus io_init_agent(
ap->Objid = objid; ap->Objid = objid;
strcpy( ap->Name, aname); strcpy( ap->Name, aname);
ap->Process = process; ap->Process = process;
if (!swap) { if (!iocomm_swap) {
if ( AgentRead != NULL) if ( AgentRead != NULL)
ap->Action |= io_mAction_Read; ap->Action |= io_mAction_Read;
if ( AgentWrite != NULL) if ( AgentWrite != NULL)
ap->Action |= io_mAction_Write; ap->Action |= io_mAction_Write;
if ( AgentSwap != NULL)
ap->Action |= io_mAction_Swap;
ap->Init = AgentInit; ap->Init = AgentInit;
ap->Close = AgentClose; ap->Close = AgentClose;
ap->Read = AgentRead; ap->Read = AgentRead;
...@@ -2252,7 +2254,7 @@ static pwr_tStatus io_init_agent( ...@@ -2252,7 +2254,7 @@ static pwr_tStatus io_init_agent(
alp->next = ap; alp->next = ap;
} }
sts = io_trv_child( objid, 0, io_init_rack, ctx, ap, agent_type, swap); sts = io_trv_child( objid, 0, io_init_rack, ctx, ap, agent_type, iocomm_swap);
} }
} }
} }
...@@ -2646,7 +2648,7 @@ pwr_tStatus io_init_swap ( ...@@ -2646,7 +2648,7 @@ pwr_tStatus io_init_swap (
{ {
if (ap->Action & io_mAction_Swap) if (ap->Action & io_mAction_Swap)
{ {
sts = (ap->Swap) ( *ctx, ap); sts = (ap->Swap) ( *ctx, ap, io_eEvent_IoCommSwapInit);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
} }
} }
...@@ -2798,59 +2800,42 @@ pwr_tStatus io_write( ...@@ -2798,59 +2800,42 @@ pwr_tStatus io_write(
Swap io racks and cards. Swap io racks and cards.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
pwr_tStatus io_swap( pwr_tStatus io_swap(
io_tCtx ctx) io_tCtx ctx,
io_eEvent event)
{ {
pwr_tStatus sts; pwr_tStatus sts;
io_sAgent *ap; io_sAgent *ap;
io_sRack *rp; io_sRack *rp;
io_sCard *cp; io_sCard *cp;
switch ( event) {
case io_eEvent_EmergencyBreak:
case io_eEvent_IoCommEmergencyBreak:
break;
default:
if ( ctx->Node->EmergBreakTrue || !ctx->IOHandler->IOReadWriteFlag) if ( ctx->Node->EmergBreakTrue || !ctx->IOHandler->IOReadWriteFlag)
return IO__IS_STOPPED; return IO__IS_STOPPED;
}
/* Call the read methods for agents, racks and cards */ /* Call the read methods for agents, racks and cards */
for ( ap = ctx->agentlist; ap != NULL; ap = ap->next) for ( ap = ctx->agentlist; ap != NULL; ap = ap->next) {
{ if (ap->Action & io_mAction_Swap) {
if (ap->Action & io_mAction_Swap) sts = (ap->Swap) ( ctx, ap, event);
{
if ( ap->scan_interval_cnt <= 1)
{
sts = (ap->Swap) ( ctx, ap);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
ap->scan_interval_cnt = ap->scan_interval;
}
else
ap->scan_interval_cnt--;
} }
for ( rp = ap->racklist; rp != NULL; rp = rp->next) for ( rp = ap->racklist; rp != NULL; rp = rp->next) {
{
if (rp->Action & io_mAction_Swap && if (rp->Action & io_mAction_Swap &&
!rp->MethodDisabled) !rp->MethodDisabled) {
{ sts = (rp->Swap) ( ctx, ap, rp, event);
if ( rp->scan_interval_cnt <= 1)
{
sts = (rp->Swap) ( ctx, ap, rp);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
rp->scan_interval_cnt = rp->scan_interval;
}
else
rp->scan_interval_cnt--;
} }
for ( cp = rp->cardlist; cp != NULL; cp = cp->next) for ( cp = rp->cardlist; cp != NULL; cp = cp->next) {
{
if (cp->Action & io_mAction_Swap && if (cp->Action & io_mAction_Swap &&
!cp->MethodDisabled) !cp->MethodDisabled) {
{ sts = (cp->Swap) ( ctx, ap, rp, cp, event);
if ( cp->scan_interval_cnt <= 1)
{
sts = (cp->Swap) ( ctx, ap, rp, cp);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
cp->scan_interval_cnt = cp->scan_interval;
}
else
cp->scan_interval_cnt--;
} }
} }
} }
......
...@@ -105,6 +105,13 @@ typedef enum { ...@@ -105,6 +105,13 @@ typedef enum {
io_mProcess_All = ~0 io_mProcess_All = ~0
} io_mProcess; } io_mProcess;
typedef enum {
io_eEvent_EmergencyBreak,
io_eEvent_IoCommEmergencyBreak,
io_eEvent_IoCommSwapInit,
io_eEvent_IoCommSwap
} io_eEvent;
typedef struct { typedef struct {
void *cop; /* Pointer to channel object */ void *cop; /* Pointer to channel object */
pwr_tDlid ChanDlid; /* Dlid for pointer to channel */ pwr_tDlid ChanDlid; /* Dlid for pointer to channel */
...@@ -245,7 +252,8 @@ pwr_tStatus io_write( ...@@ -245,7 +252,8 @@ pwr_tStatus io_write(
); );
pwr_tStatus io_swap( pwr_tStatus io_swap(
io_tCtx ctx io_tCtx ctx,
io_eEvent event
); );
pwr_tStatus io_close( pwr_tStatus io_close(
......
...@@ -172,6 +172,7 @@ struct plc_sThread { ...@@ -172,6 +172,7 @@ struct plc_sThread {
io_tCtx plc_io_ctx; io_tCtx plc_io_ctx;
pwr_tBoolean first_scan; pwr_tBoolean first_scan;
int skip_count; int skip_count;
pwr_tBoolean emergency_break_old;
}; };
struct plc_sProcess { struct plc_sProcess {
......
...@@ -250,6 +250,9 @@ scan ( ...@@ -250,6 +250,9 @@ scan (
errh_SetStatus( PLC__IOREAD); errh_SetStatus( PLC__IOREAD);
} }
} }
if ( pp->Node->EmergBreakTrue && !tp->emergency_break_old)
io_swap(tp->plc_io_ctx, io_eEvent_EmergencyBreak);
tp->emergency_break_old = pp->Node->EmergBreakTrue;
thread_MutexLock(&pp->io_copy_mutex); thread_MutexLock(&pp->io_copy_mutex);
...@@ -307,6 +310,7 @@ scan ( ...@@ -307,6 +310,7 @@ scan (
delay_action = csup_Exec(&sts, tp->csup_lh, (pwr_tDeltaTime *) &tp->sync_time, (pwr_tDeltaTime *) &tp->after_scan, &now); delay_action = csup_Exec(&sts, tp->csup_lh, (pwr_tDeltaTime *) &tp->sync_time, (pwr_tDeltaTime *) &tp->after_scan, &now);
if (delay_action == 2) { if (delay_action == 2) {
pp->IOHandler->IOReadWriteFlag = FALSE; pp->IOHandler->IOReadWriteFlag = FALSE;
pp->Node->EmergBreakTrue = TRUE;
errh_SetStatus( PLC__IOSTALLED); errh_SetStatus( PLC__IOSTALLED);
} }
} }
......
...@@ -84,11 +84,16 @@ static pwr_tStatus IoRackInit ( ...@@ -84,11 +84,16 @@ static pwr_tStatus IoRackInit (
static pwr_tStatus IoRackSwap ( static pwr_tStatus IoRackSwap (
io_tCtx ctx, io_tCtx ctx,
io_sAgent *ap, io_sAgent *ap,
io_sRack *rp io_sRack *rp,
io_eEvent event
) )
{ {
io_sRackLocal *local; io_sRackLocal *local;
switch ( event) {
case io_eEvent_IoCommSwapInit:
case io_eEvent_IoCommSwap:
if (!rp->Local) { if (!rp->Local) {
/* Open Qbus driver */ /* Open Qbus driver */
local = calloc( 1, sizeof(*local)); local = calloc( 1, sizeof(*local));
...@@ -103,6 +108,9 @@ static pwr_tStatus IoRackSwap ( ...@@ -103,6 +108,9 @@ static pwr_tStatus IoRackSwap (
errh_Info( "Swap init of IO rack %s", rp->Name); errh_Info( "Swap init of IO rack %s", rp->Name);
} }
default: ;
}
return 1; return 1;
} }
......
...@@ -278,7 +278,8 @@ static pwr_tStatus IoCardSwap ( ...@@ -278,7 +278,8 @@ static pwr_tStatus IoCardSwap (
io_tCtx ctx, io_tCtx ctx,
io_sAgent *ap, io_sAgent *ap,
io_sRack *rp, io_sRack *rp,
io_sCard *cp io_sCard *cp,
io_eEvent event
) )
{ {
io_sLocal *local; io_sLocal *local;
...@@ -289,6 +290,9 @@ static pwr_tStatus IoCardSwap ( ...@@ -289,6 +290,9 @@ static pwr_tStatus IoCardSwap (
qbus_io_read rb; qbus_io_read rb;
int sts; int sts;
switch ( event) {
case io_eEvent_IoCommSwapInit:
case io_eEvent_IoCommSwap:
op = (pwr_sClass_Ssab_BaseDoCard *) cp->op; op = (pwr_sClass_Ssab_BaseDoCard *) cp->op;
if (!cp->Local) { if (!cp->Local) {
...@@ -300,8 +304,7 @@ static pwr_tStatus IoCardSwap ( ...@@ -300,8 +304,7 @@ static pwr_tStatus IoCardSwap (
local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp; local->Qbus_fp = ((io_sRackLocal *)(rp->Local))->Qbus_fp;
} }
for ( i = 0; i < 2; i++) for ( i = 0; i < 2; i++) {
{
if (r_local->Qbus_fp != 0 && r_local->s == 0) { if (r_local->Qbus_fp != 0 && r_local->s == 0) {
/* Write to local Q-bus */ /* Write to local Q-bus */
rb.Address = local->Address[i]; rb.Address = local->Address[i];
...@@ -315,6 +318,9 @@ static pwr_tStatus IoCardSwap ( ...@@ -315,6 +318,9 @@ static pwr_tStatus IoCardSwap (
sts = 1; sts = 1;
} }
}
break;
default: ;
} }
return 1; return 1;
} }
......
...@@ -209,7 +209,9 @@ static pwr_tStatus IoRackInit ( ...@@ -209,7 +209,9 @@ static pwr_tStatus IoRackInit (
static pwr_tStatus IoRackSwap ( static pwr_tStatus IoRackSwap (
io_tCtx ctx, io_tCtx ctx,
io_sAgent *ap, io_sAgent *ap,
io_sRack *rp io_sRack *rp,
io_eEvent event
) )
{ {
io_sRackLocal *local; io_sRackLocal *local;
...@@ -220,6 +222,10 @@ static pwr_tStatus IoRackSwap ( ...@@ -220,6 +222,10 @@ static pwr_tStatus IoRackSwap (
struct bfb_buf rbuf; struct bfb_buf rbuf;
int size; int size;
switch ( event) {
case io_eEvent_IoCommSwapInit:
case io_eEvent_IoCommSwap:
if (!rp->Local) { if (!rp->Local) {
sts = IoRackInitSwap(ctx, ap, rp); sts = IoRackInitSwap(ctx, ap, rp);
...@@ -258,6 +264,9 @@ static pwr_tStatus IoRackSwap ( ...@@ -258,6 +264,9 @@ static pwr_tStatus IoRackSwap (
op->RX_packets++; op->RX_packets++;
} }
} }
break;
default: ;
}
return IO__SUCCESS; return IO__SUCCESS;
......
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