Commit 4c1e43e2 authored by Claes Sjofors's avatar Claes Sjofors

Time function for plc without exceptions at invalid times added, and fix in...

Time function for plc without exceptions at invalid times added, and fix in time_Aadd for negative deltatimes
parent cdeacae0
......@@ -581,6 +581,8 @@ static const pwr_tNid pwr_cNNid = 0; //!< Zero node identity constan
static const pwr_tStatus pwr_cNStatus = 0; //!< Zero status constant.
static const pwr_tTime pwr_cNTime = {0, 0}; //!< Zero time constant.
static const pwr_tDeltaTime pwr_cNDeltaTime = {0, 0}; //!< Zero deltatime constant.
static const pwr_tTime pwr_cNotATime = {0, 1000000000}; //!< Illegal time.
static const pwr_tDeltaTime pwr_cNotADeltaTime = {0, 1000000000}; //!< Illegal delta time.
/* Gereral macro definitions */
......
This diff is collapsed.
......@@ -160,20 +160,29 @@ typedef enum {
int time_IsNull (pwr_tTime *t1);
pwr_tTime * time_Aabs (pwr_tTime*, pwr_tTime*);
pwr_tTime * time_Aadd (pwr_tTime*, pwr_tTime*, pwr_tDeltaTime*);
pwr_tTime * time_Aadd_NE (pwr_tTime*, pwr_tTime*, pwr_tDeltaTime*);
int time_Acomp (pwr_tTime*, pwr_tTime*);
int time_Acomp_NE (pwr_tTime*, pwr_tTime*);
pwr_tDeltaTime * time_Adiff (pwr_tDeltaTime*, pwr_tTime*, pwr_tTime*);
pwr_tDeltaTime * time_Adiff_NE (pwr_tDeltaTime*, pwr_tTime*, pwr_tTime*);
pwr_tTime * time_Aneg (pwr_tTime*, pwr_tTime*);
pwr_tTime * time_Asub (pwr_tTime*, pwr_tTime*, pwr_tDeltaTime*);
pwr_tTime * time_Asub_NE (pwr_tTime*, pwr_tTime*, pwr_tDeltaTime*);
pwr_tDeltaTime * time_Dabs (pwr_tDeltaTime*, pwr_tDeltaTime*);
pwr_tDeltaTime * time_Dabs_NE (pwr_tDeltaTime*, pwr_tDeltaTime*);
pwr_tDeltaTime * time_Dadd (pwr_tDeltaTime*, pwr_tDeltaTime*, pwr_tDeltaTime*);
pwr_tDeltaTime * time_Dadd_NE (pwr_tDeltaTime*, pwr_tDeltaTime*, pwr_tDeltaTime*);
pwr_tDeltaTime * time_Dneg (pwr_tDeltaTime*, pwr_tDeltaTime*);
pwr_tDeltaTime * time_Dneg_NE (pwr_tDeltaTime*, pwr_tDeltaTime*);
pwr_tDeltaTime * time_Dsub (pwr_tDeltaTime*, pwr_tDeltaTime*, pwr_tDeltaTime*);
pwr_tDeltaTime * time_Dsub_NE (pwr_tDeltaTime*, pwr_tDeltaTime*, pwr_tDeltaTime*);
#if defined (OS_VMS) || defined(OS_ELN)
pwr_tStatus time_Dmul (pwr_tDeltaTime*, pwr_tDeltaTime*, pwr_tInt32);
#endif
int time_Dcomp (pwr_tDeltaTime*, pwr_tDeltaTime*);
int time_Dcomp_NE (pwr_tDeltaTime*, pwr_tDeltaTime*);
pwr_tStatus time_DtoAscii (pwr_tDeltaTime*, int, char*, int);
pwr_tStatus time_AtoAscii (pwr_tTime*, time_eFormat, char*, int);
pwr_tStatus time_AsciiToD (const char*, pwr_tDeltaTime*);
......
......@@ -109,35 +109,35 @@
@aref atadd AtAdd
*/
#define AtAdd_exec(obj,t1,t2) \
time_Aadd( &obj->ActVal, &t1, &t2);
time_Aadd_NE( &obj->ActVal, &t1, &t2);
/*_*
DTADD
@aref dtadd DtAdd
*/
#define DtAdd_exec(obj,t1,t2) \
time_Dadd( &obj->ActVal, &t1, &t2);
time_Dadd_NE( &obj->ActVal, &t1, &t2);
/*_*
ATSUB
@aref atsub AtSub
*/
#define AtSub_exec(obj,t1,t2) \
time_Adiff( &obj->ActVal, &t1, &t2);
time_Adiff_NE( &obj->ActVal, &t1, &t2);
/*_*
ATDTSUB
@aref atdtsub AtDtSub
*/
#define AtDtSub_exec(obj,t1,t2) \
time_Asub( &obj->ActVal, &t1, &t2);
time_Asub_NE( &obj->ActVal, &t1, &t2);
/*_*
DTSUB
@aref dtsub DtSub
*/
#define DtSub_exec(obj,t1,t2) \
time_Dsub( &obj->ActVal, &t1, &t2);
time_Dsub_NE( &obj->ActVal, &t1, &t2);
/*_*
DTTOA
......@@ -165,42 +165,42 @@
@aref atgreaterthan AtGreaterThan
*/
#define AtGreaterThan_exec(obj,t1,t2) \
obj->Status = (time_Acomp( &t1, &t2) == 1);
obj->Status = (time_Acomp_NE( &t1, &t2) == 1);
/*_*
ATLESSTHAN
@aref atlessthan AtLessThan
*/
#define AtLessThan_exec(obj,t1,t2) \
obj->Status = (time_Acomp( &t1, &t2) == -1);
obj->Status = (time_Acomp_NE( &t1, &t2) == -1);
/*_*
ATEQUAL
@aref atequal AtEqual
*/
#define AtEqual_exec(obj,t1,t2) \
obj->Status = (time_Acomp( &t1, &t2) == 0);
obj->Status = (time_Acomp_NE( &t1, &t2) == 0);
/*_*
DTGREATERTHAN
@aref dtgreaterthan DtGreaterThan
*/
#define DtGreaterThan_exec(obj,t1,t2) \
obj->Status = (time_Dcomp( &t1, &t2) == 1);
obj->Status = (time_Dcomp_NE( &t1, &t2) == 1);
/*_*
DTLESSTHAN
@aref dtlessthan DtLessThan
*/
#define DtLessThan_exec(obj,t1,t2) \
obj->Status = (time_Dcomp( &t1, &t2) == -1);
obj->Status = (time_Dcomp_NE( &t1, &t2) == -1);
/*_*
DTEQUAL
@aref dtequalthan DtEqual
*/
#define DtEqual_exec(obj,t1,t2) \
obj->Status = (time_Dcomp( &t1, &t2) == 0);
obj->Status = (time_Dcomp_NE( &t1, &t2) == 0);
/*_*
LOCALTIME
......
......@@ -47,3 +47,5 @@ ivtime <invalid time> /error
ivdtime <invalid delta time> /error
negtime <negative time> /info
clkchange <clock has changed> /info
nadt <Not a deltatime> /error
nat <Not a time> /error
......@@ -55,6 +55,7 @@
#include "co_api_user.h"
#include "co_msg.h"
#include "co_syi.h"
#include "co_time_msg.h"
#include "pwr_baseclasses.h"
#include "rt_xnav_msg.h"
#include "flow.h"
......@@ -869,7 +870,7 @@ void XNav::attrvalue_to_string( int type_id, pwr_tTid tid, void *value_ptr,
default:
sts = time_AtoAscii( (pwr_tTime *) value_ptr, time_eFormat_DateAndTime,
timstr, sizeof(timstr));
if ( EVEN(sts))
if ( EVEN(sts) && sts != TIME__NAT)
strcpy( timstr, "-");
*len = snprintf( str, size, "%s", timstr);
}
......@@ -884,7 +885,7 @@ void XNav::attrvalue_to_string( int type_id, pwr_tTid tid, void *value_ptr,
default:
sts = time_DtoAscii( (pwr_tDeltaTime *) value_ptr, 1,
timstr, sizeof(timstr));
if ( EVEN(sts))
if ( EVEN(sts) && sts != TIME__NADT)
strcpy( timstr, "Undefined time");
*len = snprintf( str, size, "%s", timstr);
}
......
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