Commit fd37d1b9 authored by Claes Sjofors's avatar Claes Sjofors

plc, function object TimeMean for calculation of cumulative mean added

parent c6b2f327
......@@ -420,6 +420,29 @@ void timint_exec(
object->ActVal += *object->InP * *object->ScanTime / object->TimFact;
}
/*_*
TIMEMEAN
Function: Cumulative mean value
@aref timemean TimeMean
*/
void timemean_exec(
plc_sThread *tp,
pwr_sClass_timemean *o)
{
if ( *o->ResetP && !o->Reset) {
/* Reset */
o->ActVal = o->AccMean;
o->AccTime = 0;
}
o->Reset = *o->ResetP;
/* Calculate new value */
o->AccMean = (*o->InP * *o->ScanTime + o->AccMean * o->AccTime) /
(*o->ScanTime + o->AccTime);
o->AccTime += *o->ScanTime;
}
/*_*
CURVE
Funktion: Interpollation in a table
......
......@@ -50,6 +50,7 @@ void filter_init( pwr_sClass_filter *object);
void filter_exec( plc_sThread *tp, pwr_sClass_filter *object);
void speed_exec( plc_sThread *tp, pwr_sClass_speed *object);
void timint_exec( plc_sThread *tp, pwr_sClass_timint *object);
void timemean_exec( plc_sThread *tp, pwr_sClass_timemean *o);
void curve_exec( plc_sThread *tp, pwr_sClass_curve *object);
void adelay_init( pwr_sClass_adelay *object);
void adelay_exec( plc_sThread *tp, pwr_sClass_adelay *object);
......
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2015 SSAB EMEA 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_timemean.wb_load -- Defines the class TimeMean.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Code rt_plc_arithm.c
! @Group Plc,PlcAnalog
! @Summary Time integrator
! Time integrator.
! @image orm_timint_fo.gif
!
! Calculate a cumulative mean value of a value over time.
! The mean value is calculated from last reset, and the mean
! value at last reset is stored in ActVal.
!*/
Object TimeMean $ClassDef 681
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Connections
Attr PopEditor = 2
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "timemean"
EndBody
!/**
! The input signal.
!*/
Object In $Input 1
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "IN"
EndBody
EndObject
!/**
! Store the current mean value and restart the calculation.
!*/
Object Reset $Input 2
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
Attr GraphName = "res"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_NOINVERT
EndBody
EndObject
!/**
! The value of the accumulated mean value at last reset.
!*/
Object ActVal $Output 3
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "VAL"
Attr Flags |= PWR_MASK_NOEDIT
EndBody
EndObject
!/**
! Cumulative mean value since last reset.
!
! AccMean(t) = (ActVal(t-1) * AccTime + In(t) * ScanTime) /
! ( AccTime + ScanTime)
!*/
Object AccMean $Intern 4
Body SysBody
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! The accumulated time since last reset.
!*/
Object AccTime $Intern 5
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "AccTime"
EndBody
EndObject
!/**
! Program cycle time in seconds.
!*/
Object ScanTime $Intern 6
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
Attr GraphName = "ScanTime"
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_POINTER
Attr Flags |= PWR_MASK_PRIVATE
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] = 2
Attr parameters[1] = 0
Attr parameters[2] = 1
Attr parameters[3] = 0
Attr subwindows = 0
Attr graphmethod = 0
Attr graphindex = 0
Attr default_mask[0] = 3
Attr default_mask[1] = 1
Attr segname_annotation = 1
Attr compmethod = 4
Attr compindex = 0
Attr tracemethod = 0
Attr traceindex = 0
Attr executeordermethod = 2
Attr objname = "TimeMean"
Attr graphname = "TimeMean"
Attr debugpar = ""
EndBody
EndObject
Object Template TimeMean
Body RtBody
EndBody
EndObject
EndObject
EndSObject
......@@ -768,6 +768,7 @@ palette PlcEditorPalette
class Sum
class Table
class Timint
class TimeMean
menu Math
{
class ACos
......
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