BoxCarFilter.xml

Page auto-generated from XML file.

Failure

The mission description could not be extracted from the XML.

Below is the reason, as well as the source XML.

root element not handled: DefineBehavior
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?xml version="1.0" encoding="UTF-8"?>
<!--
-   Copyright (c) 2024 MBARI
-   MBARI Proprietary Information. Confidential. All Rights Reserved
-   Unauthorized copying or distribution of this file via any medium is strictly
-   prohibited.
-
-   WARNING - This file contains information whose export is restricted by the
-   Export Administration Act of 1979 (Title 50, U.S.C., App. 2401 et seq.), as
-   amended. Violations of these export laws are subject to severe civil and/or
-   criminal penalties.
-->

<DefineBehavior xmlns="Tethys"
       xmlns:Control="Tethys/Control"
       xmlns:BehaviorScripts="Tethys/BehaviorScripts" 
       xmlns:Units="Tethys/Units"
       xmlns:Universal="Tethys/Universal"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="Tethys http://okeanids.mbari.org/tethys/Xml/Tethys.xsd
                           Tethys/Control http://okeanids.mbari.org/tethys/Xml/Control.xsd
                           Tethys/BehaviorScripts ./BehaviorScripts.xsd
                           Tethys/Units http://okeanids.mbari.org/tethys/Xml/Units.xsd
                           Tethys/Universal http://okeanids.mbari.org/tethys/Xml/Universal.xsd"
       Name="BoxCarFilter" Language="Lua">

    <Description>
        Given an input value and an width value, provides a boxcar filter of the
        input values.
    </Description>

    <DefineSetting Name="inputSet">
        <BehaviorScripts:BoxCarFilter.input/>
        <Description>
            The value to be filtered
        </Description><Units:none/>
        <DefaultValue>NaN</DefaultValue>
    </DefineSetting>

    <DefineSetting Name="widthSet">
        <BehaviorScripts:BoxCarFilter.width/>
        <Description>
            Width (#samples) in the filter
        </Description><Units:count/>
        <DefaultValue>10</DefaultValue>
    </DefineSetting>

    <Construct>
        <Description>
            Define functions for use in the behavior
        </Description>
        <Script><![CDATA[
            function BoxCar( buf, n )
                local sum = 0
                for i=1,n do
                    if (buf[i] == nil) then return nil end
                    sum = sum + buf[i]
                end
                return sum / n
            end
            function AddValue( buf, value, pos, n )
                pos = pos + 1
                if( pos > n ) then pos = 1 end
                buf[pos]=value
                return pos
            end
            return "Constructed BoxCarFilter", "IMPORTANT"
        ]]></Script>
    </Construct>

    <Initialize>
        <Description>
            Initialize global variables
        </Description>
        <Script><![CDATA[
           buffer={}
           position = 0
        ]]></Script>
    </Initialize>

    <Run>
        <OutputArg><BehaviorScripts:BoxCarFilter.output/><Description>
            Result of the filtering operation. Not written until the buffer is
            full
        </Description><Units:none/></OutputArg>
        <Script><![CDATA[
           position = AddValue(buffer,inputSet,position,widthSet)
           local bc = BoxCar(buffer,widthSet)
           return bc
        ]]></Script>
    </Run>

</DefineBehavior>