Commit 87a00ab3 authored by Claes Sjofors's avatar Claes Sjofors

Plc function objects PulseTrain, True and False added

parent 580daa09
...@@ -192,6 +192,25 @@ ...@@ -192,6 +192,25 @@
if ( in) \ if ( in) \
memcpy( &object->OutDataP, in, 12); memcpy( &object->OutDataP, in, 12);
/*_*
@aref pulsetrain PulseTrain
*/
#define PulseTrain_exec(o)\
o->P30s = (tp->before_scan.tv_sec / 15) & 1 ? 1 : 0;\
o->P10s = (tp->before_scan.tv_sec / 5) & 1 ? 1 : 0;\
o->P5s = ((tp->before_scan.tv_sec * 10 +\
tp->before_scan.tv_nsec / 100000000) / 25) & 1 ? 1 : 0; \
o->P2s = tp->before_scan.tv_sec & 1 ? 1 : 0;\
o->P1s = (tp->before_scan.tv_nsec / 500000000) & 1 ? 1 : 0;\
o->P500ms = (tp->before_scan.tv_nsec / 250000000) & 1 ? 1 : 0;\
o->P200ms = (tp->before_scan.tv_nsec / 100000000) & 1 ? 1 : 0;\
o->P100ms = (tp->before_scan.tv_nsec / 50000000) & 1 ? 1 : 0;\
o->P50ms = (tp->before_scan.tv_nsec / 25000000) & 1 ? 1 : 0;\
o->P20ms = (tp->before_scan.tv_nsec / 10000000) & 1 ? 1 : 0;\
o->P10ms = (tp->before_scan.tv_nsec / 5000000) & 1 ? 1 : 0;\
o->P5ms = (tp->before_scan.tv_nsec / 2500000) & 1 ? 1 : 0;\
o->P2ms = (tp->before_scan.tv_nsec / 1000000) & 1 ? 1 : 0;\
o->P1ms = (tp->before_scan.tv_nsec / 500000) & 1 ? 1 : 0;
......
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2011 SSAB Oxelosund AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_false.wb_load -- Defines the class False.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group Plc,PlcLogic
! @Summary Function object with false output.
! Function object with false output value.
! @image orm_false_fo.png
!*/
Object False $ClassDef 566
Body SysBody
Attr Editor = pwr_eEditor_PlcEd
Attr Method = pwr_eMethod_Connections
Attr PopEditor = 2
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "False"
EndBody
!/**
! False output.
!*/
Object Status $Output 1
Body SysBody
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_RTHIDE
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
EndObject
Object DevBody $ObjBodyDef 2
Object PlcNode $Buffer 1
Body SysBody
Attr Class = pwr_eClass_PlcNode
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
EndObject
Object GraphPlcNode $GraphPlcNode
Body SysBody
Attr object_type = 11
Attr parameters[0] = 0
Attr parameters[1] = 0
Attr parameters[2] = 1
Attr parameters[3] = 0
Attr subwindows = 0
Attr graphmethod = 4
Attr graphindex = 46
Attr default_mask[0] = 0
Attr default_mask[1] = 1
Attr segname_annotation = 0
Attr devbody_annotation = 0
Attr compmethod = 21
Attr compindex = 0
Attr tracemethod = 0
Attr traceindex = 0
Attr connectmethod = 0
Attr executeordermethod = 0
Attr objname = "False"
Attr graphname = "False"
EndBody
EndObject
Object Template False
EndObject
EndObject
EndSObject
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2011 SSAB Oxelosund AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_pulsetrain.wb_load -- Defines the class PulseTrain.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Code rt_plc_macro_div.h
! @Group Plc,PlcLogic
! @Summary Pulse trains with different cycletime.
! Pulse trains with different cycletime.
!
! The object has a number of outputs with pulsetrains of
! different cycletimes: 30 s, 10 s, 5 s, 2 s, 1 s, 500 ms,
! 200 ms, 100 ms, 50 ms, 20 ms, 10 ms, 5 ms, 2 ms and 1 ms.
! Note that the cycle time of the plc thread has to be at
! least half the cycle time of a used pulse train output.
!
! @image orm_pulsetrain_fo.png
!
! @image orm_pulsetrain_ex.png
! Pulse train with cycletime 2 s
!*/
Object PulseTrain $ClassDef 545
Body SysBody
Attr Editor = pwr_eEditor_PlcEd
Attr Method = pwr_eMethod_Connections
Attr PopEditor = 2
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "PulseTrain"
EndBody
!/**
! Pulse train output with cycle time 30 s.
!*/
Object P30s $Output 1
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "30s"
EndBody
EndObject
!/**
! Pulse train output with cycle time 10 s.
!*/
Object P10s $Output 2
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "10s"
EndBody
EndObject
!/**
! Pulse train output with cycle time 5 s.
!*/
Object P5s $Output 3
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "5s"
EndBody
EndObject
!/**
! Pulse train output with cycle time 2 s.
!*/
Object P2s $Output 4
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "2s"
EndBody
EndObject
!/**
! Pulse train output with cycle time 1 s.
!*/
Object P1s $Output 5
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "1s"
EndBody
EndObject
!/**
! Pulse train output with cycle time 500 ms.
!*/
Object P500ms $Output 6
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "500ms"
EndBody
EndObject
!/**
! Pulse train output with cycle time 200 ms.
!*/
Object P200ms $Output 7
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "200ms"
EndBody
EndObject
!/**
! Pulse train output with cycle time 100 ms.
!*/
Object P100ms $Output 8
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "100ms"
EndBody
EndObject
!/**
! Pulse train output with cycle time 50 ms.
!*/
Object P50ms $Output 9
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "50ms"
EndBody
EndObject
!/**
! Pulse train output with cycle time 20 ms.
!*/
Object P20ms $Output 10
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "20ms"
EndBody
EndObject
!/**
! Pulse train output with cycle time 10 ms.
!*/
Object P10ms $Output 11
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "10ms"
EndBody
EndObject
!/**
! Pulse train output with cycle time 5 ms.
!*/
Object P5ms $Output 12
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "5ms"
EndBody
EndObject
!/**
! Pulse train output with cycle time 2 ms.
!*/
Object P2ms $Output 13
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "2ms"
EndBody
EndObject
!/**
! Pulse train output with cycle time 1 ms.
!*/
Object P1ms $Output 14
Body SysBody
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "1ms"
EndBody
EndObject
EndObject
Object DevBody $ObjBodyDef 2
Object PlcNode $Buffer 1
Body SysBody
Attr Class = pwr_eClass_PlcNode
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
EndObject
Object GraphPlcNode $GraphPlcNode
Body SysBody
Attr object_type = 11
Attr parameters[0] = 0
Attr parameters[1] = 0
Attr parameters[2] = 14
Attr parameters[3] = 0
Attr subwindows = 0
Attr graphmethod = 0
Attr graphindex = 0
Attr default_mask[0] = 0
Attr default_mask[1] = 16
Attr segname_annotation = 1
Attr devbody_annotation = 0
Attr compmethod = 55
Attr compindex = 0
Attr tracemethod = 0
Attr traceindex = 0
Attr connectmethod = 0
Attr executeordermethod = 2
Attr objname = "PulseTrain"
Attr graphname = "PulseTrain"
EndBody
EndObject
Object Template PulseTrain
EndObject
EndObject
EndSObject
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2011 SSAB Oxelosund AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_true.wb_load -- Defines the class True.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group Plc,PlcLogic
! @Summary Function object with true output value..
! Function object with true output value.
! @image orm_true_fo.png
!*/
Object True $ClassDef 564
Body SysBody
Attr Editor = pwr_eEditor_PlcEd
Attr Method = pwr_eMethod_Connections
Attr PopEditor = 2
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "True"
EndBody
!/**
! True output.
!*/
Object Status $Output 1
Body SysBody
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_RTHIDE
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
EndObject
Object DevBody $ObjBodyDef 2
Object PlcNode $Buffer 1
Body SysBody
Attr Class = pwr_eClass_PlcNode
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
EndObject
Object GraphPlcNode $GraphPlcNode
Body SysBody
Attr object_type = 11
Attr parameters[0] = 0
Attr parameters[1] = 0
Attr parameters[2] = 1
Attr parameters[3] = 0
Attr subwindows = 0
Attr graphmethod = 4
Attr graphindex = 45
Attr default_mask[0] = 0
Attr default_mask[1] = 1
Attr segname_annotation = 0
Attr devbody_annotation = 0
Attr compmethod = 21
Attr compindex = 0
Attr tracemethod = 3
Attr traceindex = 1
Attr connectmethod = 0
Attr executeordermethod = 0
Attr objname = "True"
Attr graphname = "True"
Attr debugpar = "Status"
EndBody
EndObject
Object Template True
Body RtBody
Attr Status = 1
EndBody
EndObject
EndObject
EndSObject
...@@ -737,13 +737,16 @@ palette PlcEditorPalette ...@@ -737,13 +737,16 @@ palette PlcEditorPalette
class Count class Count
class DSup class DSup
class Edge class Edge
class False
class FirstScan class FirstScan
class Inv class Inv
class Or class Or
class Pulse class Pulse
class PulseTrain
class SR_R class SR_R
class SR_S class SR_S
class Timer class Timer
class True
class Wait class Wait
class Waith class Waith
class XOr class XOr
......
...@@ -76,7 +76,9 @@ typedef enum { ...@@ -76,7 +76,9 @@ typedef enum {
goen_eGraphIndex_GetATgeneric = 41, goen_eGraphIndex_GetATgeneric = 41,
goen_eGraphIndex_StoATgeneric = 42, goen_eGraphIndex_StoATgeneric = 42,
goen_eGraphIndex_GetDTgeneric = 43, goen_eGraphIndex_GetDTgeneric = 43,
goen_eGraphIndex_StoDTgeneric = 44 goen_eGraphIndex_StoDTgeneric = 44,
goen_eGraphIndex_True = 45,
goen_eGraphIndex_False = 46
} goen_eGraphIndex; } goen_eGraphIndex;
static float f_pinlength = GOEN_F_PINLENGTH; static float f_pinlength = GOEN_F_PINLENGTH;
...@@ -494,8 +496,20 @@ int goen_create_nodetype_m4( ...@@ -494,8 +496,20 @@ int goen_create_nodetype_m4(
break; break;
} }
case goen_eGraphIndex_FirstScan: case goen_eGraphIndex_FirstScan:
case goen_eGraphIndex_True:
case goen_eGraphIndex_False:
{ {
f_width = GOEN_F_GRID * 4; char text[80];
int w;
switch ( graph_index) {
case goen_eGraphIndex_FirstScan: w=4; strcpy( text, "FirstScan"); break;
case goen_eGraphIndex_True: w=2; strcpy( text, "True"); break;
case goen_eGraphIndex_False: w=2; strcpy( text, "False"); break;
default: ;
}
f_width = GOEN_F_GRID * w;
f_height = GOEN_F_GRID; f_height = GOEN_F_GRID;
flow_AddRect( nc, 0, -f_height/2, f_width, f_height, flow_AddRect( nc, 0, -f_height/2, f_width, f_height,
...@@ -503,7 +517,7 @@ int goen_create_nodetype_m4( ...@@ -503,7 +517,7 @@ int goen_create_nodetype_m4(
flow_AddLine( nc, f_width, 0, f_width + f_pinlength, 0, flow_eDrawType_Line, 2); flow_AddLine( nc, f_width, 0, f_width + f_pinlength, 0, flow_eDrawType_Line, 2);
flow_AddConPoint( nc, f_width + f_pinlength, 0, flow_AddConPoint( nc, f_width + f_pinlength, 0,
0, flow_eDirection_Right); 0, flow_eDirection_Right);
flow_AddText( nc, "FirstScan", f_strlength, 0.5 * f_strheight, flow_AddText( nc, text, f_strlength, 0.5 * f_strheight,
flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE); flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
break; break;
} }
......
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