ProviewR Programmer's Reference Manual  V6.1.4
rt_aproc.c
Go to the documentation of this file.
1 /*
2  * ProviewR Open Source Process Control.
3  * Copyright (C) 2005-2025 SSAB EMEA AB.
4  *
5  * This file is part of ProviewR.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation, either version 2 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with ProviewR. If not, see <http://www.gnu.org/licenses/>
19  *
20  * Linking ProviewR statically or dynamically with other modules is
21  * making a combined work based on ProviewR. Thus, the terms and
22  * conditions of the GNU General Public License cover the whole
23  * combination.
24  *
25  * In addition, as a special exception, the copyright holders of
26  * ProviewR give you permission to, from the build function in the
27  * ProviewR Configurator, combine ProviewR with modules generated by the
28  * ProviewR PLC Editor to a PLC program, regardless of the license
29  * terms of these modules. You may copy and distribute the resulting
30  * combined work under the terms of your choice, provided that every
31  * copy of the combined work is accompanied by a complete copy of
32  * the source code of ProviewR (the version used to produce the
33  * combined work), being distributed under the terms of the GNU
34  * General Public License plus this exception.
35  */
36 
37 #include "co_cdh.h"
38 #include "co_time.h"
39 #include "rt_gdh.h"
40 #include "rt_aproc.h"
41 #include "rt_proc_msg.h"
42 
43 static pwr_sNode* proc_np = 0;
44 
58 {
59  pwr_tStatus sts;
60  errh_eAnix anix = errh_Anix();
61 
62  if (!anix)
63  return PROC__ANIX;
64 
65  if (!proc_np) {
66  pwr_tOid noid;
67 
68  sts = gdh_GetNodeObject(0, &noid);
69  if (EVEN(sts))
70  return sts;
71 
72  sts = gdh_ObjidToPointer(noid, (void**)&proc_np);
73  if (EVEN(sts))
74  return sts;
75  }
76  proc_np->ProcObject[anix - 1] = oid;
77  return PROC__SUCCESS;
78 }
79 
90 pwr_tStatus aproc_TimeStamp(float cycletime, float maxdelay)
91 {
92  pwr_tStatus sts;
93  pwr_tTime t, tmo_time;
94  pwr_tDeltaTime dt;
95  errh_eAnix anix = errh_Anix();
96 
97  if (!anix)
98  return PROC__ANIX;
99 
100  if (!proc_np) {
101  pwr_tOid noid;
102 
103  sts = gdh_GetNodeObject(0, &noid);
104  if (EVEN(sts))
105  return sts;
106 
107  sts = gdh_ObjidToPointer(noid, (void**)&proc_np);
108  if (EVEN(sts))
109  return sts;
110  }
111 
112  time_GetTime(&t);
113  time_FloatToD(&dt, cycletime + maxdelay);
114  time_Aadd(&tmo_time, &t, &dt);
115  proc_np->ProcTimeStamp[anix - 1] = tmo_time;
116  return PROC__SUCCESS;
117 }
Include file for Cdh Class definition handler.
Include file for Time management.
pwr_tStatus aproc_TimeStamp(float cycletime, float maxdelay)
Set application timestamp. The timestamp is supervised by the event monitor and if the timestamp is d...
Definition: rt_aproc.c:90
pwr_tStatus aproc_RegisterObject(pwr_tOid oid)
Register Application object. The Application object is stored in the $Node object and be opened from ...
Definition: rt_aproc.c:57
errh_eAnix
Definition: rt_errh.h:99
errh_eAnix errh_Anix(void)
Get application index for the process.
Definition: rt_errh.c:212
pwr_tStatus gdh_ObjidToPointer(pwr_tObjid object, void **objectData)
Gets the address of the data of an object, given its object identity.
Definition: rt_gdh.c:2431
pwr_tStatus gdh_GetNodeObject(pwr_tNodeId nodeIndex, pwr_tObjid *object)
Return the objid of the node object for a node identified by a node identifier (of type pwr_tNodeId).
Definition: rt_gdh.c:1822
pwr_tDeltaTime * time_FloatToD(pwr_tDeltaTime *, pwr_tFloat32)
Convert float to time.
Definition: co_time.c:1293
int time_GetTime(pwr_tTime *ts)
Get current time.
Definition: co_time.c:1427
pwr_tTime * time_Aadd(pwr_tTime *, pwr_tTime *, pwr_tDeltaTime *)
Add an absolute time and a delta time.
Definition: co_time.c:199
#define EVEN(a)
Check if value is even.
Definition: pwr.h:623
int pwr_tStatus
Status type.
Definition: pwr.h:284
Include file for AProc Application process interface.
Include file for Gdh Global Data Handler.
Delta time type.
Definition: pwr.h:369
Object identity type.
Definition: pwr.h:263