Commit c269f138 authored by claes's avatar claes

IEqual, IGreaterEqual etc added

parent 65ef725f
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#endif #endif
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
#include <float.h>
#include "pwr.h" #include "pwr.h"
#include "pwr_baseclasses.h" #include "pwr_baseclasses.h"
...@@ -686,7 +687,19 @@ void Equal_exec( ...@@ -686,7 +687,19 @@ void Equal_exec(
{ {
o->In1 = *o->In1P; o->In1 = *o->In1P;
o->In2 = *o->In2P; o->In2 = *o->In2P;
o->Status = (o->In1 == o->In2); o->Status = (fabsf(o->In1 - o->In2) < FLT_EPSILON);
}
/*_*
@aref notequal NotEqual
*/
void NotEqual_exec(
plc_sThread *tp,
pwr_sClass_NotEqual *o)
{
o->In1 = *o->In1P;
o->In2 = *o->In2P;
o->Status = !(fabsf(o->In1 - o->In2) < FLT_EPSILON);
} }
/*_* /*_*
...@@ -698,7 +711,7 @@ void GreaterEqual_exec( ...@@ -698,7 +711,7 @@ void GreaterEqual_exec(
{ {
o->In1 = *o->In1P; o->In1 = *o->In1P;
o->In2 = *o->In2P; o->In2 = *o->In2P;
o->Status = (o->In1 >= o->In2); o->Status = (o->In1 >= o->In2) || (fabsf(o->In1 - o->In2) < FLT_EPSILON);
} }
/*_* /*_*
...@@ -722,7 +735,7 @@ void LessEqual_exec( ...@@ -722,7 +735,7 @@ void LessEqual_exec(
{ {
o->In1 = *o->In1P; o->In1 = *o->In1P;
o->In2 = *o->In2P; o->In2 = *o->In2P;
o->Status = (o->In1 <= o->In2); o->Status = (o->In1 <= o->In2) || (fabsf(o->In1 - o->In2) < FLT_EPSILON);
} }
/*_* /*_*
...@@ -737,6 +750,78 @@ void LessThan_exec( ...@@ -737,6 +750,78 @@ void LessThan_exec(
o->Status = (o->In1 < o->In2); o->Status = (o->In1 < o->In2);
} }
/*_*
@aref iequal IEqual
*/
void IEqual_exec(
plc_sThread *tp,
pwr_sClass_IEqual *o)
{
o->In1 = *o->In1P;
o->In2 = *o->In2P;
o->Status = (o->In1 == o->In2);
}
/*_*
@aref iequal INotEqual
*/
void INotEqual_exec(
plc_sThread *tp,
pwr_sClass_INotEqual *o)
{
o->In1 = *o->In1P;
o->In2 = *o->In2P;
o->Status = (o->In1 != o->In2);
}
/*_*
@aref igreaterequal IGreaterEqual
*/
void IGreaterEqual_exec(
plc_sThread *tp,
pwr_sClass_IGreaterEqual *o)
{
o->In1 = *o->In1P;
o->In2 = *o->In2P;
o->Status = (o->In1 >= o->In2);
}
/*_*
@aref igreaterthan IGreaterThan
*/
void IGreaterThan_exec(
plc_sThread *tp,
pwr_sClass_IGreaterThan *o)
{
o->In1 = *o->In1P;
o->In2 = *o->In2P;
o->Status = (o->In1 > o->In2);
}
/*_*
@aref ilessequal ILessEqual
*/
void ILessEqual_exec(
plc_sThread *tp,
pwr_sClass_ILessEqual *o)
{
o->In1 = *o->In1P;
o->In2 = *o->In2P;
o->Status = (o->In1 <= o->In2);
}
/*_*
@aref ilessthan ILessThan
*/
void ILessThan_exec(
plc_sThread *tp,
pwr_sClass_ILessThan *o)
{
o->In1 = *o->In1P;
o->In2 = *o->In2P;
o->Status = (o->In1 < o->In2);
}
/*_* /*_*
IAdd Integer addition. IAdd Integer addition.
......
...@@ -11,12 +11,12 @@ SObject pwrb:Class ...@@ -11,12 +11,12 @@ SObject pwrb:Class
!/** !/**
! @Version 1.0 ! @Version 1.0
! @Code rt_plc_arithm.c ! @Code rt_plc_arithm.c
! @Group Plc,PlcInteger ! @Group Plc,PlcAnalog
! @Summary Check if two integer are equal. ! @Summary Check if two analog values are equal.
! Equal compare two integer values and returnes true if they are equal. ! Equal compare two analog values and returnes true if they are equal.
! @image orm_equal_fo.gif ! @image orm_equal_fo.gif
!*/ !*/
Object Equal $ClassDef 391 Object Equal $ClassDef 419
Body SysBody Body SysBody
Attr Editor = pwr_eEditor_PlcEd Attr Editor = pwr_eEditor_PlcEd
Attr Method = pwr_eMethod_Connections Attr Method = pwr_eMethod_Connections
...@@ -27,24 +27,24 @@ SObject pwrb:Class ...@@ -27,24 +27,24 @@ SObject pwrb:Class
Attr StructName = "Equal" Attr StructName = "Equal"
EndBody EndBody
!/** !/**
! Integer input 1. ! Analog input 1.
!*/ !*/
Object In1 $Input 1 Object In1 $Input 1
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_NOREMOVE Attr Flags |= PWR_MASK_NOREMOVE
Attr Flags |= PWR_MASK_NOINVERT Attr Flags |= PWR_MASK_NOINVERT
Attr Flags |= PWR_MASK_NOEDIT Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "In1" Attr GraphName = "In1"
EndBody EndBody
EndObject EndObject
!/** !/**
! Integer input 2. ! Analog input 2.
!*/ !*/
Object In2 $Input 2 Object In2 $Input 2
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_NOINVERT Attr Flags |= PWR_MASK_NOINVERT
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "In2" Attr GraphName = "In2"
EndBody EndBody
EndObject EndObject
......
...@@ -11,13 +11,13 @@ SObject pwrb:Class ...@@ -11,13 +11,13 @@ SObject pwrb:Class
!/** !/**
! @Version 1.0 ! @Version 1.0
! @Code rt_plc_arithm.c ! @Code rt_plc_arithm.c
! @Group Plc,PlcInteger ! @Group Plc,PlcAnalog
! @Summary Check if an integer value is greater than or equal another. ! @Summary Check if an analog value is greater than or equal another.
! GreaterEqual compares two integer values and returns true if the first ! GreaterEqual compares two analog values and returns true if the first
! is greater than or equal the second. ! is greater than or equal the second.
! @image orm_greaterequal_fo.gif ! @image orm_greaterequal_fo.gif
!*/ !*/
Object GreaterEqual $ClassDef 392 Object GreaterEqual $ClassDef 420
Body SysBody Body SysBody
Attr Editor = pwr_eEditor_PlcEd Attr Editor = pwr_eEditor_PlcEd
Attr Method = pwr_eMethod_Connections Attr Method = pwr_eMethod_Connections
...@@ -28,24 +28,24 @@ SObject pwrb:Class ...@@ -28,24 +28,24 @@ SObject pwrb:Class
Attr StructName = "GreaterEqual" Attr StructName = "GreaterEqual"
EndBody EndBody
!/** !/**
! Integer input 1. ! Analog input 1.
!*/ !*/
Object In1 $Input 1 Object In1 $Input 1
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_NOREMOVE Attr Flags |= PWR_MASK_NOREMOVE
Attr Flags |= PWR_MASK_NOINVERT Attr Flags |= PWR_MASK_NOINVERT
Attr Flags |= PWR_MASK_NOEDIT Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "In1" Attr GraphName = "In1"
EndBody EndBody
EndObject EndObject
!/** !/**
! Integer input 2. ! Analog input 2.
!*/ !*/
Object In2 $Input 2 Object In2 $Input 2
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_NOINVERT Attr Flags |= PWR_MASK_NOINVERT
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "In2" Attr GraphName = "In2"
EndBody EndBody
EndObject EndObject
......
...@@ -11,13 +11,13 @@ SObject pwrb:Class ...@@ -11,13 +11,13 @@ SObject pwrb:Class
!/** !/**
! @Version 1.0 ! @Version 1.0
! @Code rt_plc_arithm.c ! @Code rt_plc_arithm.c
! @Group Plc,PlcInteger ! @Group Plc,PlcAnalog
! @Summary Check if an integer value is greater than another. ! @Summary Check if an analog value is greater than another.
! GreaterThan compares two integer values and returns true if the first ! GreaterThan compares two analog values and returns true if the first
! is greater than the second. ! is greater than the second.
! @image orm_greaterthan_fo.gif ! @image orm_greaterthan_fo.gif
!*/ !*/
Object GreaterThan $ClassDef 393 Object GreaterThan $ClassDef 421
Body SysBody Body SysBody
Attr Editor = pwr_eEditor_PlcEd Attr Editor = pwr_eEditor_PlcEd
Attr Method = pwr_eMethod_Connections Attr Method = pwr_eMethod_Connections
...@@ -28,24 +28,24 @@ SObject pwrb:Class ...@@ -28,24 +28,24 @@ SObject pwrb:Class
Attr StructName = "GreaterThan" Attr StructName = "GreaterThan"
EndBody EndBody
!/** !/**
! Integer input 1. ! Analog input 1.
!*/ !*/
Object In1 $Input 1 Object In1 $Input 1
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_NOREMOVE Attr Flags |= PWR_MASK_NOREMOVE
Attr Flags |= PWR_MASK_NOINVERT Attr Flags |= PWR_MASK_NOINVERT
Attr Flags |= PWR_MASK_NOEDIT Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "In1" Attr GraphName = "In1"
EndBody EndBody
EndObject EndObject
!/** !/**
! Integer input 2. ! Analog input 2.
!*/ !*/
Object In2 $Input 2 Object In2 $Input 2
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_NOINVERT Attr Flags |= PWR_MASK_NOINVERT
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "In2" Attr GraphName = "In2"
EndBody EndBody
EndObject EndObject
......
...@@ -11,13 +11,13 @@ SObject pwrb:Class ...@@ -11,13 +11,13 @@ SObject pwrb:Class
!/** !/**
! @Version 1.0 ! @Version 1.0
! @Code rt_plc_arithm.c ! @Code rt_plc_arithm.c
! @Group Plc,PlcInteger ! @Group Plc,PlcAnalog
! @Summary Check if an integer value is less than or equal another. ! @Summary Check if an analog value is less than or equal another.
! LessEqual compares two integer values and returns true if the first ! LessEqual compares two analog values and returns true if the first
! is less than or equal the second. ! is less than or equal the second.
! @image orm_lessequal_fo.gif ! @image orm_lessequal_fo.gif
!*/ !*/
Object LessEqual $ClassDef 394 Object LessEqual $ClassDef 422
Body SysBody Body SysBody
Attr Editor = pwr_eEditor_PlcEd Attr Editor = pwr_eEditor_PlcEd
Attr Method = pwr_eMethod_Connections Attr Method = pwr_eMethod_Connections
...@@ -28,24 +28,24 @@ SObject pwrb:Class ...@@ -28,24 +28,24 @@ SObject pwrb:Class
Attr StructName = "LessEqual" Attr StructName = "LessEqual"
EndBody EndBody
!/** !/**
! Integer input 1. ! Analog input 1.
!*/ !*/
Object In1 $Input 1 Object In1 $Input 1
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_NOREMOVE Attr Flags |= PWR_MASK_NOREMOVE
Attr Flags |= PWR_MASK_NOINVERT Attr Flags |= PWR_MASK_NOINVERT
Attr Flags |= PWR_MASK_NOEDIT Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "In1" Attr GraphName = "In1"
EndBody EndBody
EndObject EndObject
!/** !/**
! Integer input 2. ! Analog input 2.
!*/ !*/
Object In2 $Input 2 Object In2 $Input 2
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_NOINVERT Attr Flags |= PWR_MASK_NOINVERT
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "In2" Attr GraphName = "In2"
EndBody EndBody
EndObject EndObject
......
...@@ -11,13 +11,13 @@ SObject pwrb:Class ...@@ -11,13 +11,13 @@ SObject pwrb:Class
!/** !/**
! @Version 1.0 ! @Version 1.0
! @Code rt_plc_arithm.c ! @Code rt_plc_arithm.c
! @Group Plc,PlcInteger ! @Group Plc,PlcAnalog
! @Summary Check if an integer value is less than another. ! @Summary Check if an analog value is less than another.
! LessThan compares two integer values and returns true if the first ! LessThan compares two analog values and returns true if the first
! is less than the second. ! is less than the second.
! @image orm_lessthan_fo.gif ! @image orm_lessthan_fo.gif
!*/ !*/
Object LessThan $ClassDef 395 Object LessThan $ClassDef 423
Body SysBody Body SysBody
Attr Editor = pwr_eEditor_PlcEd Attr Editor = pwr_eEditor_PlcEd
Attr Method = pwr_eMethod_Connections Attr Method = pwr_eMethod_Connections
...@@ -28,24 +28,24 @@ SObject pwrb:Class ...@@ -28,24 +28,24 @@ SObject pwrb:Class
Attr StructName = "LessThan" Attr StructName = "LessThan"
EndBody EndBody
!/** !/**
! Integer input 1. ! Analog input 1.
!*/ !*/
Object In1 $Input 1 Object In1 $Input 1
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_NOREMOVE Attr Flags |= PWR_MASK_NOREMOVE
Attr Flags |= PWR_MASK_NOINVERT Attr Flags |= PWR_MASK_NOINVERT
Attr Flags |= PWR_MASK_NOEDIT Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "In1" Attr GraphName = "In1"
EndBody EndBody
EndObject EndObject
!/** !/**
! Integer input 2. ! Analog input 2.
!*/ !*/
Object In2 $Input 2 Object In2 $Input 2
Body SysBody Body SysBody
Attr Flags |= PWR_MASK_NOINVERT Attr Flags |= PWR_MASK_NOINVERT
Attr TypeRef = "pwrs:Type-$Int32" Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "In2" Attr GraphName = "In2"
EndBody EndBody
EndObject EndObject
......
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