Commit 9556e8c2 authored by Claes Sjofors's avatar Claes Sjofors

Plc, several plc processes, signal handling with rt_ini at start and restart (refs #96)

parent 7435be1b
......@@ -60,6 +60,7 @@
#if defined OS_ELN
# include "ini_time.h"
#endif
#include "rt_ini_event.h"
#include "rt_ini_alias.h"
#include "rt_ini_msg.h"
#include "rt_lst.h"
......@@ -2039,6 +2040,7 @@ ini_ProcTable (
char *s;
char buffer[256];
pwr_tStatus lsts;
int plc_idx;
pwr_dStatus(sts, status, INI__SUCCESS);
......@@ -2118,6 +2120,8 @@ ini_ProcTable (
pp->proc.flags.b.system = 1;
#endif
plc_idx = 0;
cp->plc_sigmask = 0;
for ( lsts = gdh_GetClassList(pwr_cClass_PlcProcess, &oid);
ODD(lsts);
lsts = gdh_GetNextObject( oid, &oid)) {
......@@ -2154,6 +2158,7 @@ ini_ProcTable (
}
if ( !found) {
plc_idx++;
continue;
}
......@@ -2166,6 +2171,8 @@ ini_ProcTable (
pp->proc.flags.b.user = 1;
pp->proc.flags.b.k_mode = 1;
pp->proc.k_size = 30;
cp->plc_sigmask |= ini_mEvent_plc1 << plc_idx;
plc_idx++;
}
for (
......
......@@ -161,6 +161,7 @@ typedef struct {
ini_sFile nodefile;
ini_sFile *plcfile;
int plcfile_cnt;
unsigned int plc_sigmask;
int busid;
char dir[256];
char bdir[256]; /* Base dir (pwr_load) */
......
......@@ -250,7 +250,7 @@ start (
exit(sts);
}
qcom_WaitAnd(&sts, &cp->eventQ, &qcom_cQini, ini_mEvent_newPlcStartDone, qcom_cTmoEternal);
qcom_WaitAnd(&sts, &cp->eventQ, &qcom_cQini, ini_mEvent_newPlcStartDone | cp->plc_sigmask, qcom_cTmoEternal);
sts = ini_SetAttributeAfterPlc(cp->aliasfile.name, cp->nodename, 0);
if (EVEN(sts) && sts != INI__FILE)
......@@ -447,16 +447,18 @@ restart (
qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_newPlcInit);
qcom_WaitAnd(&sts, &cp->eventQ, &qcom_cQini, ini_mEvent_newPlcInitDone, qcom_cTmoEternal);
qcom_WaitAnd(&sts, &cp->eventQ, &qcom_cQini, ini_mEvent_newPlcInitDone | cp->plc_sigmask, qcom_cTmoEternal);
errh_LogInfo(&cp->log, "Entering time critical period, stopping old PLC");
qcom_SignalAnd(&sts, &qcom_cQini, ~cp->plc_sigmask);
qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_oldPlcStop);
qcom_WaitAnd(&sts, &cp->eventQ, &qcom_cQini, ini_mEvent_oldPlcStopDone, qcom_cTmoEternal);
qcom_WaitAnd(&sts, &cp->eventQ, &qcom_cQini, ini_mEvent_oldPlcStopDone | cp->plc_sigmask, qcom_cTmoEternal);
qcom_SignalAnd(&sts, &qcom_cQini, ~ini_mEvent_oldPlcStop);
ini_UpdateBodies(&sts, cp, 0);
qcom_SignalAnd(&sts, &qcom_cQini, ~cp->plc_sigmask);
qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_newPlcStart);
qcom_WaitAnd(&sts, &cp->eventQ, &qcom_cQini, ini_mEvent_newPlcStartDone, qcom_cTmoEternal);
qcom_WaitAnd(&sts, &cp->eventQ, &qcom_cQini, ini_mEvent_newPlcStartDone | cp->plc_sigmask, qcom_cTmoEternal);
errh_LogInfo(&cp->log, "Time critical period over, new PLC is running");
qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_swapDone);
......
......@@ -209,7 +209,7 @@ int main (
setreuid(ruid, ruid);
#endif
qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_newPlcInitDone);
qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_newPlcInitDone | pp->sigmask);
qcom_WaitAnd(&sts, &pp->eventQ, &qcom_cQini, ini_mEvent_newPlcStart, qcom_cTmoEternal);
// proc_SetPriority(pp->PlcProcess->Prio);
......@@ -218,7 +218,7 @@ int main (
run_threads(pp);
time_Uptime(&sts, &pp->PlcProcess->StartTime, NULL);
qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_newPlcStartDone);
qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_newPlcStartDone | pp->sigmask);
#if 0
/* Force the backup to take care initialized backup objects. */
......@@ -245,7 +245,7 @@ int main (
stop_threads(pp);
save_values(pp);
qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_oldPlcStopDone);
qcom_SignalOr(&sts, &qcom_cQini, ini_mEvent_oldPlcStopDone | pp->sigmask);
#if defined OS_ELN
sts = proc_SetPriority(31);
......@@ -328,6 +328,8 @@ init_process ( char *name)
}
pp->index = idx;
if ( idx < 20)
pp->sigmask = ini_mEvent_plc1 << idx;
pp->oid = pp_oid;
if ( errh_eAnix_plc1 + pp->index < errh_eAnix__)
......
......@@ -53,10 +53,28 @@ typedef union {
pwr_Bits( swapDone , 1),
pwr_Bits( terminate , 1),
pwr_Bits( fill_1 , 6),,,,,,
pwr_Bits( fill_1 , 2),,
pwr_Bits( fill_2 , 8),,,,,,,,
pwr_Bits( fill_3 , 8),,,,,,,
pwr_Bits( plcProc1 , 1),
pwr_Bits( plcProc2 , 1),
pwr_Bits( plcProc3 , 1),
pwr_Bits( plcProc4 , 1),
pwr_Bits( plcProc5 , 1),
pwr_Bits( plcProc6 , 1),
pwr_Bits( plcProc7 , 1),
pwr_Bits( plcProc8 , 1),
pwr_Bits( plcProc9 , 1),
pwr_Bits( plcProc10 , 1),
pwr_Bits( plcProc11 , 1),
pwr_Bits( plcProc12 , 1),
pwr_Bits( plcProc13 , 1),
pwr_Bits( plcProc14 , 1),
pwr_Bits( plcProc15 , 1),
pwr_Bits( plcProc16 , 1),
pwr_Bits( plcProc17 , 1),
pwr_Bits( plcProc18 , 1),
pwr_Bits( plcProc19 , 1),
pwr_Bits( plcProc20 , 1)
) b;
#define ini_mEvent__ 0
......@@ -71,6 +89,26 @@ typedef union {
#define ini_mEvent_swapDone pwr_Bit(8)
#define ini_mEvent_terminate pwr_Bit(9)
#define ini_mEvent_plc1 pwr_Bit(12)
#define ini_mEvent_plc2 pwr_Bit(13)
#define ini_mEvent_plc3 pwr_Bit(14)
#define ini_mEvent_plc4 pwr_Bit(15)
#define ini_mEvent_plc5 pwr_Bit(16)
#define ini_mEvent_plc6 pwr_Bit(17)
#define ini_mEvent_plc7 pwr_Bit(18)
#define ini_mEvent_plc8 pwr_Bit(19)
#define ini_mEvent_plc9 pwr_Bit(20)
#define ini_mEvent_plc10 pwr_Bit(21)
#define ini_mEvent_plc11 pwr_Bit(22)
#define ini_mEvent_plc12 pwr_Bit(23)
#define ini_mEvent_plc13 pwr_Bit(24)
#define ini_mEvent_plc14 pwr_Bit(25)
#define ini_mEvent_plc15 pwr_Bit(26)
#define ini_mEvent_plc16 pwr_Bit(27)
#define ini_mEvent_plc17 pwr_Bit(28)
#define ini_mEvent_plc18 pwr_Bit(29)
#define ini_mEvent_plc19 pwr_Bit(30)
#define ini_mEvent_plc20 pwr_Bit(31)
#define ini_mEvent_ (~ini_mEvent__)
} ini_mEvent;
......
......@@ -191,6 +191,7 @@ struct plc_sProcess {
qcom_sQid eventQ;
pwr_tOid oid;
int index;
unsigned int sigmask;
thread_sMutex io_copy_mutex;
plc_sArea base;
};
......
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