Commit c5baaec8 authored by Claes Sjofors's avatar Claes Sjofors

Redundance communication 4

parent 4498447d
...@@ -5547,9 +5547,14 @@ static pwr_tStatus emon_redu_receive() ...@@ -5547,9 +5547,14 @@ static pwr_tStatus emon_redu_receive()
l.redu->packetp->UnpackTime = l.redu->msg_time; l.redu->packetp->UnpackTime = l.redu->msg_time;
} }
break;
case redu_eMsgType_TableVersionRequest:
sts = redu_send_table_version( l.redu);
break;
case redu_eMsgType_TableVersion:
break; break;
default: default:
printf( "Redu: Unknown message type\n"); printf( "Redu: Unknown message type %d\n", ((redu_sHeader *)msg)->type);
} }
qcom_Free( &sts, msg); qcom_Free( &sts, msg);
return MH__SUCCESS; return MH__SUCCESS;
......
...@@ -141,6 +141,7 @@ ...@@ -141,6 +141,7 @@
# define cPrio_remotelogg (cPrio_base + 5) # define cPrio_remotelogg (cPrio_base + 5)
# define cPrio_sim (cPrio_base + 5) # define cPrio_sim (cPrio_base + 5)
# define cPrio_videomgm (cPrio_base + 5) # define cPrio_videomgm (cPrio_base + 5)
# define cPrio_redcom (cPrio_base + 17)
#endif #endif
static pwr_tBoolean checkSect (pwr_tStatus*, ini_sContext*, int, int); static pwr_tBoolean checkSect (pwr_tStatus*, ini_sContext*, int, int);
...@@ -2135,6 +2136,9 @@ ini_ProcTable ( ...@@ -2135,6 +2136,9 @@ ini_ProcTable (
pp = ini_ProcInsert(sts, cp, "pwr_videomgm", "pwr_videomgm_%d", 0, 1, "rt_videomgm", cPrio_videomgm, 0, pwr_cClass_VideoMgmServer, "", 0); pp = ini_ProcInsert(sts, cp, "pwr_videomgm", "pwr_videomgm_%d", 0, 1, "rt_videomgm", cPrio_videomgm, 0, pwr_cClass_VideoMgmServer, "", 0);
pp->proc.flags.b.system = 1; pp->proc.flags.b.system = 1;
pp = ini_ProcInsert(sts, cp, "pwr_redcom", "pwr_redcom_%d", 0, 1, "rt_redcom", cPrio_redcom, 0, pwr_cClass_RedcomConfig, "", 0);
pp->proc.flags.b.system = 1;
pp = ini_ProcInsert(sts, cp, "pwr_sim", "pwr_sim_%d", 0, 1, "rt_sim", cPrio_sim, 0, pwr_cClass_SimulateConfig, "", 0); pp = ini_ProcInsert(sts, cp, "pwr_sim", "pwr_sim_%d", 0, 1, "rt_sim", cPrio_sim, 0, pwr_cClass_SimulateConfig, "", 0);
pp->proc.flags.b.system = 1; pp->proc.flags.b.system = 1;
#endif #endif
......
...@@ -210,10 +210,6 @@ start ( ...@@ -210,10 +210,6 @@ start (
ini_SetSystemStatus( cp, PWR__STARTUP); ini_SetSystemStatus( cp, PWR__STARTUP);
errh_SetStatus( PWR__STARTUP); errh_SetStatus( PWR__STARTUP);
sts = redu_get_initial_state( cp->nodename, cp->busid, &state);
if ( ODD(sts))
cp->np->RedundancyState = state;
sts = ini_RcReadAndSet(cp->dir, cp->nodename, cp->busid); sts = ini_RcReadAndSet(cp->dir, cp->nodename, cp->busid);
if (EVEN(sts)) if (EVEN(sts))
errh_LogError(&cp->log, "ini_RcReadAndSet, %m", sts); errh_LogError(&cp->log, "ini_RcReadAndSet, %m", sts);
...@@ -224,6 +220,12 @@ start ( ...@@ -224,6 +220,12 @@ start (
qini_BuildDb(&sts, cp->nid_t, cp->me, NULL, cp->busid); qini_BuildDb(&sts, cp->nid_t, cp->me, NULL, cp->busid);
sts = redu_get_initial_state( cp->nodename, cp->busid, &state);
if ( ODD(sts)) {
cp->np->RedundancyState = state;
qcom_SetRedundancyState( state);
}
io_init_signals(); io_init_signals();
load_backup(); load_backup();
......
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
#include "rt_cvolcm.h" #include "rt_cvolcm.h"
#include "rt_cbuf.h" #include "rt_cbuf.h"
#include "rt_pwr_msg.h" #include "rt_pwr_msg.h"
#include "co_timelog.h"
/* Declare routines used by main. */ /* Declare routines used by main. */
...@@ -490,8 +491,7 @@ id ( ...@@ -490,8 +491,7 @@ id (
errh_Info("Received '%s' from nid %s", errh_Info("Received '%s' from nid %s",
cMsg[get->type.s], cdh_NodeIdToString(NULL, mp->hdr.nid, 0, 0)); cMsg[get->type.s], cdh_NodeIdToString(NULL, mp->hdr.nid, 0, 0));
} }
printf("Id Received '%s' from nid %s\n", timelog_ss( 1, "Neth Id received from nid", cdh_NodeIdToString(NULL, mp->hdr.nid, 0, 0));
cMsg[get->type.s], cdh_NodeIdToString(NULL, mp->hdr.nid, 0, 0));
if (get->sender.nid == gdbroot->my_qid.nid && mp->hdr.nid == gdbroot->db->nid) { if (get->sender.nid == gdbroot->my_qid.nid && mp->hdr.nid == gdbroot->db->nid) {
errh_Error("New node using nid %s, conflicts with local node, '%s' ignored", errh_Error("New node using nid %s, conflicts with local node, '%s' ignored",
...@@ -936,8 +936,7 @@ sendId ( ...@@ -936,8 +936,7 @@ sendId (
errh_Info("Sending 'id' to %s (%s)", errh_Info("Sending 'id' to %s (%s)",
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0)); np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0));
} }
printf("Sending 'id' to %s (%s)\n", timelog_ss( 1, "Neth sending 'id' to", np->name);
np->name, cdh_NodeIdToString(NULL, np->nid, 0, 0));
if ( np->handler.nid) if ( np->handler.nid)
tgt = np->handler; tgt = np->handler;
......
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
#include "rt_pwr_msg.h" #include "rt_pwr_msg.h"
#include "rt_ini_event.h" #include "rt_ini_event.h"
#include "rt_qmon.h" #include "rt_qmon.h"
#include "co_timelog.h"
#if 1 #if 1
# define MAX_SEGSIZE (8192 - sizeof(sHead)) # define MAX_SEGSIZE (8192 - sizeof(sHead))
...@@ -671,12 +672,16 @@ create_connect ( ...@@ -671,12 +672,16 @@ create_connect (
{ {
sEseg *sp; sEseg *sp;
printf( "Create connect %d\n", qdb->my_node->redundancy_state);
sp = eseg_alloc(&l.eseg.mutex); sp = eseg_alloc(&l.eseg.mutex);
if ( qdb->my_node->redundancy_state == pwr_eRedundancyState_Passive) if ( qdb->my_node->redundancy_state == pwr_eRedundancyState_Passive ||
qdb->my_node->redundancy_state == pwr_eRedundancyState_Init) {
sp->head.flags.b.event = eEvent_connectPassive; sp->head.flags.b.event = eEvent_connectPassive;
else timelog( 1, "qmon sending connect Passive");
}
else {
sp->head.flags.b.event = eEvent_connect; sp->head.flags.b.event = eEvent_connect;
timelog( 1, "qmon sending connect");
}
sp->lp = lp; sp->lp = lp;
sp->c.action = eAction_export; sp->c.action = eAction_export;
...@@ -1386,14 +1391,14 @@ link_connect ( ...@@ -1386,14 +1391,14 @@ link_connect (
if ( sp->head.flags.b.event == eEvent_connect) if ( sp->head.flags.b.event == eEvent_connect)
lp->np->clx = lp->lix; lp->np->clx = lp->lix;
else if ( sp->head.flags.b.event == eEvent_connectPassive && else if ( sp->head.flags.b.event == eEvent_connectPassive) {
lp->np->clx == lp->lix) { if ( lp->np->clx == lp->lix) {
if ( lp->lix == 1) if ( lp->lix == 1)
lp->np->clx = 0; lp->np->clx = 0;
else if ( lp->lix == 0 && lp->np->link_cnt > 1) else if ( lp->lix == 0 && lp->np->link_cnt > 1)
lp->np->clx = 1; lp->np->clx = 1;
}
} }
lp->np->link[lp->lix].flags.b.active = 1; lp->np->link[lp->lix].flags.b.active = 1;
if (lp->np->link[lp->lix].flags.b.connected) if (lp->np->link[lp->lix].flags.b.connected)
...@@ -1408,7 +1413,7 @@ link_connect ( ...@@ -1408,7 +1413,7 @@ link_connect (
lp->np->link[lp->lix].qflags.b.connected = 1; lp->np->link[lp->lix].qflags.b.connected = 1;
lp->np->link[lp->lix].qflags.b.active = 1; lp->np->link[lp->lix].qflags.b.active = 1;
set_link_info(lp, (qdb_sLinkInfo *)sp->buff); set_link_info(lp, (qdb_sLinkInfo *)sp->buff);
if ( lp->np->clx == lp->lix) if ( lp->np->clx == lp->lix && sp->head.flags.b.event == eEvent_connect)
qdb_NetEvent(&sts, lp->np, qcom_eStype_linkConnect); qdb_NetEvent(&sts, lp->np, qcom_eStype_linkConnect);
} qdb_ScopeUnlock; } qdb_ScopeUnlock;
...@@ -1590,8 +1595,13 @@ link_import ( ...@@ -1590,8 +1595,13 @@ link_import (
) )
{ {
//if ( IS_SECONDARY_NID(lp->nid)) #if 0
// printf( "link_import %d\n", lp->nid); if ( IS_SECONDARY_NID(lp->nid)) {
char msg[80];
sprintf( msg, "From secondary %s %d", cdh_NodeIdToString(NULL, lp->np->nid, 0, 0), sp->head.flags.b.event);
timelog( 1, msg);
}
#endif
if (!lp->np->link[lp->lix].flags.b.active && lp->np->link[lp->lix].birth == sp->head.birth) if (!lp->np->link[lp->lix].flags.b.active && lp->np->link[lp->lix].birth == sp->head.birth)
link_active(lp); link_active(lp);
...@@ -1622,6 +1632,7 @@ link_import ( ...@@ -1622,6 +1632,7 @@ link_import (
break; break;
case eEvent_connect: case eEvent_connect:
case eEvent_connectPassive: case eEvent_connectPassive:
timelog_ss( 1, "Qmon connect received from", lp->np->link[lp->lix].name);
link_connect(lp, sp); link_connect(lp, sp);
lack(lp, sp); lack(lp, sp);
set_rack(lp, sp); set_rack(lp, sp);
...@@ -1631,13 +1642,13 @@ link_import ( ...@@ -1631,13 +1642,13 @@ link_import (
lack(lp, sp); lack(lp, sp);
set_rack(lp, sp); set_rack(lp, sp);
link_redcom_active(lp, sp); link_redcom_active(lp, sp);
printf( "Active from %s\n", lp->np->link[lp->lix].name); timelog_ss( 1, "Active received from", lp->np->link[lp->lix].name);
break; break;
case eEvent_redcomPassive: case eEvent_redcomPassive:
lack(lp, sp); lack(lp, sp);
set_rack(lp, sp); set_rack(lp, sp);
link_redcom_passive(lp, sp); link_redcom_passive(lp, sp);
printf( "Passive from %s\n", lp->np->link[lp->lix].name); timelog_ss( 1, "Passive received from", lp->np->link[lp->lix].name);
break; break;
default: default:
break; break;
...@@ -2393,8 +2404,6 @@ action_thread () ...@@ -2393,8 +2404,6 @@ action_thread ()
switch ( get.type.s) { switch ( get.type.s) {
case qmon_eMsgTypeAction_NodeActive: case qmon_eMsgTypeAction_NodeActive:
case qmon_eMsgTypeAction_NodePassive: case qmon_eMsgTypeAction_NodePassive:
printf( "Node active\n");
for (lp = tree_Minimum(&sts, l.links.table); lp != NULL; lp = tree_Successor(&sts, l.links.table, lp)) for (lp = tree_Minimum(&sts, l.links.table); lp != NULL; lp = tree_Successor(&sts, l.links.table, lp))
send_action( lp, get.type.s); send_action( lp, get.type.s);
...@@ -2423,9 +2432,11 @@ send_action ( ...@@ -2423,9 +2432,11 @@ send_action (
sp = eseg_alloc(&l.eseg.mutex); sp = eseg_alloc(&l.eseg.mutex);
switch ( action) { switch ( action) {
case qmon_eMsgTypeAction_NodeActive: case qmon_eMsgTypeAction_NodeActive:
timelog( 1, "qmon send NodeActive");
sp->head.flags.b.event = eEvent_redcomActive; sp->head.flags.b.event = eEvent_redcomActive;
break; break;
case qmon_eMsgTypeAction_NodePassive: case qmon_eMsgTypeAction_NodePassive:
timelog( 1, "qmon send NodePassive");
sp->head.flags.b.event = eEvent_redcomPassive; sp->head.flags.b.event = eEvent_redcomPassive;
break; break;
} }
......
This diff is collapsed.
/*
* 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.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "co_timelog.h"
#include "co_time.h"
/* 1 redcom connect */
/* 2 redcom tables */
/* 4 alarms and events */
unsigned int tmlog = 1;
void tm_log( unsigned int level, const char *func, const char *str)
{
char logstr[200];
int i;
time_AtoAscii( NULL, time_eFormat_DateAndTime, logstr, sizeof(logstr));
strcat( logstr, " ");
strcat( logstr, func);
for ( i = strlen(func); i < 25; i++)
strcat( logstr, " ");
strcat( logstr, str);
printf( "%s\n", logstr);
}
void tm_log_ss( unsigned int level, const char *func, const char *str1, const char *str2)
{
char logstr[200];
int i;
time_AtoAscii( NULL, time_eFormat_DateAndTime, logstr, sizeof(logstr));
strcat( logstr, " ");
strcat( logstr, func);
for ( i = strlen(func); i < 25; i++)
strcat( logstr, " ");
strcat( logstr, str1);
strcat( logstr, " ");
strcat( logstr, str2);
printf( "%s\n", logstr);
}
void tm_log_sii( unsigned int level, const char *func, const char *str, int i1, int i2)
{
char logstr[200];
int i;
time_AtoAscii( NULL, time_eFormat_DateAndTime, logstr, sizeof(logstr));
strcat( logstr, " ");
strcat( logstr, func);
for ( i = strlen(func); i < 25; i++)
strcat( logstr, " ");
strcat( logstr, str);
printf( "%s %d %d\n", logstr, i1, i2);
}
/*
* 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.
*/
#ifndef co_timelog_h
#define co_timelog_h
#if defined __cplusplus
extern "C" {
#endif
extern unsigned int tmlog;
#define timelog( level, str) if (tmlog & level) tm_log( level, __func__, str);
#define timelog_ss( level, str1, str2) if (tmlog & level) tm_log_ss( level, __func__, str1, str2);
#define timelog_sii( level, str, i1, i2) if (tmlog & level) tm_log_sii( level, __func__, str, i1, i2);
void tm_log( unsigned int level, const char *func, const char *str);
void tm_log_ss( unsigned int level, const char *func, const char *str1, const char *str2);
void tm_log_sii( unsigned int level, const char *func, const char *str, int i1, int i2);
#if defined __cplusplus
}
#endif
#endif
...@@ -71,7 +71,7 @@ pwrs_Node_Exec ( ...@@ -71,7 +71,7 @@ pwrs_Node_Exec (
static int supervise[110] = { static int supervise[110] = {
0,0,0,0,1,1,1,0,1,1, 0,0,0,0,1,1,1,0,1,1,
1,1,1,0,0,1,0,1,1,1, 1,1,1,0,0,1,0,1,1,1,
1,1,1,0,0,1,0,0,0,0, 1,1,1,0,0,1,1,0,0,0,
0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,
......
...@@ -126,6 +126,7 @@ typedef enum { ...@@ -126,6 +126,7 @@ typedef enum {
errh_eAnix_sim = 24, errh_eAnix_sim = 24,
errh_eAnix_powerlink = 25, errh_eAnix_powerlink = 25,
errh_eAnix_videomgm = 26, errh_eAnix_videomgm = 26,
errh_eAnix_redcom = 27,
errh_eAnix_plc1 = 41, errh_eAnix_plc1 = 41,
errh_eAnix_plc2 = 42, errh_eAnix_plc2 = 42,
errh_eAnix_plc3 = 43, errh_eAnix_plc3 = 43,
......
...@@ -193,6 +193,7 @@ struct plc_sThread { ...@@ -193,6 +193,7 @@ struct plc_sThread {
unsigned int sim_halted; unsigned int sim_halted;
unsigned int sim_singlestep; unsigned int sim_singlestep;
pwr_tRedundancyStateEnum redu_state_old; pwr_tRedundancyStateEnum redu_state_old;
int redu_table_version_req_sent;
redu_tCtx redu; redu_tCtx redu;
}; };
......
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
#define USE_RT_TIMER 0 #define USE_RT_TIMER 0
static void scan (plc_sThread*); static void scan (plc_sThread*);
static pwr_tStatus plc_redu_send_table( plc_sThread *tp);
static pwr_tStatus plc_redu_init( plc_sThread *tp) static pwr_tStatus plc_redu_init( plc_sThread *tp)
{ {
...@@ -119,12 +120,11 @@ static pwr_tStatus plc_redu_init( plc_sThread *tp) ...@@ -119,12 +120,11 @@ static pwr_tStatus plc_redu_init( plc_sThread *tp)
return PLC__REDUCONFIG; return PLC__REDUCONFIG;
} }
static pwr_tStatus plc_redu_receive( plc_sThread *tp) static pwr_tStatus plc_redu_receive( plc_sThread *tp, unsigned int timeout)
{ {
pwr_tStatus sts; pwr_tStatus sts;
void *msg; void *msg;
int size; int size;
unsigned int timeout = tp->i_scan_time;
sts = redu_receive( tp->redu, timeout, &size, &msg); sts = redu_receive( tp->redu, timeout, &size, &msg);
if ( sts == QCOM__TMO) if ( sts == QCOM__TMO)
...@@ -138,42 +138,60 @@ static pwr_tStatus plc_redu_receive( plc_sThread *tp) ...@@ -138,42 +138,60 @@ static pwr_tStatus plc_redu_receive( plc_sThread *tp)
redu_free_table( tp->redu); redu_free_table( tp->redu);
sts = redu_receive_table( tp->redu, msg); sts = redu_receive_table( tp->redu, msg);
if ( tp->redu->packetp) if ( tp->redu->packetp) {
tp->redu->packetp->TableStatus = sts; tp->redu->packetp->TableStatus = sts;
if ( EVEN(sts)) return sts; tp->redu->packetp->TableVersion = tp->redu->table_version;
}
if ( EVEN(sts)) {
qcom_Free( &sts, msg);
return sts;
}
tp->redu->table_sent = 1; tp->redu->table_sent = 1;
break; break;
case redu_eMsgType_Cyclic: case redu_eMsgType_Cyclic:
if ( tp->redu->packetp) if ( tp->redu->packetp)
tp->redu->packetp->PacketSize = size; tp->redu->packetp->PacketSize = size;
sts = redu_unpack_message( tp->redu, msg); sts = redu_unpack_message( tp->redu, msg);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) {
qcom_Free( &sts, msg);
return sts;
}
break; break;
case redu_eMsgType_TableRequest: { case redu_eMsgType_TableRequest: {
void *table_msg; sts = plc_redu_send_table( tp);
if ( ODD(sts))
tp->redu->table_sent = 1;
break;
}
case redu_eMsgType_TableVersionRequest: {
sts = redu_send_table_version( tp->redu);
break;
}
case redu_eMsgType_TableVersion: {
int tsts;
pwr_tTime table_version;
if ( !tp->redu->table_sent) { tp->redu_table_version_req_sent = 0;
sts = redu_create_table( tp->redu); if ( tp->redu->table_version.tv_sec == 0)
if ( tp->redu->packetp) table_version = tp->redu->nodep->CurrentVersion;
tp->redu->packetp->TableStatus = sts; else
if ( EVEN(sts)) return sts; table_version = tp->redu->table_version;
tsts = time_Acomp_NE( &table_version, &((redu_sMsgTableVersion *)msg)->version);
if ( tsts == 0)
sts = redu_send_table_request( tp->redu);
else {
sts = plc_redu_send_table( tp);
if ( EVEN(sts)) {
qcom_Free( &sts, msg);
return sts;
}
tp->redu->table_sent = 1;
} }
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; break;
} }
default: default:
printf( "Redu: Unknown message type\n"); printf( "Redu: Unknown message type %d\n", ((redu_sHeader *)msg)->type);
} }
qcom_Free( &sts, msg); qcom_Free( &sts, msg);
return PLC__SUCCESS; return PLC__SUCCESS;
...@@ -190,30 +208,52 @@ static pwr_tStatus plc_redu_receive_active( plc_sThread *tp) ...@@ -190,30 +208,52 @@ static pwr_tStatus plc_redu_receive_active( plc_sThread *tp)
switch ( ((redu_sHeader *)msg)->type) { switch ( ((redu_sHeader *)msg)->type) {
break; break;
case redu_eMsgType_TableRequest: { case redu_eMsgType_Table:
void *table_msg; if ( tp->redu->t)
redu_free_table( tp->redu);
if ( !tp->redu->table_sent) {
sts = redu_create_table( tp->redu); sts = redu_receive_table( tp->redu, msg);
if ( tp->redu->packetp) 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; tp->redu->packetp->TableStatus = sts;
if ( EVEN(sts)) return sts; tp->redu->packetp->TableVersion = tp->redu->table_version;
}
sts = redu_send( tp->redu, table_msg, if ( EVEN(sts)) {
((redu_sTableMsgHeader *)table_msg)->size + sizeof( redu_sTableMsgHeader), qcom_Free( &sts, msg);
tp->redu->msgid_table); return sts;
}
tp->redu->table_sent = 1;
break;
case redu_eMsgType_Cyclic:
break;
case redu_eMsgType_TableRequest: {
sts = plc_redu_send_table( tp);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
tp->redu->table_sent = 1; tp->redu->table_sent = 1;
break; break;
} }
case redu_eMsgType_Table: case redu_eMsgType_TableVersionRequest: {
case redu_eMsgType_Cyclic: sts = redu_send_table_version( tp->redu);
break; break;
}
case redu_eMsgType_TableVersion: {
int tsts;
pwr_tTime table_version;
if ( tp->redu->table_version.tv_sec == 0)
table_version = tp->redu->nodep->CurrentVersion;
else
table_version = tp->redu->table_version;
tsts = time_Acomp_NE( &table_version, &((redu_sMsgTableVersion *)msg)->version);
if ( tsts == 0)
sts = redu_send_table_request( tp->redu);
else {
sts = plc_redu_send_table( tp);
if ( ODD(sts))
tp->redu->table_sent = 1;
}
break;
}
default: default:
printf( "Redu: Unknown message type\n"); printf( "Redu: Unknown message type\n");
} }
...@@ -221,27 +261,41 @@ static pwr_tStatus plc_redu_receive_active( plc_sThread *tp) ...@@ -221,27 +261,41 @@ static pwr_tStatus plc_redu_receive_active( plc_sThread *tp)
return PLC__SUCCESS; return PLC__SUCCESS;
} }
static pwr_tStatus plc_redu_send( plc_sThread *tp) static pwr_tStatus plc_redu_send_table( plc_sThread *tp)
{ {
void *table_msg;
pwr_tStatus sts; pwr_tStatus sts;
void *msg;
if ( !tp->redu->table_sent) {
void *table_msg;
if ( !tp->redu->table_created) {
sts = redu_create_table( tp->redu); sts = redu_create_table( tp->redu);
if ( tp->redu->packetp) if ( tp->redu->packetp) {
tp->redu->packetp->TableStatus = sts; tp->redu->packetp->TableStatus = sts;
tp->redu->packetp->TableVersion = tp->redu->table_version;
}
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
tp->redu->table_created = 1;
}
sts = redu_send_table( tp->redu, &table_msg); sts = redu_send_table( tp->redu, &table_msg);
if ( tp->redu->packetp) if ( tp->redu->packetp)
tp->redu->packetp->TableStatus = sts; tp->redu->packetp->TableStatus = sts;
if ( EVEN(sts)) return 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);
free( table_msg);
return sts;
}
sts = redu_send( tp->redu, table_msg, static pwr_tStatus plc_redu_send( plc_sThread *tp)
((redu_sTableMsgHeader *)table_msg)->size + sizeof( redu_sTableMsgHeader), {
tp->redu->msgid_table); pwr_tStatus sts;
void *msg;
if ( !tp->redu->table_sent) {
sts = plc_redu_send_table( tp);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
tp->redu->table_sent = 1; tp->redu->table_sent = 1;
} }
...@@ -260,21 +314,6 @@ static pwr_tStatus plc_redu_send( plc_sThread *tp) ...@@ -260,21 +314,6 @@ static pwr_tStatus plc_redu_send( plc_sThread *tp)
return sts; 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 void
plc_thread ( plc_thread (
...@@ -565,13 +604,17 @@ scan ( ...@@ -565,13 +604,17 @@ scan (
if ( tp->redu && tp->pp->Node->RedundancyState == pwr_eRedundancyState_Passive) { 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) { if ( tp->redu_state_old == pwr_eRedundancyState_Off || tp->redu_state_old == pwr_eRedundancyState_Init) {
/* Send table request */ /* Send table version request to see if table should be requested or sent */
sts = plc_redu_send_table_request( tp); if ( !tp->redu_table_version_req_sent) {
sts = redu_send_table_version_request( tp->redu);
if ( ODD(sts))
tp->redu_table_version_req_sent = 1;
}
} }
time_GetTimeMonotonic(&tp->before_scan); time_GetTimeMonotonic(&tp->before_scan);
time_GetTime(&tp->before_scan_abs); time_GetTime(&tp->before_scan_abs);
sts = plc_redu_receive( tp); sts = plc_redu_receive( tp, tp->i_scan_time);
if ( EVEN(sts)) return; if ( EVEN(sts)) return;
time_Aadd(NULL, &tp->sync_time, &tp->scan_time); time_Aadd(NULL, &tp->sync_time, &tp->scan_time);
...@@ -594,6 +637,9 @@ scan ( ...@@ -594,6 +637,9 @@ scan (
if ( !tp->redu || (tp->pp->Node->RedundancyState != pwr_eRedundancyState_Passive)) { if ( !tp->redu || (tp->pp->Node->RedundancyState != pwr_eRedundancyState_Passive)) {
if ( tp->redu_state_old == pwr_eRedundancyState_Passive && tp->redu)
sts = plc_redu_receive( tp, 0);
if (pp->IOHandler->IOReadWriteFlag) { if (pp->IOHandler->IOReadWriteFlag) {
if ( tp->redu_state_old == pwr_eRedundancyState_Passive) if ( tp->redu_state_old == pwr_eRedundancyState_Passive)
tp->plc_io_ctx->read_reset = 1; tp->plc_io_ctx->read_reset = 1;
...@@ -607,8 +653,8 @@ scan ( ...@@ -607,8 +653,8 @@ scan (
errh_Error("IO read, %m", sts); errh_Error("IO read, %m", sts);
errh_SetStatus( PLC__IOREAD); errh_SetStatus( PLC__IOREAD);
} }
tp->redu_state_old = tp->pp->Node->RedundancyState;
} }
tp->redu_state_old = tp->pp->Node->RedundancyState;
if ( pp->Node->EmergBreakTrue && !tp->emergency_break_old) if ( pp->Node->EmergBreakTrue && !tp->emergency_break_old)
io_swap(tp->plc_io_ctx, io_eEvent_EmergencyBreak); io_swap(tp->plc_io_ctx, io_eEvent_EmergencyBreak);
......
...@@ -414,7 +414,7 @@ qcom_Get ( ...@@ -414,7 +414,7 @@ qcom_Get (
if (gp != NULL && gp->data != NULL) { if (gp != NULL && gp->data != NULL) {
br = pool_InPool(&lsts, &qdb->pool, gp->data, gp->size); br = pool_InPool(&lsts, &qdb->pool, gp->data, gp->size);
if (br != pool_cNRef) return NULL; if (br != pool_cNRef) break;
} }
qp = qdb_Que(sts, qid, NULL); qp = qdb_Que(sts, qid, NULL);
...@@ -1360,6 +1360,14 @@ qcom_EventMask ( ...@@ -1360,6 +1360,14 @@ qcom_EventMask (
return result; return result;
} }
void
qcom_SetRedundancyState (
pwr_eRedundancyState state
)
{
qdb->my_node->redundancy_state = state;
}
/* /*
......
...@@ -48,6 +48,10 @@ ...@@ -48,6 +48,10 @@
# include "pwr.h" # include "pwr.h"
#endif #endif
#ifndef pwr_class_h
# include "pwr_class.h"
#endif
#ifndef co_platform_h #ifndef co_platform_h
# include "co_platform.h" # include "co_platform.h"
#endif #endif
...@@ -460,6 +464,10 @@ pwr_tBoolean qcom_Unbind ( ...@@ -460,6 +464,10 @@ pwr_tBoolean qcom_Unbind (
const qcom_sQid *fromQ const qcom_sQid *fromQ
); );
void
qcom_SetRedundancyState (
pwr_eRedundancyState state
);
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "rt_qcom_msg.h" #include "rt_qcom_msg.h"
#include "rt_redu.h" #include "rt_redu.h"
#include "rt_redu_msg.h" #include "rt_redu_msg.h"
#include "co_timelog.h"
static pwr_tStatus add_table_object( redu_tCtx ctx, pwr_tAttrRef *o); 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); static pwr_tStatus add_table_attr( redu_tCtx ctx, pwr_tAttrRef *aref, gdh_sAttrDef *bd);
...@@ -81,6 +82,8 @@ pwr_tStatus redu_create_table( redu_tCtx ctx) ...@@ -81,6 +82,8 @@ pwr_tStatus redu_create_table( redu_tCtx ctx)
} }
#endif #endif
ctx->table_version = ctx->nodep->CurrentVersion;
return REDU__TABLECREATED; return REDU__TABLECREATED;
} }
...@@ -105,6 +108,7 @@ void redu_free_table( redu_tCtx ctx) ...@@ -105,6 +108,7 @@ void redu_free_table( redu_tCtx ctx)
ctx->t_last = 0; ctx->t_last = 0;
ctx->attr_cnt = 0; ctx->attr_cnt = 0;
ctx->current_offset = 0; ctx->current_offset = 0;
ctx->table_version = pwr_cNTime;
} }
static pwr_tStatus add_table_object( redu_tCtx ctx, pwr_tAttrRef *o) static pwr_tStatus add_table_object( redu_tCtx ctx, pwr_tAttrRef *o)
...@@ -257,13 +261,6 @@ static pwr_tStatus add_table_attr( redu_tCtx ctx, pwr_tAttrRef *aref, gdh_sAttrD ...@@ -257,13 +261,6 @@ static pwr_tStatus add_table_attr( redu_tCtx ctx, pwr_tAttrRef *aref, gdh_sAttrD
return REDU__SUCCESS; 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) pwr_tStatus redu_create_message( redu_tCtx ctx, void **msg)
{ {
char *buf; char *buf;
...@@ -278,6 +275,7 @@ pwr_tStatus redu_create_message( redu_tCtx ctx, void **msg) ...@@ -278,6 +275,7 @@ pwr_tStatus redu_create_message( redu_tCtx ctx, void **msg)
((redu_sMsgHeader *)buf)->h.type = redu_eMsgType_Cyclic; ((redu_sMsgHeader *)buf)->h.type = redu_eMsgType_Cyclic;
((redu_sMsgHeader *)buf)->size = ctx->current_offset; ((redu_sMsgHeader *)buf)->size = ctx->current_offset;
((redu_sMsgHeader *)buf)->version = ctx->table_version;
time_GetTime( &start_time); time_GetTime( &start_time);
bufp = buf + sizeof(redu_sMsgHeader); bufp = buf + sizeof(redu_sMsgHeader);
...@@ -305,6 +303,16 @@ pwr_tStatus redu_unpack_message( redu_tCtx ctx, void *msg) ...@@ -305,6 +303,16 @@ pwr_tStatus redu_unpack_message( redu_tCtx ctx, void *msg)
pwr_tTime start_time; pwr_tTime start_time;
pwr_tTime end_time; pwr_tTime end_time;
pwr_tDeltaTime dtime; pwr_tDeltaTime dtime;
int tsts;
tsts = time_Acomp_NE( &ctx->table_version, &((redu_sMsgHeader *)msg)->version);
if ( tsts != 0) {
if ( tsts == -2)
return 0;
else
// Request new table...
return 0;
}
time_GetTime( &start_time); time_GetTime( &start_time);
bufp = msg + sizeof(redu_sMsgHeader); bufp = msg + sizeof(redu_sMsgHeader);
...@@ -336,6 +344,7 @@ pwr_tStatus redu_send_table( redu_tCtx ctx, void **table_msg) ...@@ -336,6 +344,7 @@ pwr_tStatus redu_send_table( redu_tCtx ctx, void **table_msg)
((redu_sTableMsgHeader *)msg)->h.type = redu_eMsgType_Table; ((redu_sTableMsgHeader *)msg)->h.type = redu_eMsgType_Table;
((redu_sTableMsgHeader *)msg)->attributes = ctx->attr_cnt; ((redu_sTableMsgHeader *)msg)->attributes = ctx->attr_cnt;
((redu_sTableMsgHeader *)msg)->size = size; ((redu_sTableMsgHeader *)msg)->size = size;
((redu_sTableMsgHeader *)msg)->version = ctx->table_version;
msgp = msg + sizeof(redu_sTableMsgHeader); msgp = msg + sizeof(redu_sTableMsgHeader);
for ( e = ctx->t; e; e = e->next) { for ( e = ctx->t; e; e = e->next) {
...@@ -360,14 +369,23 @@ pwr_tStatus redu_receive_table( redu_tCtx ctx, void *table_msg) ...@@ -360,14 +369,23 @@ pwr_tStatus redu_receive_table( redu_tCtx ctx, void *table_msg)
int i; int i;
redu_sTable *e; redu_sTable *e;
pwr_tStatus sts; pwr_tStatus sts;
int tsts;
void *p; void *p;
// Test
msg = table_msg; msg = table_msg;
if ( ctx->t) if ( ctx->t)
redu_free_table( ctx); redu_free_table( ctx);
timelog( 2, "Table received");
tsts = time_Acomp_NE( &ctx->nodep->CurrentVersion, &((redu_sTableMsgHeader *)msg)->version);
if ( tsts != 0) {
if ( tsts == -2)
return 0;
else
errh_Warning( "Table version differs from current load version");
}
attributes = ((redu_sTableMsgHeader *)msg)->attributes; attributes = ((redu_sTableMsgHeader *)msg)->attributes;
msgp = msg + sizeof(redu_sTableMsgHeader); msgp = msg + sizeof(redu_sTableMsgHeader);
...@@ -396,6 +414,9 @@ pwr_tStatus redu_receive_table( redu_tCtx ctx, void *table_msg) ...@@ -396,6 +414,9 @@ pwr_tStatus redu_receive_table( redu_tCtx ctx, void *table_msg)
ctx->attr_cnt++; ctx->attr_cnt++;
msgp += sizeof(redu_sTableMsgElement); msgp += sizeof(redu_sTableMsgElement);
} }
ctx->table_version = ((redu_sTableMsgHeader *)msg)->version;
return REDU__TABLERECEIVED; return REDU__TABLERECEIVED;
} }
...@@ -414,7 +435,7 @@ void redu_print_table( redu_tCtx ctx) ...@@ -414,7 +435,7 @@ void redu_print_table( redu_tCtx ctx)
} }
} }
int redu_send( redu_tCtx ctx, void *msg, int size, unsigned int msg_id) pwr_tStatus redu_send( redu_tCtx ctx, void *msg, int size, unsigned int msg_id)
{ {
pwr_tStatus sts; pwr_tStatus sts;
qcom_sPut put; qcom_sPut put;
...@@ -433,7 +454,7 @@ int redu_send( redu_tCtx ctx, void *msg, int size, unsigned int msg_id) ...@@ -433,7 +454,7 @@ int redu_send( redu_tCtx ctx, void *msg, int size, unsigned int msg_id)
return sts; return sts;
} }
int redu_init( redu_tCtx *ctx, pwr_sNode *nodep, pwr_sClass_RedcomPacket *packetp) pwr_tStatus redu_init( redu_tCtx *ctx, pwr_sNode *nodep, pwr_sClass_RedcomPacket *packetp)
{ {
qcom_sQattr qattr; qcom_sQattr qattr;
pwr_tStatus sts; pwr_tStatus sts;
...@@ -496,7 +517,7 @@ int redu_init( redu_tCtx *ctx, pwr_sNode *nodep, pwr_sClass_RedcomPacket *packet ...@@ -496,7 +517,7 @@ int redu_init( redu_tCtx *ctx, pwr_sNode *nodep, pwr_sClass_RedcomPacket *packet
return REDU__SUCCESS; return REDU__SUCCESS;
} }
int redu_receive( redu_tCtx ctx, unsigned int timeout, int *size, void **msg) pwr_tStatus redu_receive( redu_tCtx ctx, unsigned int timeout, int *size, void **msg)
{ {
pwr_tStatus sts; pwr_tStatus sts;
qcom_sGet get; qcom_sGet get;
...@@ -561,3 +582,130 @@ pwr_tStatus redu_get_initial_state( char *nodename, int busid, int *state) ...@@ -561,3 +582,130 @@ pwr_tStatus redu_get_initial_state( char *nodename, int busid, int *state)
return REDU__SUCCESS; return REDU__SUCCESS;
} }
pwr_tStatus redu_send_table_request( redu_tCtx ctx)
{
redu_sHeader *msg;
pwr_tStatus sts;
timelog( 2, "Redu seding table request");
msg = (redu_sHeader *)malloc( sizeof(redu_sHeader));
msg->type = redu_eMsgType_TableRequest;
sts = redu_send( ctx, msg, sizeof(redu_sHeader), 0);
free( msg);
return sts;
}
pwr_tStatus redu_send_table_version( redu_tCtx ctx)
{
redu_sMsgTableVersion *msg;
pwr_tStatus sts;
timelog( 2, "Redu seding table version");
msg = (redu_sMsgTableVersion *)malloc( sizeof(redu_sMsgTableVersion));
msg->h.type = redu_eMsgType_TableVersion;
msg->version = ctx->table_version;
sts = redu_send( ctx, msg, sizeof(redu_sMsgTableVersion), 0);
free( msg);
return sts;
}
pwr_tStatus redu_send_table_version_request( redu_tCtx ctx)
{
redu_sHeader *msg;
pwr_tStatus sts;
timelog( 1, "");
msg = (redu_sHeader *)malloc( sizeof(redu_sHeader));
msg->type = redu_eMsgType_TableVersionRequest;
sts = redu_send( ctx, msg, sizeof(redu_sHeader), 0);
free( msg);
return sts;
}
pwr_tStatus redu_set_state( pwr_eRedundancyState state)
{
pwr_tStatus sts;
pwr_tOid oid;
pwr_sClass_RedcomConfig *p;
sts = gdh_GetClassList( pwr_cClass_RedcomConfig, &oid);
if ( EVEN(sts)) return sts;
sts = gdh_ObjidToPointer( oid, (void **)&p);
if ( EVEN(sts)) return sts;
switch ( state) {
case pwr_eRedundancyState_Active:
p->SetActive = 1;
break;
case pwr_eRedundancyState_Passive:
p->SetPassive = 1;
break;
case pwr_eRedundancyState_Off:
p->SetOff = 1;
break;
default: ;
}
return REDU__SUCCESS;
}
pwr_tStatus redu_appl_init( redu_tCtx *ctx, pwr_sClass_RedcomPacket *packetp)
{
pwr_sNode *nodep;
pwr_tOid noid;
pwr_tStatus sts;
sts = gdh_GetNodeObject( pwr_cNNid, &noid);
if ( EVEN(sts)) return sts;
sts = gdh_ObjidToPointer( noid, (void **)&nodep);
if ( EVEN(sts)) return sts;
return redu_init( ctx, nodep, packetp);
}
pwr_tStatus redu_appl_send( redu_tCtx ctx, void *msg, int size, pwr_tTime version, unsigned int msg_id)
{
pwr_tStatus sts;
((redu_sMsgHeader *)msg)->h.type = redu_eMsgType_Cyclic;
((redu_sMsgHeader *)msg)->size = size;
((redu_sMsgHeader *)msg)->version = version;
sts = redu_send( ctx, msg, size, msg_id);
if ( ODD(sts) && ctx->packetp) {
ctx->packetp->TransmitCnt++;
ctx->packetp->PacketSize = size;
}
return sts;
}
pwr_tStatus redu_appl_receive( redu_tCtx ctx, unsigned int timeout, void **msg, int *size)
{
pwr_tStatus sts;
sts = redu_receive( ctx, timeout, size, msg);
if ( EVEN(sts) && sts != QCOM__TMO) {
// Wait to avoid looping
struct timespec ts = {timeout/1000, (timeout * 1000000) % 1000000000};
nanosleep(&ts, NULL);
}
if ( ODD(sts) && ctx->packetp) {
ctx->packetp->ReceiveCnt++;
ctx->packetp->PacketSize = *size;
}
return sts;
}
...@@ -67,7 +67,9 @@ extern "C" { ...@@ -67,7 +67,9 @@ extern "C" {
typedef enum { typedef enum {
redu_eMsgType_Table, redu_eMsgType_Table,
redu_eMsgType_Cyclic, redu_eMsgType_Cyclic,
redu_eMsgType_TableRequest redu_eMsgType_TableRequest,
redu_eMsgType_TableVersionRequest,
redu_eMsgType_TableVersion
} redu_eMsgType; } redu_eMsgType;
typedef enum { typedef enum {
...@@ -107,6 +109,8 @@ typedef struct { ...@@ -107,6 +109,8 @@ typedef struct {
redu_sTable *t_last; redu_sTable *t_last;
float msg_time; float msg_time;
int table_sent; int table_sent;
int table_created;
pwr_tTime table_version;
} redu_sCtx, *redu_tCtx; } redu_sCtx, *redu_tCtx;
typedef struct { typedef struct {
...@@ -116,14 +120,14 @@ typedef struct { ...@@ -116,14 +120,14 @@ typedef struct {
typedef struct { typedef struct {
redu_sHeader h; redu_sHeader h;
pwr_tUInt32 size; pwr_tUInt32 size;
pwr_tTime time; pwr_tTime version;
} redu_sMsgHeader; } redu_sMsgHeader;
typedef struct { typedef struct {
redu_sHeader h; redu_sHeader h;
pwr_tUInt32 size; pwr_tUInt32 size;
pwr_tUInt32 attributes; pwr_tUInt32 attributes;
pwr_tTime time; pwr_tTime version;
} redu_sTableMsgHeader; } redu_sTableMsgHeader;
typedef struct { typedef struct {
...@@ -131,6 +135,11 @@ typedef struct { ...@@ -131,6 +135,11 @@ typedef struct {
pwr_tUInt32 size; pwr_tUInt32 size;
} redu_sTableMsgElement; } redu_sTableMsgElement;
typedef struct {
redu_sHeader h;
pwr_tTime version;
} redu_sMsgTableVersion;
pwr_tStatus redu_create_table( redu_tCtx ctx); pwr_tStatus redu_create_table( redu_tCtx ctx);
void redu_free( redu_tCtx ctx); void redu_free( redu_tCtx ctx);
void redu_free_table( redu_tCtx ctx); void redu_free_table( redu_tCtx ctx);
...@@ -138,12 +147,19 @@ pwr_tStatus redu_create_message( redu_tCtx ctx, void **msg); ...@@ -138,12 +147,19 @@ pwr_tStatus redu_create_message( redu_tCtx ctx, void **msg);
pwr_tStatus redu_unpack_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_receive_table( redu_tCtx ctx, void *table_msg);
pwr_tStatus redu_send_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); pwr_tStatus redu_send_table_request( redu_tCtx ctx);
int redu_init( redu_tCtx *ctx, pwr_sNode *nodep, pwr_sClass_RedcomPacket *packetp); pwr_tStatus redu_send_table_version( redu_tCtx ctx);
int redu_send( redu_tCtx ctx, void *msg, int size, unsigned int msg_id); pwr_tStatus redu_send_table_version_request( redu_tCtx ctx);
int redu_receive( redu_tCtx ctx, unsigned int timeout, int *size, void **msg); pwr_tStatus redu_init( redu_tCtx *ctx, pwr_sNode *nodep, pwr_sClass_RedcomPacket *packetp);
pwr_tStatus redu_send( redu_tCtx ctx, void *msg, int size, unsigned int msg_id);
pwr_tStatus redu_receive( redu_tCtx ctx, unsigned int timeout, int *size, void **msg);
void redu_print( redu_tCtx ctx); void redu_print( redu_tCtx ctx);
pwr_tStatus redu_get_initial_state( char *nodename, int busid, int *state); pwr_tStatus redu_get_initial_state( char *nodename, int busid, int *state);
pwr_tStatus redu_set_state( pwr_eRedundancyState state);
pwr_tStatus redu_appl_init( redu_tCtx *ctx, pwr_sClass_RedcomPacket *packetp);
pwr_tStatus redu_appl_send( redu_tCtx ctx, void *msg, int size, pwr_tTime version, unsigned int msg_id);
pwr_tStatus redu_appl_receive( redu_tCtx ctx, unsigned int timeout, void **msg, int *size);
#if defined __cplusplus #if defined __cplusplus
} }
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
.facility GDB,15 /prefix = GDB__ ! Global database .facility GDB,15 /prefix = GDB__ ! Global database
success <successful completion> /succ success <successful completion> /succ
lockcheck <database locking bugckeck> /fatal lockcheck <database locking bugcheck> /fatal
mutexinit <failed to init mutex> /error mutexinit <failed to init mutex> /error
dupladd <item is already added> /error dupladd <item is already added> /error
alradd <item is already added> /info alradd <item is already added> /info
......
...@@ -102,6 +102,7 @@ convert <Unable to convert value> /error ...@@ -102,6 +102,7 @@ convert <Unable to convert value> /error
readonly <Object or attribute is read only> /error readonly <Object or attribute is read only> /error
remotemount <Remotly mounted object> /error remotemount <Remotly mounted object> /error
dblock <Unable to map db lock> /error dblock <Unable to map db lock> /error
connlost <Connection lost> /error
.end .end
...@@ -43,6 +43,9 @@ tablecreated <Table successfully created> /succ ...@@ -43,6 +43,9 @@ tablecreated <Table successfully created> /succ
tablesent <Table sent> /succ tablesent <Table sent> /succ
redcomfile <Unable to open redcom file> /error redcomfile <Unable to open redcom file> /error
localnode <Local node not found> /error localnode <Local node not found> /error
down <Link down> /warning
buffhigh <High buffer level> /warning
.end .end
......
...@@ -182,9 +182,29 @@ SObject pwrb:Class ...@@ -182,9 +182,29 @@ SObject pwrb:Class
EndBody EndBody
EndObject EndObject
!/** !/**
! Maximum time between two received transactions.
!*/
Object TimeMax $Attribute 14
Body SysBody
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Mean time between received transactions.
!*/
Object TimeMean $Attribute 15
Body SysBody
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Disable. ! Disable.
!*/ !*/
Object Disable $Attribute 15 Object Disable $Attribute 16
Body SysBody Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
EndBody EndBody
......
...@@ -78,12 +78,21 @@ SObject pwrb:Class ...@@ -78,12 +78,21 @@ SObject pwrb:Class
EndBody EndBody
EndObject EndObject
!/** !/**
! Startup timeout time.
! Increased timeout time at startup.
!*/
Object StartupTimeout $Attribute 4
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Force state. ! Force state.
! State can only be changed from Active/Passive buttons in ! State can only be changed from Active/Passive buttons in
! object graph. I will not automatically be changed by system ! object graph. It will not automatically be changed by system
! events or errors. ! events or errors.
!*/ !*/
Object Force $Attribute 4 Object Force $Attribute 5
Body SysBody Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean" Attr TypeRef = "pwrs:Type-$Boolean"
EndBody EndBody
...@@ -91,7 +100,7 @@ SObject pwrb:Class ...@@ -91,7 +100,7 @@ SObject pwrb:Class
!/** !/**
! Set redundancy state Active. ! Set redundancy state Active.
!*/ !*/
Object SetActive $Attribute 5 Object SetActive $Attribute 6
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_STATE Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT Attr Flags |= PWR_MASK_NOEDIT
...@@ -101,7 +110,7 @@ SObject pwrb:Class ...@@ -101,7 +110,7 @@ SObject pwrb:Class
!/** !/**
! Set redundancy state Passive. ! Set redundancy state Passive.
!*/ !*/
Object SetPassive $Attribute 6 Object SetPassive $Attribute 7
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_STATE Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT Attr Flags |= PWR_MASK_NOEDIT
...@@ -111,7 +120,7 @@ SObject pwrb:Class ...@@ -111,7 +120,7 @@ SObject pwrb:Class
!/** !/**
! Set redundancy state Off. ! Set redundancy state Off.
!*/ !*/
Object SetOff $Attribute 7 Object SetOff $Attribute 8
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_STATE Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT Attr Flags |= PWR_MASK_NOEDIT
...@@ -121,7 +130,7 @@ SObject pwrb:Class ...@@ -121,7 +130,7 @@ SObject pwrb:Class
!/** !/**
! Link state. ! Link state.
!*/ !*/
Object Link $Attribute 8 Object Link $Attribute 9
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_ARRAY Attr Flags |= PWR_MASK_ARRAY
Attr Flags |= PWR_MASK_CLASS Attr Flags |= PWR_MASK_CLASS
...@@ -134,6 +143,7 @@ SObject pwrb:Class ...@@ -134,6 +143,7 @@ SObject pwrb:Class
Body RtBody Body RtBody
Attr CycleTime = 0.005 Attr CycleTime = 0.005
Attr LinkTimeout = 0.200 Attr LinkTimeout = 0.200
Attr StartupTimeout = 5.0
EndBody EndBody
EndObject EndObject
EndObject EndObject
......
...@@ -128,6 +128,16 @@ SObject pwrb:Class ...@@ -128,6 +128,16 @@ SObject pwrb:Class
EndBody EndBody
EndObject EndObject
!/** !/**
! Table status.
!*/
Object TableVersion $Attribute 13
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Time"
EndBody
EndObject
!/**
! Number of attributes. ! Number of attributes.
!*/ !*/
Object Attributes $Attribute 8 Object Attributes $Attribute 8
......
...@@ -29,21 +29,21 @@ ...@@ -29,21 +29,21 @@
100 20 100 20
135 20 135 20
101 20 101 20
102 -86 102 399
103 15 103 -1
104 2.37945 104 2.37629
136 2.37945 136 2.37629
105 100 105 100
106 -10 106 -4
107 0 107 0
108 51.5 108 51.5
109 -2 109 -2
110 47.5032 110 47.5032
111 0.01322 111 0.01322
116 0 116 51
117 1 117 0
118 119 118 138
119 81 119 72
120 1 120 1
121 Claes context 121 Claes context
122 0 122 0
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
134 134
22 22
2200 0 2200 0
2201 517 2201 518
2202 pwr_c_node 2202 pwr_c_node
2203 310 2203 310
2205 0 2205 0
...@@ -486,6 +486,290 @@ pwr_exe: ...@@ -486,6 +486,290 @@ pwr_exe:
123 123
2 2
3 3
300 pwrct_valueinputmediumcenterbg
301
2
26
2604 O0
2600 3.15
2601 -0.15
2602 1.15
2603 -0.15
2605
25
2500 0
2501 1
2503 1
2504 0
2502
2
7
700 -0.15
701 1.15
99
7
700 3.15
701 1.15
99
7
700 3.15
701 -0.15
99
7
700 3
701 0
99
7
700 3
701 1
99
7
700 0
701 1
99
7
700 -0.15
701 1.15
99
99
99
2608 0
2609 310
2629 10000
2610 310
2611 0
2616 0
2614 5
2617 2
2615 0
2618 1
2607 0
2606
2612
28
2800 1
2801 0
2802 0
2803 0
2804 1
2805 0
2806 0
99
2613 0
2619 0
2620 0
2626 1
2627 0
2621 0
2622 0
2623 0
2624 4
2625 1
2628 0
99
26
2604 O1
2600 3.15
2601 -0.15
2602 1.15
2603 -0.15
2605
25
2500 0
2501 1
2503 1
2504 0
2502
2
7
700 3
701 0
99
7
700 3.15
701 -0.15
99
7
700 -0.15
701 -0.15
99
7
700 -0.15
701 1.15
99
7
700 0
701 1
99
7
700 0
701 0
99
7
700 3
701 0
99
99
99
2608 0
2609 310
2629 10000
2610 310
2611 0
2616 0
2614 5
2617 2
2615 0
2618 1
2607 0
2606
2612
28
2800 1
2801 0
2802 0
2803 0
2804 1
2805 0
2806 0
99
2613 0
2619 0
2620 0
2626 0
2627 1
2621 0
2622 0
2623 0
2624 4
2625 1
2628 0
99
19
1904 O2
1900 3
1901 0
1902 1
1903 0
1908 334
1909 330
1910 330
1911 1
1915 0
1913 10
1916 2
1914 0
1918 0
1919 0
1920 0
1917 1
1921 0
1922 2
1923 0
1924 0
1925 10000
1926 0
1907 0
1906
1905
5
500 334
501 1
504 1
505 1
502
7
700 0
701 0
99
503
7
700 3
701 1
99
99
1912
28
2800 1
2801 0
2802 0
2803 0
2804 1
2805 0
2806 0
99
99
29
2907
13
1300 1
1301 303
1306 338
1302 3
1305 1
1303
7
700 1
701 1.35
99
1304 0
1307 4
1308 0
99
2908
28
2800 1
2801 0
2802 0.521458
2803 0
2804 1
2805 -0.55
2806 0
99
2901 0
99
99
302 0
304 0
303
305 0
306
307
308 1024
330 0
321 4096
331 0
309 0
313 0
322 0
323 0
324 0
325 0
326 0
327 0
310 0
311 0
312
314
315 1
316 1
317 0
318 0
319 0
320 0
328 0
332 0
329
1
100 1
105 0
101 1
106 0
102 65532
103 0
99
99
3
300 pwr_indsquare 300 pwr_indsquare
301 301
2 2
...@@ -1824,6 +2108,8 @@ pwr_exe: ...@@ -1824,6 +2108,8 @@ pwr_exe:
1202 1 1202 1
1203 1 1203 1
1204 0 1204 0
1205
1206 0
99 99
99 99
99 99
...@@ -3082,6 +3368,8 @@ pwr_exe: ...@@ -3082,6 +3368,8 @@ pwr_exe:
1202 1 1202 1
1203 1 1203 1
1204 0 1204 0
1205
1206 0
99 99
99 99
99 99
...@@ -3253,6 +3541,8 @@ pwr_exe: ...@@ -3253,6 +3541,8 @@ pwr_exe:
1202 1 1202 1
1203 1 1203 1
1204 0 1204 0
1205
1206 0
99 99
99 99
99 99
...@@ -3390,6 +3680,8 @@ pwr_exe: ...@@ -3390,6 +3680,8 @@ pwr_exe:
1202 1 1202 1
1203 1 1203 1
1204 0 1204 0
1205
1206 0
99 99
99 99
99 99
...@@ -3527,6 +3819,8 @@ pwr_exe: ...@@ -3527,6 +3819,8 @@ pwr_exe:
1202 1 1202 1
1203 1 1203 1
1204 0 1204 0
1205
1206 0
99 99
99 99
99 99
...@@ -3664,6 +3958,8 @@ pwr_exe: ...@@ -3664,6 +3958,8 @@ pwr_exe:
1202 1 1202 1
1203 1 1203 1
1204 0 1204 0
1205
1206 0
99 99
99 99
99 99
...@@ -3801,6 +4097,8 @@ pwr_exe: ...@@ -3801,6 +4097,8 @@ pwr_exe:
1202 1 1202 1
1203 1 1203 1
1204 0 1204 0
1205
1206 0
99 99
99 99
99 99
...@@ -3938,6 +4236,8 @@ pwr_exe: ...@@ -3938,6 +4236,8 @@ pwr_exe:
1202 1 1202 1
1203 1 1203 1
1204 0 1204 0
1205
1206 0
99 99
99 99
99 99
...@@ -4089,5 +4389,168 @@ pwr_exe: ...@@ -4089,5 +4389,168 @@ pwr_exe:
103 0 103 0
99 99
99 99
27
2703 10000
2704 10000
2731 10000
2722 10000
2705 10000
2723 10000
2706 10000
2732 10000
2708 0
2709 0
2710 0
2711 0
2712 0
2713 0
2714 0
2715 0
2720 0
2725 0
2726 0
2702 0
2701
2700
10
1000 pwrct_valueinputmediumcenterbg
1002 O517
1005
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1006 49.45
1007 42.85
1008 3.75
1009 1.95
1013 49.45
1014 42.85
1015 3.75
1016 1.95
1003
0
0
0
0
0
0
0
0
0
0
1004
1001
7
700 8.9
701 8.95
99
1010
1011
1018
1019
1020
1021
1022
1023
1024
1025
1012 0
1017 9999
1027 9999
1026 35454972
1028 0
1029
99
2707
28
2800 2
2801 0
2802 43.15
2803 0
2804 1.38462
2805 2.15769
2806 0
99
2716 0
2718
2717
2719 0
2724 0
2727 0
2728 303
2729 4
2730 0
2721
1
100 2177
105 0
101 0
106 0
102 35454972
103 0
9
900 !$object.RedundancyState##Boolean
901 0
902 1
903 1
99
61
6100
6101 3
6102 4
6103 470
6104 2
6105 1
6106 0
99
61
6100 $object.RedundancyState##Int32
6101 2
6102 4
6103 410
6104 1
6105 3
6106 0
99
12
1200 $object.RedundancyState##Enum
1201 %s
1202 1
1203 1
1204 0
1205
1206 0
99
99
99
99 99
99 99
This diff is collapsed.
...@@ -5461,11 +5461,11 @@ pwr_exe: ...@@ -5461,11 +5461,11 @@ pwr_exe:
0 0
1006 40.4414 1006 40.4414
1007 12.55 1007 12.55
1008 12.8815 1008 12.8816
1009 11.9519 1009 11.9519
1013 40.4414 1013 40.4414
1014 12.55 1014 12.55
1015 12.8815 1015 12.8816
1016 11.9519 1016 11.9519
1003 1003
0 0
...@@ -5529,7 +5529,7 @@ pwr_exe: ...@@ -5529,7 +5529,7 @@ pwr_exe:
102 65532 102 65532
103 0 103 0
12 12
1200 $node.ProcStatus[20]##Status 1200 $node.ProcStatus[26]##Status
1201 %1m 1201 %1m
1202 1 1202 1
1203 1 1203 1
...@@ -6024,11 +6024,11 @@ pwr_exe: ...@@ -6024,11 +6024,11 @@ pwr_exe:
0 0
1006 40.4414 1006 40.4414
1007 12.55 1007 12.55
1008 14.2597 1008 14.2598
1009 13.3301 1009 13.3301
1013 40.4414 1013 40.4414
1014 12.55 1014 12.55
1015 14.2597 1015 14.2598
1016 13.3301 1016 13.3301
1003 1003
0 0
...@@ -6092,7 +6092,7 @@ pwr_exe: ...@@ -6092,7 +6092,7 @@ pwr_exe:
102 65532 102 65532
103 0 103 0
12 12
1200 $node.ProcMessage[20]##String80 1200 $node.ProcMessage[26]##String80
1201 %s 1201 %s
1202 1 1202 1
1203 1 1203 1
...@@ -6503,7 +6503,7 @@ pwr_exe: ...@@ -6503,7 +6503,7 @@ pwr_exe:
102 65532 102 65532
103 0 103 0
31 31
3100 $node.ProcStatus[20]##status 3100 $node.ProcStatus[26]##status
3101 374 3101 374
3102 1 3102 1
99 99
...@@ -6814,7 +6814,7 @@ pwr_exe: ...@@ -6814,7 +6814,7 @@ pwr_exe:
102 65532 102 65532
103 0 103 0
31 31
3100 $node.ProcMsgSeverity[20]##status 3100 $node.ProcMsgSeverity[26]##status
3101 374 3101 374
3102 1 3102 1
99 99
...@@ -7386,7 +7386,7 @@ pwr_exe: ...@@ -7386,7 +7386,7 @@ pwr_exe:
1 1
100 2049 100 2049
105 0 105 0
101 1 101 0
106 0 106 0
102 35454972 102 35454972
103 0 103 0
...@@ -7417,17 +7417,6 @@ pwr_exe: ...@@ -7417,17 +7417,6 @@ pwr_exe:
1205 1205
1206 0 1206 0
99 99
13
1302 0
1303 0
1304 0
1305 0
1306 0
1307
1308
1309 0
1310 0
99
99 99
99 99
99 99
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "cow_wow.h" #include "cow_wow.h"
#include "co_lng.h" #include "co_lng.h"
#include "co_time.h" #include "co_time.h"
#include "co_timelog.h"
#include "rt_gdh.h" #include "rt_gdh.h"
#include "flow.h" #include "flow.h"
#include "flow_browctx.h" #include "flow_browctx.h"
...@@ -942,8 +943,8 @@ void EvList::event_alarm( mh_sMessage *msg) ...@@ -942,8 +943,8 @@ void EvList::event_alarm( mh_sMessage *msg)
if ( id_to_item( &event->Info.Id, (void **)&item)) if ( id_to_item( &event->Info.Id, (void **)&item))
return; return;
if ( type != ev_eType_EventList ) if ( type != ev_eType_EventList )
printf( "New ala %d,%d\n", event->Info.Id.Nix, event->Info.Id.Idx); timelog_sii( 4, "Ev, New alarm", event->Info.Id.Nix, event->Info.Id.Idx);
sts = get_destination( net_NetTimeToTime( &event->Info.EventTime), (void **)&dest); sts = get_destination( net_NetTimeToTime( &event->Info.EventTime), (void **)&dest);
if ( EVEN(sts)) { if ( EVEN(sts)) {
...@@ -1146,7 +1147,7 @@ void EvList::event_ack( mh_sAck *msg) ...@@ -1146,7 +1147,7 @@ void EvList::event_ack( mh_sAck *msg)
// Check that this id not already inserted // Check that this id not already inserted
if ( id_to_item( &event->Info.Id, (void **)&item)) if ( id_to_item( &event->Info.Id, (void **)&item))
return; return;
printf( "New ack %d,%d\n", event->Info.Id.Nix, event->Info.Id.Idx); timelog_sii( 3, "Ev, new ack", event->Info.Id.Nix, event->Info.Id.Idx);
sts = get_destination( net_NetTimeToTime( &event->Info.EventTime), (void **)&dest); sts = get_destination( net_NetTimeToTime( &event->Info.EventTime), (void **)&dest);
if ( EVEN(sts)) { if ( EVEN(sts)) {
...@@ -1240,7 +1241,7 @@ void EvList::event_return( mh_sReturn *msg) ...@@ -1240,7 +1241,7 @@ void EvList::event_return( mh_sReturn *msg)
// Check that this id not already inserted // Check that this id not already inserted
if ( id_to_item( &event->Info.Id, (void **)&item)) if ( id_to_item( &event->Info.Id, (void **)&item))
return; return;
printf( "New ret %d,%d\n", event->Info.Id.Nix, event->Info.Id.Idx); timelog_sii( 4, "Ev, New return", event->Info.Id.Nix, event->Info.Id.Idx);
sts = get_destination( net_NetTimeToTime( &event->Info.EventTime), (void **)&dest); sts = get_destination( net_NetTimeToTime( &event->Info.EventTime), (void **)&dest);
if ( EVEN(sts)) { if ( EVEN(sts)) {
......
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