Commit ec9fca16 authored by Claes Sjofors's avatar Claes Sjofors

Simulate config, reset function added

parent ad44fde4
...@@ -619,6 +619,15 @@ void rt_sim::load_nmps() ...@@ -619,6 +619,15 @@ void rt_sim::load_nmps()
system( cmd); system( cmd);
} }
void rt_sim::store_state()
{
// Store current state
for ( unsigned int i = 0; i < plcpgm_cnt; i++) {
plcpgm_stored_scanoff[i] = windowplcp[i]->ScanOff;
}
state_stored = 1;
}
void rt_sim::scan() void rt_sim::scan()
{ {
pwr_tStatus sts; pwr_tStatus sts;
...@@ -644,6 +653,8 @@ void rt_sim::scan() ...@@ -644,6 +653,8 @@ void rt_sim::scan()
conf->PlcPgmScanOff = 0; conf->PlcPgmScanOff = 0;
if ( conf->PlcPgmScanOn) if ( conf->PlcPgmScanOn)
conf->PlcPgmScanOn = 0; conf->PlcPgmScanOn = 0;
if ( conf->Reset)
conf->Reset = 0;
if ( !disable_old) { if ( !disable_old) {
...@@ -653,10 +664,9 @@ void rt_sim::scan() ...@@ -653,10 +664,9 @@ void rt_sim::scan()
conf->ThreadStatus[i] = SIM__THREAD_RUNNING; conf->ThreadStatus[i] = SIM__THREAD_RUNNING;
} }
// Set scan on of plcpgm // Set scan on of plcpgm
if ( state_stored) {
for ( unsigned int i = 0; i < plcpgm_cnt; i++) { for ( unsigned int i = 0; i < plcpgm_cnt; i++) {
if ( plcpgm_scanoff_set[i]) { windowplcp[i]->ScanOff = plcpgm_stored_scanoff[i];
windowplcp[i]->ScanOff = 0;
plcpgm_scanoff_set[i] = 0;
} }
} }
...@@ -671,9 +681,12 @@ void rt_sim::scan() ...@@ -671,9 +681,12 @@ void rt_sim::scan()
return; return;
} }
if ( !conf->Disable && disable_old) if ( !conf->Disable && disable_old) {
conf->Message = SIM__ACTIVE; conf->Message = SIM__ACTIVE;
store_state();
}
disable_old = conf->Disable; disable_old = conf->Disable;
// Select all threads request // Select all threads request
...@@ -709,6 +722,9 @@ void rt_sim::scan() ...@@ -709,6 +722,9 @@ void rt_sim::scan()
conf->PlcHalt = 0; conf->PlcHalt = 0;
conf->PlcContinueStatus = 0; conf->PlcContinueStatus = 0;
if ( !state_stored)
store_state();
// Count selected threads in running state // Count selected threads in running state
select_thread_cnt = 0; select_thread_cnt = 0;
for ( unsigned int i = 0; i < thread_cnt; i++) { for ( unsigned int i = 0; i < thread_cnt; i++) {
...@@ -741,6 +757,9 @@ void rt_sim::scan() ...@@ -741,6 +757,9 @@ void rt_sim::scan()
conf->PlcContinue = 0; conf->PlcContinue = 0;
conf->PlcHaltStatus = 0; conf->PlcHaltStatus = 0;
if ( !state_stored)
store_state();
// Count selected threads // Count selected threads
select_thread_cnt = 0; select_thread_cnt = 0;
for ( unsigned int i = 0; i < thread_cnt; i++) { for ( unsigned int i = 0; i < thread_cnt; i++) {
...@@ -769,6 +788,9 @@ void rt_sim::scan() ...@@ -769,6 +788,9 @@ void rt_sim::scan()
if ( conf->PlcStep) { if ( conf->PlcStep) {
conf->PlcStep = 0; conf->PlcStep = 0;
if ( !state_stored)
store_state();
// Count selected threads // Count selected threads
select_thread_cnt = 0; select_thread_cnt = 0;
for ( unsigned int i = 0; i < thread_cnt; i++) { for ( unsigned int i = 0; i < thread_cnt; i++) {
...@@ -797,6 +819,9 @@ void rt_sim::scan() ...@@ -797,6 +819,9 @@ void rt_sim::scan()
if ( conf->Load) { if ( conf->Load) {
conf->Load = 0; conf->Load = 0;
if ( !state_stored)
store_state();
// Check that all thread are halted // Check that all thread are halted
int not_halted = 0; int not_halted = 0;
for ( unsigned int i = 0; i < thread_cnt; i++) { for ( unsigned int i = 0; i < thread_cnt; i++) {
...@@ -854,6 +879,9 @@ void rt_sim::scan() ...@@ -854,6 +879,9 @@ void rt_sim::scan()
if ( conf->Store) { if ( conf->Store) {
conf->Store = 0; conf->Store = 0;
if ( !state_stored)
store_state();
// Check that all thread are halted // Check that all thread are halted
int not_halted = 0; int not_halted = 0;
for ( unsigned int i = 0; i < thread_cnt; i++) { for ( unsigned int i = 0; i < thread_cnt; i++) {
...@@ -877,12 +905,14 @@ void rt_sim::scan() ...@@ -877,12 +905,14 @@ void rt_sim::scan()
if ( conf->PlcPgmScanOn) { if ( conf->PlcPgmScanOn) {
conf->PlcPgmScanOn = 0; conf->PlcPgmScanOn = 0;
if ( !state_stored)
store_state();
int found = 0; int found = 0;
for ( unsigned int i = 0; i < plcpgm_cnt; i++) { for ( unsigned int i = 0; i < plcpgm_cnt; i++) {
if ( conf->PlcPgmSelected[i]) { if ( conf->PlcPgmSelected[i]) {
windowplcp[i]->ScanOff = 0; windowplcp[i]->ScanOff = 0;
conf->PlcPgmStatus[i] = SIM__SCANON; conf->PlcPgmStatus[i] = SIM__SCANON;
plcpgm_scanoff_set[i] = 0;
found = 1; found = 1;
} }
} }
...@@ -896,12 +926,14 @@ void rt_sim::scan() ...@@ -896,12 +926,14 @@ void rt_sim::scan()
if ( conf->PlcPgmScanOff) { if ( conf->PlcPgmScanOff) {
conf->PlcPgmScanOff = 0; conf->PlcPgmScanOff = 0;
if ( !state_stored)
store_state();
int found = 0; int found = 0;
for ( unsigned int i = 0; i < plcpgm_cnt; i++) { for ( unsigned int i = 0; i < plcpgm_cnt; i++) {
if ( conf->PlcPgmSelected[i]) { if ( conf->PlcPgmSelected[i]) {
windowplcp[i]->ScanOff = 1; windowplcp[i]->ScanOff = 1;
conf->PlcPgmStatus[i] = SIM__SCANOFF; conf->PlcPgmStatus[i] = SIM__SCANOFF;
plcpgm_scanoff_set[i] = 1;
found = 1; found = 1;
} }
} }
...@@ -910,6 +942,37 @@ void rt_sim::scan() ...@@ -910,6 +942,37 @@ void rt_sim::scan()
else else
conf->Message = SIM__NOSELPLCPGM; conf->Message = SIM__NOSELPLCPGM;
} }
if ( conf->Reset) {
conf->Reset = 0;
// Revert to stored state
if ( state_stored) {
for ( unsigned int i = 0; i < plcpgm_cnt; i++) {
windowplcp[i]->ScanOff = plcpgm_stored_scanoff[i];
}
}
for ( unsigned int i = 0; i < thread_cnt; i++)
conf->ThreadSelected[i] = 1;
for ( unsigned int i = 0; i < plcpgm_cnt; i++)
conf->PlcPgmSelected[i] = 1;
// Set continue order on halted threads
select_thread_cnt = 0;
for ( unsigned int i = 0; i < thread_cnt; i++) {
if ( conf->ThreadStatus[i] == SIM__THREAD_HALT)
select_thread_cnt++;
}
if ( select_thread_cnt > 0) {
conf->PlcContinueOrder = select_thread_cnt;
continue_order_active = true;
conf->Message = SIM__THREADRESPOND;
}
}
} }
void rt_sim::close() void rt_sim::close()
......
...@@ -57,9 +57,9 @@ typedef enum { ...@@ -57,9 +57,9 @@ typedef enum {
class rt_sim { class rt_sim {
public: public:
rt_sim() : scan_time(0.5), thread_cnt(0), select_thread_cnt(0), halt_order_active(false), rt_sim() : scan_time(0.5), thread_cnt(0), select_thread_cnt(0), state_stored(false),
load_order_active(false), disable_old(0) { halt_order_active(false), load_order_active(false), disable_old(0) {
memset(plcpgm_scanoff_set,0,sizeof(plcpgm_scanoff_set));} memset(plcpgm_stored_scanoff,0,sizeof(plcpgm_stored_scanoff));}
void init( qcom_sQid *qid); void init( qcom_sQid *qid);
void open(); void open();
void close(); void close();
...@@ -75,6 +75,7 @@ class rt_sim { ...@@ -75,6 +75,7 @@ class rt_sim {
void store_nmps(); void store_nmps();
void load_nmps(); void load_nmps();
void delete_children( pwr_tOid oid); void delete_children( pwr_tOid oid);
void store_state();
double scan_time; double scan_time;
pwr_sClass_SimulateConfig *conf; pwr_sClass_SimulateConfig *conf;
...@@ -86,7 +87,8 @@ class rt_sim { ...@@ -86,7 +87,8 @@ class rt_sim {
unsigned int plcpgm_thread_idx[200]; unsigned int plcpgm_thread_idx[200];
pwr_sClass_windowplc *windowplcp[200]; pwr_sClass_windowplc *windowplcp[200];
pwr_tDlid windowplc_dlid[200]; pwr_tDlid windowplc_dlid[200];
int plcpgm_scanoff_set[200]; int plcpgm_stored_scanoff[200];
bool state_stored;
bool halt_order_active; bool halt_order_active;
bool step_order_active; bool step_order_active;
bool continue_order_active; bool continue_order_active;
......
...@@ -371,6 +371,16 @@ SObject pwrb:Class ...@@ -371,6 +371,16 @@ SObject pwrb:Class
Attr Flags |= PWR_MASK_NOEDIT Attr Flags |= PWR_MASK_NOEDIT
EndBody EndBody
EndObject EndObject
!/**
! Reset.
!*/
Object Reset $Attribute 32
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
EndBody
EndObject
EndObject EndObject
Object Template SimulateConfig Object Template SimulateConfig
Body RtBody Body RtBody
......
...@@ -4,22 +4,22 @@ ...@@ -4,22 +4,22 @@
100 20 100 20
135 20 135 20
101 20 101 20
102 -73 102 310
103 -136 103 -24
104 2.99213 104 3.7377
136 2.99213 136 3.7377
105 100 105 100
106 -10 106 2
107 -20 107 -4
108 62.7005 108 62.5004
109 0.65 109 0.649995
110 25.5408 110 28.6409
111 1.2 111 1.2
116 0 116 55
117 0 117 0
118 208 118 183
119 113 119 113
120 1 120 0
121 Claes context 121 Claes context
122 0 122 0
126 1 126 1
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
134 134
22 22
2200 0 2200 0
2201 270 2201 271
2202 pwr_c_simulateconfig 2202 pwr_c_simulateconfig
2203 51 2203 51
2205 0 2205 0
...@@ -462,10 +462,10 @@ pwr_exe: ...@@ -462,10 +462,10 @@ pwr_exe:
99 99
19 19
1904 O254 1904 O254
1900 62.7005 1900 62.5005
1901 31.8 1901 31.6
1902 25.5408 1902 28.6408
1903 4.1 1903 7.2
1908 0 1908 0
1909 32 1909 32
1910 32 1910 32
...@@ -504,10 +504,10 @@ pwr_exe: ...@@ -504,10 +504,10 @@ pwr_exe:
28 28
2800 3.32263 2800 3.32263
2801 0 2801 0
2802 29.308 2802 29.108
2803 0 2803 0
2804 4.20409 2804 4.20409
2805 -19.4429 2805 -16.3429
2806 0 2806 0
99 99
99 99
...@@ -1506,11 +1506,11 @@ pwr_exe: ...@@ -1506,11 +1506,11 @@ pwr_exe:
0 0
0 0
0 0
1006 54.388 1006 51.4326
1007 23.3812 1007 23.3812
1008 2.82 1008 2.82
1009 1.91 1009 1.91
1013 54.388 1013 51.4326
1014 23.3812 1014 23.3812
1015 2.82 1015 2.82
1016 1.91 1016 1.91
...@@ -1550,7 +1550,7 @@ pwr_exe: ...@@ -1550,7 +1550,7 @@ pwr_exe:
99 99
2707 2707
28 28
2800 1.16567 2800 1.05456
2801 0 2801 0
2802 23.3812 2802 23.3812
2803 0 2803 0
...@@ -1964,12 +1964,12 @@ pwr_exe: ...@@ -1964,12 +1964,12 @@ pwr_exe:
0 0
0 0
0 0
1006 61.8806 1006 62.0806
1007 56.95 1007 57.15
1008 2.81377 1008 2.81377
1009 1.85 1009 1.85
1013 61.8806 1013 62.0806
1014 56.95 1014 57.15
1015 2.81377 1015 2.81377
1016 1.85 1016 1.85
1003 1003
...@@ -2011,7 +2011,7 @@ pwr_exe: ...@@ -2011,7 +2011,7 @@ pwr_exe:
28 28
2800 2.24115 2800 2.24115
2801 0 2801 0
2802 56.5018 2802 56.7018
2803 0 2803 0
2804 1.13385 2804 1.13385
2805 1.62323 2805 1.62323
...@@ -2162,12 +2162,12 @@ pwr_exe: ...@@ -2162,12 +2162,12 @@ pwr_exe:
0 0
0 0
0 0
1006 57.6388 1006 57.5851
1007 53.85 1007 53.7963
1008 5.41377 1008 5.41377
1009 4.45 1009 4.45
1013 57.6388 1013 57.5851
1014 53.85 1014 53.7963
1015 5.41377 1015 5.41377
1016 4.45 1016 4.45
1003 1003
...@@ -2209,7 +2209,7 @@ pwr_exe: ...@@ -2209,7 +2209,7 @@ pwr_exe:
28 28
2800 1.72215 2800 1.72215
2801 0 2801 0
2802 53.5056 2802 53.4519
2803 0 2803 0
2804 1.13385 2804 1.13385
2805 4.22323 2805 4.22323
...@@ -2293,12 +2293,12 @@ pwr_exe: ...@@ -2293,12 +2293,12 @@ pwr_exe:
0 0
0 0
0 0
1006 62.0388 1006 62.0806
1007 58.25 1007 58.2918
1008 5.41377 1008 5.41377
1009 4.45 1009 4.45
1013 62.0388 1013 62.0806
1014 58.25 1014 58.2918
1015 5.41377 1015 5.41377
1016 4.45 1016 4.45
1003 1003
...@@ -2340,7 +2340,7 @@ pwr_exe: ...@@ -2340,7 +2340,7 @@ pwr_exe:
28 28
2800 1.72215 2800 1.72215
2801 0 2801 0
2802 57.9056 2802 57.9474
2803 0 2803 0
2804 1.13385 2804 1.13385
2805 4.22323 2805 4.22323
...@@ -2867,5 +2867,139 @@ pwr_exe: ...@@ -2867,5 +2867,139 @@ pwr_exe:
2806 0 2806 0
99 99
99 99
27
2703 10000
2704 32
2722 10000
2705 32
2723 10000
2706 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 pwr_smallbuttoncenter
1002 O270
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 56.4246
1007 53.7963
1008 2.81377
1009 1.85
1013 56.4246
1014 53.7963
1015 2.81377
1016 1.85
1003
0
12
0
0
0
0
0
0
0
0
1004
"Reset"
1001
7
700 4.45
701 7.65
99
1010
1011
1018
1019
1020
1021
1022
1023
1024
1025
1012 0
1017 9999
1027 9999
1026 33619964
1028 0
1029
99
2707
28
2800 1.19469
2801 0
2802 53.5573
2803 0
2804 1.13385
2805 1.62323
2806 0
99
2716 0
2718
2717
2719 0
2724 1
2727 0
2728 303
2729 4
2721
1
100 1
101 260
102 33619964
103 0
57
5700 Do you want to reset
99
51
5100 $object.Reset##Boolean
5101 1
5102 1
99
99
99
99 99
99 99
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