Commit 309323a4 authored by Claes Sjofors's avatar Claes Sjofors

Redundance communication 3

parent ab6bf4ff
......@@ -2822,6 +2822,8 @@ ODD() <LINK> ODD()
get_language() <LINK> get_language()
GetUser() <LINK> getuser()
GetPrivileges() <LINK> getprivileges()
GetGraphInstance() <LINK> getgraphinstance()
GetGraphInstanceNext() <LINK> getgraphinstancenext()
<h2>xtt-commands
xtt-commands <LINK> xtt-commands
......@@ -4044,6 +4046,8 @@ ODD() <t>Check if value is odd. <LINK> ODD()
get_language() <t>Get the current language <LINK> get_language()
GetUser() <t>Get the current user. <LINK> getuser()
GetPrivileges() <t>Get the privileges for the current user. <LINK> getprivileges()
GetGraphInstance() <t>Get the instance object for a graph. <LINK> getgraphinstance()
GetGraphInstanceNext() <t>Get the instance object for next graph. <LINK> getgraphinstancenext()
</TOPIC>
<headerlevel>
......@@ -4287,6 +4291,58 @@ Get the privileges for the current user.
<c> endif
</TOPIC>
<TOPIC> getgraphinstance() <style> function
GetGraphInstance()
string GetGraphInstance( string graph)
<b>Description
Get the instance object for an open object graph.
Returns the instance object, or an empty string if the
graph is node open.
<b>Arguments
string <t>graph <t>Graph file name.
<b>Example
<c> string instance;
<c> instance = GetGraphInstance( "$pwr_exe/pwr_c_dv.pwg");
</TOPIC>
<TOPIC> getgraphinstancenext() <style> function
GetGraphInstanceNext()
string GetGraphInstanceNext( string graph, string previous)
<b>Description
Get the next instance object for the specified object graph.
Used when several versions of the same object graph is open for
different objects.
Returns the instance object, or an empty string if there is
no next instance.
<b>Arguments
string <t>graph <t>Graph file name.
string <t>previous <t>Previous instance.
<b>Example
<c> string instance;
<c> instance = GetGraphInstance( "$pwr_exe/pwr_c_dv.pwg");
<c> while ( instance != "")
<c> printf( "Instance %s\n", instance);
<c> instance = GetGraphInstanceNext( "$pwr_exe/pwr_c_dv.pwg", instance);
<c> endwile
</TOPIC>
</headerlevel>
<TOPIC> xtt-commands <style> function
......
......@@ -148,7 +148,6 @@ struct s_Appl {
struct s_Active {
LstLink(sActive) active_l; /* Link in active list */
LstLink(sActive) activeIdx_l; /* Link in active index list */
pwr_tUInt32 idx; /* Event index of alarm */
pwr_tUInt32 returnIdx; /* Event index of return message */
pwr_tUInt32 ackIdx; /* Event index of ack message */
......@@ -205,7 +204,6 @@ union u_Event {
struct s_Event {
pwr_tUInt32 idx;
LstHead(sActive) activeIdx_l;
pwr_tObjid outunit;
pwr_tAttrRef object;
pwr_tAName objName;
......@@ -673,15 +671,13 @@ activeListGet (
pwr_tUInt32 idx
)
{
LstLink(sActive) *al;
LstHead(sActive) *ll;
ll = (LstHead(sActive) *)&l.event_l->list[idx % l.event_l->size].activeIdx_l;
for (al = (LstLink(sActive) *)LstFir(ll); al != LstEnd(ll); al = LstNex(al))
if (idx == LstObj(al)->idx)
return LstObj(al);
sEventTab *etp;
pwr_tStatus sts;
etp = tree_Find(&sts, l.eventTab, &idx);
if ( etp)
return etp->ap;
return NULL;
}
......@@ -695,17 +691,26 @@ activeListInsert (
mh_eSource source
)
{
int inserted;
LstLink(sActive) *al;
LstLink(sBlock) *bl;
/* Check that not already inserted */
inserted = 0;
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l) ; al = LstNex(al)) {
if ( ap == LstObj(al)) {
inserted = 1;
break;
}
}
ap->idx = ep->idx;
ap->source = source;
al = LstEnd(&l.active_l);
LstIns(al, ap, active_l);
al = LstEnd(&ep->activeIdx_l);
LstIns(al, ap, activeIdx_l);
if ( !inserted) {
al = LstEnd(&l.active_l);
LstIns(al, ap, active_l);
}
switch (ap->event) {
case mh_eEvent_Alarm:
......@@ -744,10 +749,11 @@ activeListRemove (
sApplActive *aap;
sBlock *bp;
if ( LstIsNul(&ap->active_l))
return;
LstRem(&ap->active_l);
LstNul(&ap->active_l);
LstRem(&ap->activeIdx_l);
LstNul(&ap->activeIdx_l);
ap->idx = 0;
ap->ackIdx = 0;
ap->returnIdx = 0;
......@@ -814,7 +820,6 @@ activeListRemove (
else
handlerListFree((sApplActive*)ap);
}
}
static void
......@@ -1280,6 +1285,9 @@ sendAlarmStatus( sOutunit *op)
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l); al = LstNex(al)) {
ap = LstObj(al);
if ( !ap->detect_etp)
continue;
switch (ap->detect_etp->event) {
case mh_eEvent_Info:
case mh_eEvent_InfoSuccess:
......@@ -1294,9 +1302,9 @@ sendAlarmStatus( sOutunit *op)
ep = ap->detect_etp->ep;
if ( ap->detect_etp->event == mh_eEvent_Info || ap->detect_etp->event == mh_eEvent_InfoSuccess) {
if ( !(ep->msg.info.EventFlags & mh_mEventFlags_InfoWindow))
if ( ep && !(ep->msg.info.EventFlags & mh_mEventFlags_InfoWindow))
break;
if ( ep->msg.info.EventFlags & mh_mEventFlags_InfoWindow &&
if ( ep && ep->msg.info.EventFlags & mh_mEventFlags_InfoWindow &&
( !(ep->msg.info.EventFlags & mh_mEventFlags_Ack) ||
!(ep->msg.info.EventFlags & mh_mEventFlags_Return)))
break;
......@@ -1338,9 +1346,9 @@ sendAlarmStatus( sOutunit *op)
ep = ap->detect_etp->ep;
if ( ap->detect_etp->event == mh_eEvent_Info || ap->detect_etp->event == mh_eEvent_InfoSuccess) {
if ( !(ep->msg.info.EventFlags & mh_mEventFlags_InfoWindow))
if ( ep && !(ep->msg.info.EventFlags & mh_mEventFlags_InfoWindow))
break;
if ( ep->msg.info.EventFlags & mh_mEventFlags_InfoWindow &&
if ( ep && ep->msg.info.EventFlags & mh_mEventFlags_InfoWindow &&
( !(ep->msg.info.EventFlags & mh_mEventFlags_Ack) ||
!(ep->msg.info.EventFlags & mh_mEventFlags_Return)))
break;
......@@ -1559,7 +1567,6 @@ enableQcomAllHandlers (
static void
eventListInit ()
{
int i;
l.event_l = (sEventList*) calloc(1, sizeof(sEventList) +
sizeof(sEvent) * l.emon->EventListSize);
......@@ -1571,10 +1578,6 @@ eventListInit ()
l.event_l->oldIdx = 0;
l.event_l->size = l.emon->EventListSize;
/* Initialize all alarm index lists */
for (i = 0; i <= l.event_l->size; i++)
LstIni(&l.event_l->list[i].activeIdx_l);
}
static sEvent *
......@@ -1672,6 +1675,7 @@ eventListInsert (
errh_Error("eventListInsert, programming error, source: %d", ap->source);
break;
}
// printf( "** eventListInsert %s ap: %u\n", ep->objName, (unsigned int)ep->etp->ap);
return ep;
}
......@@ -3552,6 +3556,8 @@ outunitAck (
return;
}
printf( "** Acked %s %u\n", ap->objName, (unsigned int)ap->status.Event.Status);
switch (ap->source) {
case mh_eSource_Scanner:
sp = (sSupActive*) ap;
......@@ -3830,6 +3836,10 @@ outunitAlarmReq (
ap = LstObj(al);
if ( ap->idx == msg->Idx[i]) {
if ( !ap->detect_etp->ap)
/* Not active any more, don't resend */
break;
ok = reSendEventToOutunit( op, ap->detect_etp);
#if 0
if (ap->detect_etp->ep != NULL)
......@@ -3844,6 +3854,7 @@ outunitAlarmReq (
op->maxIdx = l.event_l->idx;
op->check = 0;
}
break;
}
}
}
......@@ -4927,6 +4938,12 @@ typedef struct {
pwr_tTime detectTime;
pwr_tTime returnTime;
pwr_tTime ackTime;
pwr_tUInt32 detect_etp;
pwr_tUInt32 return_etp;
pwr_tUInt32 ack_etp;
pwr_tUInt32 detect_event;
pwr_tUInt32 return_event;
pwr_tUInt32 ack_event;
} redu_sEvActive;
typedef struct {
......@@ -4966,8 +4983,13 @@ typedef struct {
pwr_tUInt32 msgSize;
pwr_tBoolean local;
uEvent msg;
mh_eSource activeSource;
pwr_tAttrRef activeSupObject;
pwr_tUInt32 etp;
} redu_sEvEvent;
#define NOIDX 0xffffffff
static pwr_tStatus emon_redu_send()
{
pwr_tStatus sts;
......@@ -5029,6 +5051,24 @@ static pwr_tStatus emon_redu_send()
activep->eventFlags = ap->eventFlags;
activep->eventType = ap->eventType;
activep->status = ap->status;
if ( ap->detect_etp) {
activep->detect_etp = ap->detect_etp->idx;
activep->detect_event = ap->detect_etp->event;
}
else
activep->detect_etp = NOIDX;
if ( ap->return_etp) {
activep->return_etp = ap->return_etp->idx;
activep->return_event = ap->return_etp->event;
}
else
activep->return_etp = NOIDX;
if ( ap->ack_etp) {
activep->ack_etp = ap->ack_etp->idx;
activep->ack_event = ap->ack_etp->event;
}
else
activep->ack_etp = NOIDX;
if ( ap->source == mh_eSource_Scanner) {
sp = (sSupActive *) ap;
......@@ -5036,6 +5076,7 @@ static pwr_tStatus emon_redu_send()
activep->returnTime = sp->sup->ReturnTime;
activep->ackTime = sp->sup->AckTime;
}
activep++;
}
......@@ -5087,11 +5128,23 @@ static pwr_tStatus emon_redu_send()
eventp->msgSize = ep->msgSize;
eventp->local = ep->local;
eventp->msg = ep->msg;
if ( ep->etp && ep->etp->ap) {
eventp->activeSource = ep->etp->ap->source;
if ( ep->etp->ap->source == mh_eSource_Scanner ||
ep->etp->ap->source == mh_eSource_Handler)
eventp->activeSupObject = ep->etp->ap->supObject;
}
if ( ep->etp)
eventp->etp = ep->etp->idx;
else
eventp->etp = NOIDX;
eventp++;
}
l.redu->packetp->PacketSize = ((redu_sEvMsgHeader *)msg)->size +
sizeof(redu_sEvMsgHeader);
l.redu->packetp->TransmitCnt++;
sts = redu_send( l.redu, msg, ((redu_sEvMsgHeader *)msg)->size +
sizeof(redu_sEvMsgHeader), l.redu->msgid_cyclic);
......@@ -5121,13 +5174,12 @@ static pwr_tStatus emon_redu_receive()
int events;
int i;
LstLink(sActive) *al;
sActive *ap;
sActive *ap, *tp;
sSupActive *sp;
sEvent *ep;
sOutunit *op;
LstLink(sOutunit) *ol;
int found;
sEventTab *etp;
sts = redu_receive( l.redu, timeout, &size, &msg);
if ( sts == QCOM__TMO)
......@@ -5160,38 +5212,28 @@ static pwr_tStatus emon_redu_receive()
/* Events */
event_start = (redu_sEvEvent *)((char *)eventlistp + sizeof(redu_sEvEventList));
/* Remove old events */
if ( eventlistp->oldIdx != l.event_l->oldIdx) {
for ( i = l.event_l->oldIdx; i < MIN(eventlistp->oldIdx,l.event_l->oldIdx + l.event_l->size); i++) {
ep = &l.event_l->list[ i % l.event_l->size ];
printf( "Event remove, idx %d %s\n", ep->etp->idx, ep->objName);
tree_Remove(&sts, l.eventTab, &ep->etp->idx);
}
}
/* Add new events */
if ( eventlistp->idx != l.event_l->idx) {
int istart = l.event_l->idx;
if ( istart < (int)eventlistp->idx - (int)l.event_l->size + 1)
istart = (int)eventlistp->idx - (int)l.event_l->size + 1;
for ( i = istart; i <= eventlistp->idx; i++) {
eventp = event_start + i - eventlistp->oldIdx;
ep = &l.event_l->list[ i % l.event_l->size ];
ep->idx = eventp->idx;
ep->outunit = eventp->outunit;
ep->object = eventp->object;
ep->local = eventp->local;
ep->event = eventp->event;
ep->eventType = ep->eventType;
strncpy( ep->objName, eventp->objName, sizeof(ep->objName));
ep->msg = eventp->msg;
tree_EmptyTable( &sts, l.eventTab);
/* Insert events */
for ( i = eventlistp->oldIdx; i <= eventlistp->idx; i++) {
eventp = event_start + i - eventlistp->oldIdx;
ep = &l.event_l->list[ i % l.event_l->size];
ep->idx = eventp->idx;
ep->outunit = eventp->outunit;
ep->object = eventp->object;
ep->local = eventp->local;
ep->event = eventp->event;
ep->eventType = ep->eventType;
strncpy( ep->objName, eventp->objName, sizeof(ep->objName));
ep->msg = eventp->msg;
if ( eventp->etp == NOIDX)
ep->etp = 0;
else {
ep->etp = tree_Insert(&sts, l.eventTab, &ep->idx);
ep->etp->ep = ep;
ep->etp->event = ep->event;
printf( "Event add, idx %d %s\n", ep->etp->idx, ep->objName);
}
// printf( "Event add, idx %d %s sup_oix:%d %u %u\n", ep->etp->idx, ep->objName, ep->etp->ap ? ep->etp->ap->supObject.Objid.oix : 0, (unsigned int)ep->etp->node.left, (unsigned int)ep->etp->node.right);
}
l.event_l->idx = eventlistp->idx;
......@@ -5201,7 +5243,8 @@ static pwr_tStatus emon_redu_receive()
/* Find removed elements in active list */
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l) ; al = LstNex(al)) {
ap = LstObj(al);
if ( ap->source == mh_eSource_Scanner) {
if ( ap->source == mh_eSource_Scanner ||
ap->source == mh_eSource_Handler) {
sp = (sSupActive *) ap;
sp->found = 0;
}
......@@ -5209,10 +5252,12 @@ static pwr_tStatus emon_redu_receive()
activep = (redu_sEvActive *)((char *)msg + sizeof(redu_sEvMsgHeader));
for ( i = 0; i < actives; i++) {
if ( activep->source == mh_eSource_Scanner) {
if ( activep->source == mh_eSource_Scanner ||
activep->source == mh_eSource_Handler) {
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l) ; al = LstNex(al)) {
ap = LstObj(al);
if ( activep->source == mh_eSource_Scanner &&
if ( (activep->source == mh_eSource_Scanner ||
activep->source == mh_eSource_Handler) &&
cdh_ArefIsEqual( &activep->supObject, &ap->supObject)) {
sp = (sSupActive *) ap;
sp->found = 1;
......@@ -5226,16 +5271,19 @@ static pwr_tStatus emon_redu_receive()
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l); ) {
ap = LstObj(al);
al = LstNex(al);
if ( ap->source == mh_eSource_Scanner) {
if ( ap->source == mh_eSource_Scanner ||
ap->source == mh_eSource_Handler) {
sp = (sSupActive *) ap;
if ( !sp->found) {
ap->status.Event.Status &= ~mh_mEventStatus_NotRet;
ap->status.Event.Status &= ~mh_mEventStatus_NotAck;
sp->sup->DetectCheck = TRUE;
sp->sup->AlarmCheck = TRUE;
sp->sup->ReturnCheck = FALSE;
sp->sup->AlarmStatus.All = ap->status.All;
printf( "Active remove, idx %d %s\n", ap->detect_etp->idx, ap->detect_etp->ep->objName);
if ( sp->sup) {
sp->sup->DetectCheck = TRUE;
sp->sup->AlarmCheck = TRUE;
sp->sup->ReturnCheck = FALSE;
sp->sup->AlarmStatus.All = ap->status.All;
}
// printf( "Active remove, idx %d %s\n", ap->detect_etp->idx, ap->detect_etp->ep ? ap->detect_etp->ep->objName : "");
activeListRemove( ap);
}
}
......@@ -5245,19 +5293,21 @@ static pwr_tStatus emon_redu_receive()
activep = (redu_sEvActive *)((char *)msg + sizeof(redu_sEvMsgHeader));
for ( i = 0; i < actives; i++) {
found = 0;
if ( activep->source == mh_eSource_Scanner) {
if ( activep->source == mh_eSource_Scanner ||
activep->source == mh_eSource_Handler) {
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l) ; al = LstNex(al)) {
ap = LstObj(al);
if ( activep->source == mh_eSource_Scanner &&
if ( (activep->source == mh_eSource_Scanner ||
activep->source == mh_eSource_Handler) &&
cdh_ArefIsEqual( &activep->supObject, &ap->supObject)) {
sp = (sSupActive *) ap;
/* Update status */
ap->status = activep->status;
found = 1;
break;
}
}
}
if ( !found) {
/* Add to active list */
sp = supListGet( &activep->supObject);
......@@ -5266,29 +5316,140 @@ static pwr_tStatus emon_redu_receive()
activep++;
continue;
}
sp->sup->DetectTime = activep->detectTime;
sp->sup->AckTime = activep->ackTime;
sp->sup->ReturnTime = activep->returnTime;
sp->sup->AlarmCheck = FALSE;
sp->sup->DetectCheck = FALSE;
sp->sup->ReturnCheck = TRUE;
sp->sup->AlarmStatus.All = activep->status.All;
ap->idx = activep->idx;
etp = tree_Find(&sts, l.eventTab, &ap->idx);
if ( etp) {
etp->ap = ap;
ap->detect_etp = etp;
activeListInsert((sActive *) sp, etp->ep, mh_eSource_Scanner);
printf( "Active add, idx %d %s\n", ap->detect_etp->idx, ap->detect_etp->ep->objName);
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l) ; al = LstNex(al)) {
tp = LstObj(al);
if ( ap == tp)
/* Already in active list */
found = 1;
}
}
if ( activep->detect_etp == NOIDX)
ap->detect_etp = 0;
else {
ap->detect_etp = tree_Find(&sts, l.eventTab, &activep->detect_etp);
if ( ap->detect_etp == 0) {
ap->detect_etp = tree_Insert(&sts, l.eventTab, &activep->detect_etp);
ap->detect_etp->ep = 0;
}
ap->detect_etp->event = activep->detect_event;
ap->detect_etp->ap = ap;
}
if ( activep->return_etp == NOIDX)
ap->return_etp = 0;
else {
ap->return_etp = tree_Find(&sts, l.eventTab, &activep->return_etp);
if ( ap->return_etp == 0) {
ap->return_etp = tree_Insert(&sts, l.eventTab, &activep->return_etp);
ap->return_etp->ep = 0;
}
ap->return_etp->event = activep->return_event;
ap->return_etp->ap = ap;
}
if ( activep->ack_etp == NOIDX)
ap->ack_etp = 0;
else {
ap->ack_etp = tree_Find(&sts, l.eventTab, &activep->ack_etp);
if ( ap->ack_etp == 0) {
ap->ack_etp = tree_Insert(&sts, l.eventTab, &activep->ack_etp);
ap->ack_etp->ep = 0;
}
ap->ack_etp->event = activep->ack_event;
ap->ack_etp->ap = ap;
}
switch ( ap->detect_etp->event) {
case mh_eEvent_Info:
case mh_eEvent_InfoSuccess:
case mh_eEvent_Alarm:
case mh_eEvent_MaintenanceAlarm:
case mh_eEvent_SystemAlarm:
case mh_eEvent_UserAlarm1:
case mh_eEvent_UserAlarm2:
case mh_eEvent_UserAlarm3:
case mh_eEvent_UserAlarm4:
break;
default:
printf( "** etp type error %s %d\n", ap->objName, ap->detect_etp->event);
activep++;
continue;
}
if ( !found) {
LstLink(sActive) *al;
LstLink(sBlock) *bl;
// printf( "Active add, idx %d %s\n", ap->detect_etp->idx, ap->detect_etp->ep ? ap->detect_etp->ep->objName : "");
//if ( sp->sup) {
// sp->sup->DetectTime = activep->detectTime;
// sp->sup->AckTime = activep->ackTime;
// sp->sup->ReturnTime = activep->returnTime;
// sp->sup->AlarmCheck = FALSE;
// sp->sup->DetectCheck = FALSE;
// sp->sup->ReturnCheck = TRUE;
// sp->sup->AlarmStatus.All = activep->status.All;
//}
/* Insert in active list */
al = LstEnd(&l.active_l);
LstIns(al, ap, active_l);
switch (ap->event) {
case mh_eEvent_Alarm:
case mh_eEvent_MaintenanceAlarm:
case mh_eEvent_SystemAlarm:
case mh_eEvent_UserAlarm1:
case mh_eEvent_UserAlarm2:
case mh_eEvent_UserAlarm3:
case mh_eEvent_UserAlarm4:
++l.emon->AlarmCount;
break;
case mh_eEvent_Block:
case mh_eEvent_Reblock:
bl = LstEnd(&l.block_l);
LstIns(bl, (sBlock *)ap, block_l);
++l.emon->BlockCount;
break;
case mh_eEvent_Info:
case mh_eEvent_InfoSuccess:
break;
default:
errh_Error("activeListInsert, program error, event: %d", ap->event);
break;
}
ap->status = activep->status;
// printf( "Active add, idx %d %s\n", ap->detect_etp->idx, ap->detect_etp->ep ? ap->detect_etp->ep->objName : "");
}
ap->idx = activep->idx;
ap->outunit = activep->outunit;
ap->status = activep->status;
activep++;
}
#if 0
/* Test */
printf( "---------------------\n");
for (al = LstFir(&l.active_l); al != LstEnd(&l.active_l) ; al = LstNex(al)) {
ap = LstObj(al);
printf( " %s %s %s\n", ap->objName, ap->status.All & mh_mEventStatus_NotAck ? "NA" : " ",ap->status.All & mh_mEventStatus_NotRet ? "NR" : " " );
}
printf( "---------------------\n");
#endif
#if 0
/* Check that there are no etp without ap */
for (etp = tree_Minimum(&sts, l.eventTab); etp != NULL; etp = tree_Successor(&sts, l.eventTab, etp)) {
if ( !etp->ap) {
printf( "** etp without ap removed\n");
sEventTab *pred = tree_Predecessor(&sts, l.eventTab, etp);
tree_Remove(&sts, l.eventTab, &etp->idx);
if ( pred != NULL)
etp = pred;
else
etp = tree_Minimum(&sts, l.eventTab);
}
}
#endif
/* Outunits */
outunit_start = (redu_sEvOutunit *)activep;
......@@ -5382,8 +5543,8 @@ static pwr_tStatus emon_redu_receive()
time_Adiff( &dtime, &end_time, &start_time);
time_DToFloat( &l.redu->msg_time, &dtime);
if ( l.redu->packetp) {
l.redu->packetp->PacketCount++;
l.redu->packetp->PackTime = l.redu->msg_time;
l.redu->packetp->ReceiveCnt++;
l.redu->packetp->UnpackTime = l.redu->msg_time;
}
break;
......
......@@ -204,6 +204,7 @@ struct sLink {
pwr_tDeltaTime ack_delay;
unsigned int exp_buf_quota;
sIseg tmo;
thread_sMutex eseg_mutex;
};
......@@ -588,6 +589,7 @@ clean_insert (
if ((!pending) && (esp->head.flags.b.first)) {
thread_MutexLock(&esp->lp->eseg_mutex);
for (sp = lst_Succ(NULL, le, &se); se != le; sp = nsp) {
li = se;
nsp = lst_Succ(NULL, se, &se);
......@@ -609,12 +611,14 @@ clean_insert (
break;
}
}
thread_MutexUnlock(&esp->lp->eseg_mutex);
if (!esp->head.flags.b.last && first) ret_pend = TRUE;
if (!first) li = le;
}
else if (pending) {
thread_MutexLock(&esp->lp->eseg_mutex);
for (sp = lst_Succ(NULL, le, &se); se != le; sp = nsp) {
li = se;
nsp = lst_Succ(NULL, se, &se);
......@@ -631,6 +635,7 @@ clean_insert (
break;
}
}
thread_MutexUnlock(&esp->lp->eseg_mutex);
if (!first) li = le;
ret_pend = !esp->head.flags.b.last;
......@@ -651,7 +656,9 @@ clean_insert (
}
}
#endif
thread_MutexLock(&esp->lp->eseg_mutex);
lst_InsertPred(NULL, li, &esp->c.le, esp);
thread_MutexUnlock(&esp->lp->eseg_mutex);
return ret_pend;
......@@ -1016,17 +1023,19 @@ export_thread ()
thread_MutexLock(&l.bcast);
esp = sp;
thread_MutexLock(&sp->lp->eseg_mutex);
esp = sp;
do {
ssp = esp;
do {
ssp = esp;
do {
ssp->c.action = eAction_export;
que_Put(NULL, &ssp->lp->q_in, &ssp->c.le, ssp);
ssp = lst_Succ(NULL, &ssp->le_seg, NULL) ;
} while (ssp != esp);
esp = lst_Succ(NULL, &ssp->le_bcast, NULL) ;
} while (esp != sp);
ssp->c.action = eAction_export;
que_Put(NULL, &ssp->lp->q_in, &ssp->c.le, ssp);
ssp = lst_Succ(NULL, &ssp->le_seg, NULL) ;
} while (ssp != esp);
esp = lst_Succ(NULL, &ssp->le_bcast, NULL) ;
} while (esp != sp);
thread_MutexUnlock(&sp->lp->eseg_mutex);
thread_MutexUnlock(&l.bcast);
}
......@@ -1312,6 +1321,7 @@ lack (
lst_sEntry *se;
int diff;
sEseg *sp, *nsp;
thread_sMutex *mx;
for (sp = lst_Succ(NULL, &lp->lh_win, &se); se != &lp->lh_win; sp = nsp) {
nsp = lst_Succ(NULL, se, &se);
......@@ -1327,7 +1337,10 @@ lack (
window_remove(lp, sp);
mx = &sp->lp->eseg_mutex;
thread_MutexLock(mx);
eseg_free(sp);
thread_MutexUnlock(mx);
} else {
/* This is the oldest not acked segment. */
lp->np->link[lp->lix].lack = sp->head.lack;
......@@ -1437,6 +1450,7 @@ link_disconnect (
/* Empty window list */
thread_MutexLock(&lp->eseg_mutex);
for (
sp = lst_Succ(NULL, &lp->lh_win, NULL);
sp != NULL;
......@@ -1445,6 +1459,7 @@ link_disconnect (
lst_Remove(NULL, &sp->c.le);
eseg_free(sp);
}
thread_MutexUnlock(&lp->eseg_mutex);
lp->np->link[lp->lix].win_count = 0;
......@@ -1544,6 +1559,7 @@ link_purge (
/* Purge send list */
int i = 0;
thread_MutexUnlock(&lp->eseg_mutex);
for (
sp = lst_Succ(NULL, &lp->lh_send, NULL);
sp != NULL;
......@@ -1560,6 +1576,7 @@ link_purge (
alloc_cnt += sp->size;
i++;
}
thread_MutexUnlock(&lp->eseg_mutex);
printf( "link_purge: %d cnt %d (%d)\n", i, lp->np->link[lp->lix].export_alloc_cnt, alloc_cnt);
lp->np->link[lp->lix].export_alloc_cnt = alloc_cnt;
lp->np->link[lp->lix].export_purge_cnt++;
......@@ -1825,6 +1842,7 @@ new_link (
lp->np->link[lp->lix].rtt_rxmax = rtt_rxmax;
lp->np->link[lp->lix].rtt_rxmin = rtt_rxmin;
lp->tmo.c.action = eAction_tmo;
sts = thread_MutexInit(&lp->eseg_mutex);
if (mp != NULL) {
#if defined OS_VMS
......@@ -1901,11 +1919,15 @@ pending_send (
sLink *lp
)
{
sEseg *sp;
if (lp->np->link[lp->lix].win_count >= lp->np->link[lp->lix].win_max)
return NULL;
return lst_RemoveSucc(NULL, &lp->lh_send, NULL);
thread_MutexLock(&lp->eseg_mutex);
sp = lst_RemoveSucc(NULL, &lp->lh_send, NULL);
thread_MutexUnlock(&lp->eseg_mutex);
return sp;
}
static void
......
......@@ -139,6 +139,8 @@ struct sHead {
mSeg flags pwr_dPacked;
qdb_sAck lack;
qdb_sAck rack;
int prio;
int state;
};
typedef struct {
......@@ -228,11 +230,13 @@ struct sLink {
que_sQue q_in;
redu_sNode *np;
thread_s thread;
qdb_sBuffer *bp;
char *p;
qdb_sBuffer *bp[redu_ePrio__];
char *p[redu_ePrio__];
pwr_tDeltaTime ack_delay;
unsigned int exp_buf_quota;
sIseg tmo;
thread_sMutex eseg_mutex;
pwr_tTime receive_time;
};
......@@ -302,6 +306,13 @@ struct {
} cyclic;
qdb_sLinkInfo link_info;
pwr_tStatus sts;
struct {
int initialized;
pwr_tBoolean force_old;
pwr_tBoolean emergbreaktrue_old;
pwr_eUpDownEnum linkstate_old;
pwr_tStatus systemstatus_old;
} sup;
} l;
static pwr_tStatus redu_sts = PWR__SRVSTARTUP;
......@@ -679,6 +690,7 @@ clean_insert (
if ((!pending) && (esp->head.flags.b.first)) {
thread_MutexLock(&esp->lp->eseg_mutex);
for (sp = lst_Succ(NULL, le, &se); se != le; sp = nsp) {
li = se;
nsp = lst_Succ(NULL, se, &se);
......@@ -700,12 +712,14 @@ clean_insert (
break;
}
}
thread_MutexUnlock(&esp->lp->eseg_mutex);
if (!esp->head.flags.b.last && first) ret_pend = TRUE;
if (!first) li = le;
}
else if (pending) {
thread_MutexLock(&esp->lp->eseg_mutex);
for (sp = lst_Succ(NULL, le, &se); se != le; sp = nsp) {
li = se;
nsp = lst_Succ(NULL, se, &se);
......@@ -722,6 +736,7 @@ clean_insert (
break;
}
}
thread_MutexUnlock(&esp->lp->eseg_mutex);
if (!first) li = le;
ret_pend = !esp->head.flags.b.last;
......@@ -729,21 +744,40 @@ clean_insert (
}
}
/* Insert new item */
/* Prioritize */
if ( !first) {
thread_MutexLock(&esp->lp->eseg_mutex);
for (sp = lst_Pred(NULL, le, &se); se != le; sp = lst_Pred(NULL, se, &se)) {
li = se;
if (sp->head.prio <= esp->head.prio)
break;
}
if ( se == le)
lst_InsertPred(NULL, li, &esp->c.le, esp);
else
lst_InsertSucc(NULL, li, &esp->c.le, esp);
thread_MutexUnlock(&esp->lp->eseg_mutex);
}
else {
/* Insert new item */
thread_MutexLock(&esp->lp->eseg_mutex);
lst_InsertPred(NULL, li, &esp->c.le, esp);
thread_MutexUnlock(&esp->lp->eseg_mutex);
}
#if 0
// Segment sequence test
static int no = 0;
if ( esp->head.flags.b.last) {
no++;
if ( no == 100) {
no = 0;
return ret_pend;
}
// Test
static int cnt = 0;
if ( 0 == 0) {
cnt++;
printf("************************ %d\n", cnt);
for (sp = lst_Succ(NULL, le, &se); se != le; sp = lst_Succ(NULL, se, &se))
printf( "%x %d %s%s%s\n", (unsigned int)sp->bp, sp->head.prio, sp->head.flags.b.first ? "F" : " ",
sp->head.flags.b.last ? "L" : " ", sp->head.flags.b.middle ? "M" : " ");
}
#endif
lst_InsertPred(NULL, li, &esp->c.le, esp);
return ret_pend;
}
......@@ -757,9 +791,16 @@ create_connect (
sp = eseg_alloc(&l.eseg.mutex);
sp->head.flags.b.event = eEvent_connect;
sp->head.prio = redu_ePrio_0;
sp->head.state = l.nodep->RedundancyState;
sp->lp = lp;
sp->c.action = eAction_export;
/* Init receive timeout */
if ( l.nodep->RedundancyState == pwr_eRedundancyState_Init ||
l.nodep->RedundancyState == pwr_eRedundancyState_Passive)
time_GetTimeMonotonic( &lp->receive_time);
return sp;
}
......@@ -792,6 +833,8 @@ decode_head (
tp->lack.ts = ntohl(sp->lack.ts);
tp->rack.seq = ntohl(sp->rack.seq);
tp->rack.ts = ntohl(sp->rack.ts);
tp->prio = ntohl(sp->prio);
tp->state = ntohl(sp->state);
}
static void
......@@ -830,6 +873,8 @@ encode_head (
tp->lack.ts = htonl(sp->lack.ts);
tp->rack.seq = htonl(sp->rack.seq);
tp->rack.ts = htonl(sp->rack.ts);
tp->prio = htonl(sp->prio);
tp->state = htonl(sp->state);
}
static void
......@@ -960,6 +1005,8 @@ eseg_build (
sp->size = MIN(size, redu_segment_size);
sp->head.flags.b.event = eEvent_user;
sp->head.flags.b.bcast = bcast;
sp->head.prio = bp->b.prio;
sp->head.state = l.nodep->RedundancyState;
if (msp == NULL) {
sp->head.flags.b.first = 1;
msp = sp;
......@@ -991,6 +1038,8 @@ eseg_build (
csp->bp = bp;
csp->lp = lp;
csp->head.flags.m = sp->head.flags.m;
csp->head.prio = bp->b.prio;
csp->head.state = l.nodep->RedundancyState;
csp->size = sp->size;
csp->id = ii++;
if (mcsp == NULL) {
......@@ -1110,7 +1159,7 @@ export_thread ()
if (bp != NULL)
bp = qdb_DetachBuffer(&sts, bp);
} qdb_ScopeUnlock;
if (bp == NULL) continue;
pwr_Assert(bp->c.type == qdb_eBuffer_base);
......@@ -1125,17 +1174,19 @@ export_thread ()
thread_MutexLock(&l.bcast);
esp = sp;
thread_MutexLock(&sp->lp->eseg_mutex);
esp = sp;
do {
ssp = esp;
do {
ssp = esp;
do {
ssp->c.action = eAction_export;
que_Put(NULL, &ssp->lp->q_in, &ssp->c.le, ssp);
ssp = lst_Succ(NULL, &ssp->le_seg, NULL) ;
} while (ssp != esp);
esp = lst_Succ(NULL, &ssp->le_bcast, NULL) ;
} while (esp != sp);
ssp->c.action = eAction_export;
que_Put(NULL, &ssp->lp->q_in, &ssp->c.le, ssp);
ssp = lst_Succ(NULL, &ssp->le_seg, NULL) ;
} while (ssp != esp);
esp = lst_Succ(NULL, &ssp->le_bcast, NULL) ;
} while (esp != sp);
thread_MutexUnlock(&sp->lp->eseg_mutex);
thread_MutexUnlock(&l.bcast);
}
......@@ -1300,62 +1351,69 @@ iseg_import (
qdb_sInfo *ip;
qdb_sQue *qp;
qcom_sQid qid;
int prio;
if (!lp->np->link.flags.b.connected) {
return;
}
diff = sp->head.lack.seq - lp->np->link.rack.seq;
if (diff != 1) {
return;
}
prio = sp->head.prio;
if ( prio < 0 || prio >= redu_ePrio__)
return;
if (sp->head.flags.b.first) {
// pwr_Assert(lp->bp == NULL);
// pwr_Assert(lp->bp[prio] == NULL);
ip = (qdb_sInfo *)sp->buff;
decode_info(ip);
qdb_ScopeLock {
if ( lp->bp != NULL) {
if ( lp->bp[prio] != NULL) {
lp->np->link.err_seg_seq++;
qdb_Free( NULL, lp->bp);
qdb_Free( NULL, lp->bp[prio]);
}
lp->bp = qdb_Alloc(&sts, qdb_eBuffer_base, ip->size);
lp->bp[prio] = qdb_Alloc(&sts, qdb_eBuffer_base, ip->size);
} qdb_ScopeUnlock;
if ( lp->bp == NULL) {
if ( lp->bp[prio] == NULL) {
purge();
return;
}
lp->bp->c.flags.m |= ip->flags.m & qdb_mBuffer_maskExport;
lp->p = (char *)&lp->bp->b.info;
lp->bp[prio]->c.flags.m |= ip->flags.m & qdb_mBuffer_maskExport;
lp->p[prio] = (char *)&lp->bp[prio]->b.info;
} else if (!sp->head.flags.b.first) {
// pwr_Assert(lp->bp != NULL);
// pwr_Assert(lp->p != NULL);
if ( lp->bp == NULL) {
// pwr_Assert(lp->bp[prio] != NULL);
// pwr_Assert(lp->p[prio] != NULL);
if ( lp->bp[prio] == NULL) {
lp->np->link.err_seg_seq++;
return;
}
}
memcpy(lp->p, sp->buff, sp->size);
lp->p += sp->size;
memcpy(lp->p[prio], sp->buff, sp->size);
lp->p[prio] += sp->size;
if (sp->head.flags.b.last) {
lp->bp->c.flags.b.imported = 1;
lp->bp[prio]->c.flags.b.imported = 1;
qdb_ScopeLock {
qid.qix = lp->bp->b.info.receiver.qix;
qid.qix = lp->bp[prio]->b.info.receiver.qix;
qid.nid = qdb->my_nid;
qp = qdb_Que(&sts, &qid, NULL);
if (qp == NULL) {
/* To do !!! Send notification reply if requested. */
qdb_Free(NULL, lp->bp);
qdb_Free(NULL, lp->bp[prio]);
} else {
qdb_Put(NULL, lp->bp, qp);
qdb_Put(NULL, lp->bp[prio], qp);
}
} qdb_ScopeUnlock;
lp->bp = NULL;
lp->bp[prio] = NULL;
}
}
......@@ -1372,6 +1430,7 @@ lack (
lst_sEntry *se;
int diff;
sEseg *sp, *nsp;
thread_sMutex *mx;
for (sp = lst_Succ(NULL, &lp->lh_win, &se); se != &lp->lh_win; sp = nsp) {
nsp = lst_Succ(NULL, se, &se);
......@@ -1387,7 +1446,10 @@ lack (
window_remove(lp, sp);
mx = &sp->lp->eseg_mutex;
thread_MutexLock(mx);
eseg_free(sp);
thread_MutexUnlock(mx);
} else {
/* This is the oldest not acked segment. */
lp->np->link.lack = sp->head.lack;
......@@ -1450,6 +1512,7 @@ link_disconnect (
)
{
sEseg *sp;
int i;
if (!lp->np->link.flags.b.connected) {
pwr_Assert(!lp->np->link.flags.b.active);
......@@ -1468,6 +1531,7 @@ link_disconnect (
/* Empty send list */
thread_MutexLock(&lp->eseg_mutex);
for (
sp = lst_Succ(NULL, &lp->lh_send, NULL);
sp != NULL;
......@@ -1487,21 +1551,25 @@ link_disconnect (
lst_Remove(NULL, &sp->c.le);
eseg_free(sp);
}
thread_MutexUnlock(&lp->eseg_mutex);
lp->np->link.win_count = 0;
errh_Info("Disconnected, link to %s (%s)",
lp->np->name, cdh_NodeIdToString(NULL, lp->np->nid, 0, 0));
qdb_ScopeLock {
if (lp->bp != NULL) {
qdb_Free(NULL, lp->bp);
for ( i = 0; i < redu_ePrio__; i++) {
if (lp->bp[i] != NULL)
qdb_Free(NULL, lp->bp[i]);
}
lp->np->flags.b.active = 0;
lp->np->flags.b.connected = 0;
} qdb_ScopeUnlock;
lp->bp = NULL;
lp->p = NULL;
for ( i = 0; i < redu_ePrio__; i++) {
lp->bp[i] = NULL;
lp->p[i] = NULL;
}
lp->np->link.export_alloc_cnt = 0;
l.config->Link[lp->idx].ExportAlloc = lp->np->link.export_alloc_cnt;
sp = create_connect(lp);
......@@ -1527,6 +1595,7 @@ link_purge (
/* Purge send list */
int i = 0;
thread_MutexLock(&lp->eseg_mutex);
for (
sp = lst_Succ(NULL, &lp->lh_send, NULL);
sp != NULL;
......@@ -1543,6 +1612,7 @@ link_purge (
alloc_cnt += sp->size;
i++;
}
thread_MutexUnlock(&lp->eseg_mutex);
printf( "redcom link_purge: %d cnt %d (%d)\n", i, lp->np->link.export_alloc_cnt, alloc_cnt);
lp->np->link.export_alloc_cnt = alloc_cnt;
lp->np->link.export_purge_cnt++;
......@@ -1550,6 +1620,36 @@ link_purge (
l.config->Link[lp->idx].ExportAlloc = lp->np->link.export_alloc_cnt;
}
static void check_state( sLink *lp, sIseg *sp)
{
switch ( sp->head.state) {
case pwr_eRedundancyState_Active:
switch ( l.nodep->RedundancyState) {
case pwr_eRedundancyState_Init:
case pwr_eRedundancyState_Active:
state_change_request( lp, sp, pwr_eRedundancyState_Passive);
break;
}
break;
case pwr_eRedundancyState_Passive:
switch ( l.nodep->RedundancyState) {
case pwr_eRedundancyState_Init:
case pwr_eRedundancyState_Passive:
state_change_request( lp, sp, pwr_eRedundancyState_Active);
break;
}
break;
case pwr_eRedundancyState_Init:
switch ( l.nodep->RedundancyState) {
case pwr_eRedundancyState_Init:
state_change_request( lp, sp, pwr_eRedundancyState_Active);
break;
}
break;
}
}
static void
link_import (
......@@ -1558,6 +1658,8 @@ link_import (
)
{
time_GetTimeMonotonic( &lp->receive_time);
if (!lp->np->link.flags.b.active && lp->np->birth == sp->head.birth)
link_active(lp);
else if (lp->np->birth != sp->head.birth && lp->np->link.flags.b.connected)
......@@ -1567,6 +1669,7 @@ link_import (
switch (sp->head.flags.b.event) {
case eEvent_user:
check_state(lp, sp);
if (lp->np->link.flags.b.active) {
lack(lp, sp);
iseg_import(lp, sp);
......@@ -1574,11 +1677,13 @@ link_import (
}
break;
case eEvent_ack:
check_state(lp, sp);
if (lp->np->link.flags.b.active) {
lack(lp, sp);
}
break;
case eEvent_connect:
check_state(lp, sp);
link_connect(lp, sp);
lack(lp, sp);
set_rack(lp, sp);
......@@ -1801,6 +1906,7 @@ new_link (
lp->np->link.rtt_rxmax = rtt_rxmax;
lp->np->link.rtt_rxmin = rtt_rxmin;
lp->tmo.c.action = eAction_tmo;
sts = thread_MutexInit(&lp->eseg_mutex);
if (mp != NULL) {
lp->np->sa = mp->sa;
......@@ -1847,11 +1953,15 @@ pending_send (
sLink *lp
)
{
sEseg *sp;
if (lp->np->link.win_count >= lp->np->link.win_max)
return NULL;
return lst_RemoveSucc(NULL, &lp->lh_send, NULL);
thread_MutexLock(&lp->eseg_mutex);
sp = lst_RemoveSucc(NULL, &lp->lh_send, NULL);
thread_MutexUnlock(&lp->eseg_mutex);
return sp;
}
static void
......@@ -1870,6 +1980,8 @@ send_ack (
head.nid = l.head.nid;
head.birth = l.head.birth;
head.rack = lp->np->link.rack;
head.prio = redu_ePrio_0;
head.state = l.nodep->RedundancyState;
set_sendmsg(lp, NULL, &msg);
encode_head(&msg.head, &head);
......@@ -2214,6 +2326,7 @@ state_change_request (
case pwr_eRedundancyState_Active:
case pwr_eRedundancyState_Passive:
case pwr_eRedundancyState_Off:
case pwr_eRedundancyState_Init:
l.nodep->RedundancyState = state;
qdb->my_node->redundancy_state = l.nodep->RedundancyState;
......@@ -2240,15 +2353,65 @@ request_state_change (
case pwr_eRedundancyState_Off:
sp->head.flags.b.event = eEvent_set_off;
break;
default:
return 0;
}
sp->lp = lp;
sp->c.action = eAction_export;
sp->head.prio = redu_ePrio_0;
sp->head.state = l.nodep->RedundancyState;
que_Put(NULL, &lp->q_in, &sp->c.le, sp);
return sp;
}
static void failover_detection()
{
pwr_tTime current;
sLink *lp;
pwr_tStatus sts;
time_GetTimeMonotonic( &current);
/* When force is removed, initialize again */
if ( !l.config->Force && l.sup.force_old)
l.sup.initialized = 0;
if ( !l.config->Force && l.sup.initialized) {
if ( l.nodep->RedundancyState == pwr_eRedundancyState_Active) {
/* State is active */
if ( l.nodep->EmergBreakTrue && !l.sup.emergbreaktrue_old)
l.config->SetPassive = 1;
//else if ( EVEN(l.nodep->SystemStatus) && ODD(l.sup.systemstatus_old))
//l.config->SetPassive = 1;
}
else {
/* State if passive, check for overtaking */
if ( l.config->Link[0].State == pwr_eUpDownEnum_Down && l.sup.linkstate_old == pwr_eUpDownEnum_Up)
l.config->SetActive = 1;
for (lp = tree_Minimum(&sts, l.links.table); lp != NULL; lp = tree_Successor(&sts, l.links.table, lp)) {
if ( l.config->Link[lp->idx].State == pwr_eUpDownEnum_Up && l.config->LinkTimeout > 0) {
pwr_tDeltaTime dt;
time_Adiff( &dt, &current, &lp->receive_time);
if ( time_DToFloat( 0, &dt) > l.config->LinkTimeout)
l.config->SetActive = 1;
}
}
}
}
l.sup.force_old = l.config->Force;
l.sup.emergbreaktrue_old = l.nodep->EmergBreakTrue;
l.sup.linkstate_old = l.config->Link[0].State;
l.sup.systemstatus_old = l.nodep->SystemStatus;
if ( !l.sup.initialized)
l.sup.initialized = 1;
}
static void *
cyclic_thread ()
{
......@@ -2262,7 +2425,10 @@ cyclic_thread ()
ts.tv_sec = dt.tv_sec;
ts.tv_nsec = dt.tv_nsec;
for (;;) {
failover_detection();
if ( l.config->SetActive) {
for (lp = tree_Minimum(&sts, l.links.table); lp != NULL; lp = tree_Successor(&sts, l.links.table, lp))
......
......@@ -643,7 +643,8 @@ typedef pwr_tEnum pwr_tRedundancyStateEnum;
typedef enum {
pwr_eRedundancyState_Off,
pwr_eRedundancyState_Passive,
pwr_eRedundancyState_Active
pwr_eRedundancyState_Active,
pwr_eRedundancyState_Init
} pwr_eRedundancyState;
......
......@@ -87,6 +87,7 @@
(p)->pre = (void *)(&(o)->e))
#define LstRem(p) ((p)->nex->pre = (p)->pre,(p)->pre->nex = (p)->nex)
#define LstNul(p) ((p)->nex = (p)->pre = NULL)
#define LstIsNul(p) ((p)->nex == NULL && (p)->pre == NULL)
#define LstInl(p) ((p)->nex != NULL && (p)->pre != NULL)
#define LstIni(h) ((h)->nex = (h)->pre = (h))
#define LstObj(p) ((p)->obj)
......
......@@ -113,10 +113,10 @@ static pwr_tStatus plc_redu_init( plc_sThread *tp)
sts = redu_init( &tp->redu, tp->pp->Node, p);
if ( EVEN(sts)) return sts;
break;
return PLC__SUCCESS;
}
}
return PLC__SUCCESS;
return PLC__REDUCONFIG;
}
static pwr_tStatus plc_redu_receive( plc_sThread *tp)
......@@ -138,8 +138,11 @@ static pwr_tStatus plc_redu_receive( plc_sThread *tp)
redu_free_table( tp->redu);
sts = redu_receive_table( tp->redu, msg);
if ( tp->redu->packetp)
tp->redu->packetp->TableStatus = sts;
if ( EVEN(sts)) return sts;
tp->redu->table_sent = 1;
break;
case redu_eMsgType_Cyclic:
if ( tp->redu->packetp)
......@@ -147,6 +150,69 @@ static pwr_tStatus plc_redu_receive( plc_sThread *tp)
sts = redu_unpack_message( tp->redu, msg);
if ( EVEN(sts)) return sts;
break;
case redu_eMsgType_TableRequest: {
void *table_msg;
if ( !tp->redu->table_sent) {
sts = redu_create_table( tp->redu);
if ( tp->redu->packetp)
tp->redu->packetp->TableStatus = sts;
if ( EVEN(sts)) return sts;
}
sts = redu_send_table( tp->redu, &table_msg);
if ( tp->redu->packetp)
tp->redu->packetp->TableStatus = sts;
if ( EVEN(sts)) return sts;
sts = redu_send( tp->redu, table_msg,
((redu_sTableMsgHeader *)table_msg)->size + sizeof( redu_sTableMsgHeader),
tp->redu->msgid_table);
if ( EVEN(sts)) return sts;
tp->redu->table_sent = 1;
break;
}
default:
printf( "Redu: Unknown message type\n");
}
qcom_Free( &sts, msg);
return PLC__SUCCESS;
}
static pwr_tStatus plc_redu_receive_active( plc_sThread *tp)
{
pwr_tStatus sts;
void *msg;
int size;
sts = redu_receive( tp->redu, qcom_cTmoNone, &size, &msg);
if ( EVEN(sts)) return sts;
switch ( ((redu_sHeader *)msg)->type) {
break;
case redu_eMsgType_TableRequest: {
void *table_msg;
if ( !tp->redu->table_sent) {
sts = redu_create_table( tp->redu);
if ( tp->redu->packetp)
tp->redu->packetp->TableStatus = sts;
if ( EVEN(sts)) return sts;
}
sts = redu_send_table( tp->redu, &table_msg);
if ( tp->redu->packetp)
tp->redu->packetp->TableStatus = sts;
if ( EVEN(sts)) return sts;
sts = redu_send( tp->redu, table_msg,
((redu_sTableMsgHeader *)table_msg)->size + sizeof( redu_sTableMsgHeader),
tp->redu->msgid_table);
if ( EVEN(sts)) return sts;
tp->redu->table_sent = 1;
break;
}
case redu_eMsgType_Table:
case redu_eMsgType_Cyclic:
break;
default:
printf( "Redu: Unknown message type\n");
......@@ -164,9 +230,13 @@ static pwr_tStatus plc_redu_send( plc_sThread *tp)
void *table_msg;
sts = redu_create_table( tp->redu);
if ( tp->redu->packetp)
tp->redu->packetp->TableStatus = sts;
if ( EVEN(sts)) return sts;
sts = redu_send_table( tp->redu, &table_msg);
if ( tp->redu->packetp)
tp->redu->packetp->TableStatus = sts;
if ( EVEN(sts)) return sts;
sts = redu_send( tp->redu, table_msg,
......@@ -190,6 +260,21 @@ static pwr_tStatus plc_redu_send( plc_sThread *tp)
return sts;
}
static pwr_tStatus plc_redu_send_table_request( plc_sThread *tp)
{
pwr_tStatus sts;
void *msg;
sts = redu_create_table_request_message( tp->redu, &msg);
if ( EVEN(sts)) return sts;
sts = redu_send( tp->redu, msg, sizeof(redu_sHeader), 0);
free( msg);
return sts;
}
void
plc_thread (
......@@ -479,6 +564,10 @@ scan (
}
if ( tp->redu && tp->pp->Node->RedundancyState == pwr_eRedundancyState_Passive) {
if ( tp->redu_state_old == pwr_eRedundancyState_Off || tp->redu_state_old == pwr_eRedundancyState_Init) {
/* Send table request */
sts = plc_redu_send_table_request( tp);
}
time_GetTimeMonotonic(&tp->before_scan);
time_GetTime(&tp->before_scan_abs);
......@@ -503,7 +592,7 @@ scan (
return;
}
if ( tp->pp->Node->RedundancyState != pwr_eRedundancyState_Passive) {
if ( !tp->redu || (tp->pp->Node->RedundancyState != pwr_eRedundancyState_Passive)) {
if (pp->IOHandler->IOReadWriteFlag) {
if ( tp->redu_state_old == pwr_eRedundancyState_Passive)
......@@ -555,6 +644,7 @@ scan (
}
}
if ( tp->redu && tp->pp->Node->RedundancyState == pwr_eRedundancyState_Active) {
sts = plc_redu_receive_active( tp);
sts = plc_redu_send( tp);
}
}
......
......@@ -48,6 +48,7 @@
#include "rt_qcom.h"
#include "rt_qcom_msg.h"
#include "rt_redu.h"
#include "rt_redu_msg.h"
static pwr_tStatus add_table_object( redu_tCtx ctx, pwr_tAttrRef *o);
static pwr_tStatus add_table_attr( redu_tCtx ctx, pwr_tAttrRef *aref, gdh_sAttrDef *bd);
......@@ -80,7 +81,7 @@ pwr_tStatus redu_create_table( redu_tCtx ctx)
}
#endif
return 1;
return REDU__TABLECREATED;
}
void redu_free( redu_tCtx ctx)
......@@ -146,7 +147,7 @@ static pwr_tStatus add_table_object( redu_tCtx ctx, pwr_tAttrRef *o)
o = &maref;
}
else
return 1;
return REDU__SUCCESS;
sts = gdh_GetAttrRefTid( o, &tid);
if ( EVEN(sts)) return sts;
......@@ -220,7 +221,7 @@ static pwr_tStatus add_table_object( redu_tCtx ctx, pwr_tAttrRef *o)
if ( EVEN(sts)) return sts;
}
}
return 1;
return REDU__SUCCESS;
}
static pwr_tStatus add_table_attr( redu_tCtx ctx, pwr_tAttrRef *aref, gdh_sAttrDef *bd)
......@@ -234,7 +235,7 @@ static pwr_tStatus add_table_attr( redu_tCtx ctx, pwr_tAttrRef *aref, gdh_sAttrD
if ( aref->Flags.b.Indirect) {
if ( *(unsigned long *)p == 0)
return 1;
return REDU__SUCCESS;
p = gdh_TranslateRtdbPointer( *(unsigned long *)p);
}
......@@ -253,7 +254,14 @@ static pwr_tStatus add_table_attr( redu_tCtx ctx, pwr_tAttrRef *aref, gdh_sAttrD
ctx->current_offset += t->size;
ctx->attr_cnt++;
return 1;
return REDU__SUCCESS;
}
pwr_tStatus redu_create_table_request_message( redu_tCtx ctx, void **msg)
{
*msg = malloc( sizeof(redu_sHeader));
((redu_sHeader *)(*msg))->type = redu_eMsgType_TableRequest;
return REDU__SUCCESS;
}
pwr_tStatus redu_create_message( redu_tCtx ctx, void **msg)
......@@ -287,7 +295,7 @@ pwr_tStatus redu_create_message( redu_tCtx ctx, void **msg)
ctx->packetp->PackTime = ctx->msg_time;
}
*msg = buf;
return 1;
return REDU__SUCCESS;
}
pwr_tStatus redu_unpack_message( redu_tCtx ctx, void *msg)
......@@ -313,7 +321,7 @@ pwr_tStatus redu_unpack_message( redu_tCtx ctx, void *msg)
ctx->packetp->ReceiveCnt++;
ctx->packetp->UnpackTime = ctx->msg_time;
}
return 1;
return REDU__SUCCESS;
}
pwr_tStatus redu_send_table( redu_tCtx ctx, void **table_msg)
......@@ -336,10 +344,12 @@ pwr_tStatus redu_send_table( redu_tCtx ctx, void **table_msg)
msgp += sizeof(redu_sTableMsgElement);
}
ctx->packetp->TablePacketSize = size;
ctx->packetp->Attributes = ctx->attr_cnt;
if ( ctx->packetp) {
ctx->packetp->TablePacketSize = size;
ctx->packetp->Attributes = ctx->attr_cnt;
}
*table_msg = msg;
return 1;
return REDU__TABLESENT;
}
pwr_tStatus redu_receive_table( redu_tCtx ctx, void *table_msg)
......@@ -386,7 +396,7 @@ pwr_tStatus redu_receive_table( redu_tCtx ctx, void *table_msg)
ctx->attr_cnt++;
msgp += sizeof(redu_sTableMsgElement);
}
return 1;
return REDU__TABLERECEIVED;
}
void redu_print_table( redu_tCtx ctx)
......@@ -483,7 +493,7 @@ int redu_init( redu_tCtx *ctx, pwr_sNode *nodep, pwr_sClass_RedcomPacket *packet
c->send_qid.qix = redu_cQixExport;
c->send_qid.nid = 0;
return 1;
return REDU__SUCCESS;
}
int redu_receive( redu_tCtx ctx, unsigned int timeout, int *size, void **msg)
......@@ -524,7 +534,7 @@ pwr_tStatus redu_get_initial_state( char *nodename, int busid, int *state)
dcli_translate_filename( fname, fname);
fp = fopen( fname, "r");
if ( !fp)
return 0;
return REDU__REDCOMFILE;
while ((s = fgets(buffer, sizeof(buffer) - 1, fp)) != NULL) {
......@@ -539,14 +549,15 @@ pwr_tStatus redu_get_initial_state( char *nodename, int busid, int *state)
if ( strcmp( name, nodename) == 0) {
local_found = 1;
*state = atoi(s_state);
// *state = atoi(s_state);
*state = pwr_eRedundancyState_Init;
break;
}
}
fclose( fp);
if ( !local_found)
return 0;
return 1;
return REDU__LOCALNODE;
return REDU__SUCCESS;
}
......@@ -66,10 +66,12 @@ extern "C" {
typedef enum {
redu_eMsgType_Table,
redu_eMsgType_Cyclic
redu_eMsgType_Cyclic,
redu_eMsgType_TableRequest
} redu_eMsgType;
typedef enum {
redu_ePrio_0 = 0,
redu_ePrio_1 = 1,
redu_ePrio_2 = 2,
redu_ePrio_3 = 3,
......@@ -136,6 +138,7 @@ pwr_tStatus redu_create_message( redu_tCtx ctx, void **msg);
pwr_tStatus redu_unpack_message( redu_tCtx ctx, void *msg);
pwr_tStatus redu_receive_table( redu_tCtx ctx, void *table_msg);
pwr_tStatus redu_send_table( redu_tCtx ctx, void **table_msg);
pwr_tStatus redu_create_table_request_message( redu_tCtx ctx, void **msg);
int redu_init( redu_tCtx *ctx, pwr_sNode *nodep, pwr_sClass_RedcomPacket *packetp);
int redu_send( redu_tCtx ctx, void *msg, int size, unsigned int msg_id);
int redu_receive( redu_tCtx ctx, unsigned int timeout, int *size, void **msg);
......
......@@ -72,5 +72,6 @@ ininstep <initialize init steps> /error
iostalled <IO stalled, cyclesup delay detected> /fatal
ioread <IO stalled, io read error> /fatal
iowrite <IO stalled, io write error> /fatal
reduinit <Redundcancy init error> /error
reduinit <Redundancy init error> /error
reduconfig <Redundancy not configured> /error
.end
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2016 SSAB EMEA AB.
!
! This file is part of Proview.
!
! 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 Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. 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
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview 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 Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! rt_redu_msg.msg -- <short description>
!
.facility REDU,27 /prefix = REDU__
success <Successful completion> /succ
tablereceived <Table successfully received> /succ
tablecreated <Table successfully created> /succ
tablesent <Table sent> /succ
redcomfile <Unable to open redcom file> /error
localnode <Local node not found> /error
.end
......@@ -16,6 +16,7 @@
24 PROC
25 SEV
26 SIM
27 REDU
50 HD
100 CDH
101 NDC
......
......@@ -184,7 +184,7 @@ SObject pwrb:Class
!/**
! Disable.
!*/
Object Disable $Attribute 14
Object Disable $Attribute 15
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
......
......@@ -172,6 +172,7 @@ SObject pwrb:Class
Attr PgmName = "Action"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "act"
EndBody
......@@ -189,6 +190,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr GraphName = "ack"
EndBody
EndObject
......@@ -209,6 +211,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr GraphName = "blk"
EndBody
EndObject
......@@ -401,6 +404,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -412,6 +416,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -425,6 +430,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -438,6 +444,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -449,6 +456,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -462,6 +470,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -475,6 +484,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -487,6 +497,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -499,6 +510,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -565,6 +577,7 @@ SObject pwrb:Class
Body SysBody
Attr PgmName = "High"
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -590,6 +603,7 @@ SObject pwrb:Class
Attr PgmName = "TimerFlag"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
......@@ -614,6 +628,7 @@ SObject pwrb:Class
Attr PgmName = "TimerCount"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
......
......@@ -166,6 +166,7 @@ SObject pwrb:Class
Attr PgmName = "Action"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
......@@ -182,6 +183,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -201,6 +203,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
! ++
......@@ -228,6 +231,7 @@ SObject pwrb:Class
Body SysBody
Attr PgmName = "DetectOn"
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -383,6 +387,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -394,6 +399,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -407,6 +413,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -420,6 +427,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -431,6 +439,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -444,6 +453,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -457,6 +467,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -469,6 +480,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -481,6 +493,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -572,6 +585,7 @@ SObject pwrb:Class
Attr PgmName = "TimerFlag"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
......@@ -596,6 +610,7 @@ SObject pwrb:Class
Attr PgmName = "TimerCount"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
......
......@@ -175,6 +175,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr GraphName = "act"
EndBody
EndObject
......@@ -190,6 +191,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr GraphName = "ack"
EndBody
EndObject
......@@ -211,6 +213,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr GraphName = "blk"
EndBody
EndObject
......@@ -239,6 +242,7 @@ SObject pwrb:Class
Body SysBody
Attr PgmName = "DetectOn"
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -397,6 +401,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -408,6 +413,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -421,6 +427,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -434,6 +441,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -445,6 +453,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -458,6 +467,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -471,6 +481,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -483,6 +494,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -495,6 +507,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -554,6 +567,7 @@ SObject pwrb:Class
Attr PgmName = "TimerFlag"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
......@@ -578,6 +592,7 @@ SObject pwrb:Class
Attr PgmName = "TimerCount"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
......
......@@ -168,6 +168,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -182,6 +183,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -202,6 +204,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
! ++
......@@ -229,6 +232,7 @@ SObject pwrb:Class
Body SysBody
Attr PgmName = "DetectOn"
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -380,6 +384,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -391,6 +396,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -404,6 +410,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -417,6 +424,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -428,6 +436,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -441,6 +450,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -454,6 +464,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -466,6 +477,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -478,6 +490,7 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......@@ -537,6 +550,7 @@ SObject pwrb:Class
Attr PgmName = "TimerFlag"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
......@@ -561,6 +575,7 @@ SObject pwrb:Class
Attr PgmName = "TimerCount"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
......@@ -590,6 +605,7 @@ SObject pwrb:Class
Body SysBody
Attr PgmName = "TimerTime"
Attr TypeRef = "pwrs:Type-$Float32"
Attr Flags |= PWR_MASK_REDUTRANSFER
EndBody
EndObject
!/**
......
......@@ -64,7 +64,7 @@ SObject pwrb:Class
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_RTVIRTUAL
Attr Flags |= PWR_MASK_DEVBODYREF
Attr TypeRef = "pwrs:Type-$Float32"
Attr TypeRef = "pwrs:Type-$Int32"
Attr GraphName = "val"
EndBody
EndObject
......
......@@ -68,33 +68,60 @@ SObject pwrb:Class
EndBody
EndObject
!/**
! Link timeout time.
! If no messages in passive state is received within this
! time the link is regarded as down.
!*/
Object LinkTimeout $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Force state.
! State can only be changed from Active/Passive buttons in
! object graph. I will not automatically be changed by system
! events or errors.
!*/
Object Force $Attribute 4
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
!/**
! Set redundancy state Active.
!*/
Object SetActive $Attribute 3
Object SetActive $Attribute 5
Body SysBody
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
!/**
! Set redundancy state Passive.
!*/
Object SetPassive $Attribute 4
Object SetPassive $Attribute 6
Body SysBody
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
!/**
! Set redundancy state Off.
!*/
Object SetOff $Attribute 5
Object SetOff $Attribute 7
Body SysBody
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
!/**
! Link state.
!*/
Object Link $Attribute 6
Object Link $Attribute 8
Body SysBody
Attr Flags |= PWR_MASK_ARRAY
Attr Flags |= PWR_MASK_CLASS
......@@ -106,6 +133,7 @@ SObject pwrb:Class
Object Template RedcomConfig
Body RtBody
Attr CycleTime = 0.005
Attr LinkTimeout = 0.200
EndBody
EndObject
EndObject
......
......@@ -118,6 +118,16 @@ SObject pwrb:Class
EndBody
EndObject
!/**
! Table status.
!*/
Object TableStatus $Attribute 12
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Status"
EndBody
EndObject
!/**
! Number of attributes.
!*/
Object Attributes $Attribute 8
......
......@@ -76,6 +76,16 @@ SObject pwrs:Type
Attr Value = 2
EndBody
EndObject
!/**
! Initialization.
!*/
Object Init $Value
Body SysBody
Attr PgmName = "Init"
Attr Text = "Init"
Attr Value = 3
EndBody
EndObject
EndObject
EndSObject
......
......@@ -3610,9 +3610,11 @@ int gcg_get_outputstring (
}
/* Check that the object is not in a library hierarchy */
if ( gcg_in_libhier( gcgctx, *objdid)) {
gcg_error_msg( gcgctx, GSX__LIBREF, output_node);
free((char *) objdid);
return GSX__NEXTPAR;
if ( !gcg_in_libhier( gcgctx, output_node->ln.oid)) {
gcg_error_msg( gcgctx, GSX__LIBREF, output_node);
free((char *) objdid);
return GSX__NEXTPAR;
}
}
strcpy( parstring,
......@@ -3650,9 +3652,11 @@ int gcg_get_outputstring (
}
/* Check that object is not in a library hierarchy */
if ( gcg_in_libhier( gcgctx, attrref->Objid)) {
gcg_error_msg( gcgctx, GSX__LIBREF, output_node);
free((char *) attrref);
return GSX__NEXTPAR;
if ( !gcg_in_libhier( gcgctx, output_node->ln.oid)) {
gcg_error_msg( gcgctx, GSX__LIBREF, output_node);
free((char *) attrref);
return GSX__NEXTPAR;
}
}
strcpy( parstring,
......@@ -3780,9 +3784,11 @@ static int gcg_get_outputstring_spec(
}
/* Check that the object is not in a library hierarchy */
if ( gcg_in_libhier( gcgctx, attrref->Objid)) {
gcg_error_msg( gcgctx, GSX__LIBREF, output_node);
free((char *) attrref);
return GSX__NEXTPAR;
if ( !gcg_in_libhier( gcgctx, output_node->ln.oid)) {
gcg_error_msg( gcgctx, GSX__LIBREF, output_node);
free((char *) attrref);
return GSX__NEXTPAR;
}
}
/* Get the attribute name of last segment */
......@@ -3842,9 +3848,11 @@ static int gcg_get_outputstring_spec(
}
/* Check that the object is not in a library hierarchy */
if ( gcg_in_libhier( gcgctx, attrref->Objid)) {
gcg_error_msg( gcgctx, GSX__LIBREF, output_node);
free((char *) attrref);
return GSX__NEXTPAR;
if ( !gcg_in_libhier( gcgctx, output_node->ln.oid)) {
gcg_error_msg( gcgctx, GSX__LIBREF, output_node);
free((char *) attrref);
return GSX__NEXTPAR;
}
}
strcpy( parstring,
......@@ -3895,9 +3903,11 @@ static int gcg_get_outputstring_spec(
}
/* Check that the object is not in a library hierarchy */
if ( gcg_in_libhier( gcgctx, attrref->Objid)) {
gcg_error_msg( gcgctx, GSX__LIBREF, output_node);
free((char *) attrref);
return GSX__NEXTPAR;
if ( !gcg_in_libhier( gcgctx, output_node->ln.oid)) {
gcg_error_msg( gcgctx, GSX__LIBREF, output_node);
free((char *) attrref);
return GSX__NEXTPAR;
}
}
/* Get the attribute name of last segment */
......@@ -3998,9 +4008,11 @@ static int gcg_get_outputstring_spec(
}
/* Check that the object is not in a library hierarchy */
if ( gcg_in_libhier( gcgctx, attrref->Objid)) {
gcg_error_msg( gcgctx, GSX__LIBREF, output_node);
free((char *) attrref);
return GSX__NEXTPAR;
if ( !gcg_in_libhier( gcgctx, output_node->ln.oid)) {
gcg_error_msg( gcgctx, GSX__LIBREF, output_node);
free((char *) attrref);
return GSX__NEXTPAR;
}
}
/* Check if DisableAttr is present */
......
......@@ -44,7 +44,7 @@
117 0
118 134
119 112
120 1
120 0
121 Claes context
122 0
126 0.5
......@@ -7391,12 +7391,21 @@ pwr_exe:
102 35454972
103 0
61
6100
6101 3
6102 4
6103 470
6104 2
6105 1
6106 0
99
61
6100 $node.RedundancyState##Int32
6101 2
6102 4
6103 410
6104 1
6105 1
6105 3
6106 0
99
12
......
......@@ -766,6 +766,7 @@ pwr_tStatus Ev::mh_alarmstatus_bc( mh_sAlarmStatus *MsgP)
brow_GetObjectList( ev->ala->browbase->ctx, &object_list, &object_cnt);
ev->ala->size = object_cnt;
// Reset check to find obsolete items
for ( i = 0; i < object_cnt; i++) {
......@@ -839,6 +840,7 @@ pwr_tStatus Ev::mh_alarmstatus_bc( mh_sAlarmStatus *MsgP)
case evlist_eItemType_Alarm:
if ( MsgP->Nix == item->eventid.Nix && !item->check) {
ev->ala->event_delete( &item->eventid);
printf( "Sts ala del %d,%d\n", item->eventid.Nix, item->eventid.Idx);
for ( int k = 0; k < ev->sala_cnt; k++)
ev->sala[k]->event_delete( &item->eventid);
i--;
......
......@@ -924,6 +924,8 @@ void EvList::event_alarm( mh_sMessage *msg)
ItemAlarm *dest;
flow_eDest dest_code;
brow_tNode dest_node;
ItemAlarm *item;
if ( type == ev_eType_AlarmList ) {
if ( !( msg->Status & mh_mEventStatus_NotAck ||
......@@ -931,12 +933,18 @@ void EvList::event_alarm( mh_sMessage *msg)
return;
// Check that this id not already inserted
ItemAlarm *item;
if ( id_to_item( &event->Info.Id, (void **)&item))
return;
}
if ( type != ev_eType_HistList ) {
// Check that this id not already inserted
if ( id_to_item( &event->Info.Id, (void **)&item))
return;
if ( type != ev_eType_EventList )
printf( "New ala %d,%d\n", event->Info.Id.Nix, event->Info.Id.Idx);
sts = get_destination( net_NetTimeToTime( &event->Info.EventTime), (void **)&dest);
if ( EVEN(sts)) {
dest_code = flow_eDest_IntoLast;
......@@ -952,7 +960,7 @@ void EvList::event_alarm( mh_sMessage *msg)
dest_node = NULL;
}
ItemAlarm *item = new ItemAlarm( this, "Alarm",
item = new ItemAlarm( this, "Alarm",
net_NetTimeToTime( &event->Info.EventTime), event->Msg.EventText,
event->Msg.EventName, event->Info.EventType, event->Info.EventFlags,
event->Info.EventPrio, event->Info.Id,
......@@ -1129,11 +1137,17 @@ void EvList::event_ack( mh_sAck *msg)
ala_uEvent *event = (ala_uEvent *) msg;
int sts;
ItemAlarm *dest;
ItemAlarm *item;
flow_eDest dest_code;
brow_tNode dest_node;
if ( type == ev_eType_EventList || type == ev_eType_HistList) {
if(type == ev_eType_EventList) {
// Check that this id not already inserted
if ( id_to_item( &event->Info.Id, (void **)&item))
return;
printf( "New ack %d,%d\n", event->Info.Id.Nix, event->Info.Id.Idx);
sts = get_destination( net_NetTimeToTime( &event->Info.EventTime), (void **)&dest);
if ( EVEN(sts)) {
dest_code = flow_eDest_IntoLast;
......@@ -1217,11 +1231,17 @@ void EvList::event_return( mh_sReturn *msg)
ala_uEvent *event = (ala_uEvent *) msg;
int sts;
ItemAlarm *dest;
ItemAlarm *item;
flow_eDest dest_code;
brow_tNode dest_node;
if ( type == ev_eType_EventList || type == ev_eType_HistList) {
if(type == ev_eType_EventList) {
// Check that this id not already inserted
if ( id_to_item( &event->Info.Id, (void **)&item))
return;
printf( "New ret %d,%d\n", event->Info.Id.Nix, event->Info.Id.Idx);
sts = get_destination( net_NetTimeToTime( &event->Info.EventTime), (void **)&dest);
if ( EVEN(sts)) {
dest_code = flow_eDest_IntoLast;
......@@ -1920,17 +1940,21 @@ ItemAlarm::ItemAlarm( EvList *item_evlist, const char *item_name, pwr_tTime item
sts = brow_GetLast( evlist->browbase->ctx, &last_node);
if ( ODD(sts))
{
if ( node == last_node)
// I'm deleting myself
*rsts = 0;
brow_GetUserData( last_node, (void **)&item);
brow_tNode tree_node = item->tree_node;
evlist_eItemType item_type = item->type;
brow_DeleteNode( evlist->browbase->ctx, last_node);
if ( item->type == evlist_eItemType_Alarm && evlist->browtree) {
if ( item->tree_node)
brow_DeleteNode( evlist->browtree->ctx, item->tree_node);
evlist->view_configure();
if ( item_type == evlist_eItemType_Alarm && item_evlist->browtree) {
if ( tree_node)
brow_DeleteNode( item_evlist->browtree->ctx, tree_node);
item_evlist->view_configure();
}
// Note! This ItemAlarm might be deleted by now if node == last_node
......@@ -2784,8 +2808,7 @@ int EvList::id_to_item( mh_sEventId *id, void **item)
brow_GetUserData( object_list[i], (void **)&object_item);
switch( object_item->type) {
case evlist_eItemType_Alarm:
if ( memcmp( &object_item->eventid, id, sizeof(object_item->eventid))
== 0) {
if ( object_item->eventid.Idx == id->Idx && object_item->eventid.Nix == id->Nix) {
*item = (void *)object_item;
return 1;
}
......
......@@ -295,8 +295,19 @@ int XNav::show_nethandler()
t.elem_cnt = 0;
// Node name
strcpy( t.elem[t.elem_cnt].fix_str, np->name);
t.elem[t.elem_cnt++].type_id = xnav_eType_FixStr;
//strcpy( t.elem[t.elem_cnt].fix_str, np->name);
//t.elem[t.elem_cnt++].type_id = xnav_eType_FixStr;
if (np == gdbroot->my_node) {
// Local node
strcpy( t.elem[t.elem_cnt].fix_str, np->name);
t.elem[t.elem_cnt++].type_id = xnav_eType_FixStr;
}
else {
t.elem[t.elem_cnt].value_p = np->name;
t.elem[t.elem_cnt].type_id = pwr_eType_String;
t.elem[t.elem_cnt].size = sizeof(np->name);
strcpy( t.elem[t.elem_cnt++].format, "%s");
}
// Os
switch ( np->hw) {
......
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