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