This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

How to shift buffers?
#4
Seems like you answered most of the questions yourself Smile

The visual editor does some half-hearted validation. But it can only use modules that are known to it and it will generate the entire XML file from scratch, so there is no way to use it with new modules.

requireFill is only designed to observe a single buffer and it is indeed an attribute to the analysis tag. Since it controls if the analysis modules are executed at all, there is no workaround to observe multiple buffers at the moment.

Here is an example of how I use the split module to calculate a moving average of 100 values. The split module keeps enough values (99) around for the next iteration, so the moving average has enough historic values to continue with the next new value. Note, that this is somewhat specific to the moving average module as it has the option to only output results when it has consumed enough values. Also note, that if you would try this example, the results on Android would be wrong as I made a mistake when implementing the movingaverage. It will be fixed in the next release.

Code:
<phyphox version="1.18" locale="en">
    <title>Moving average demo</title>
    <category>Test</category>
    <description>Demo for the new movingaverage and split analysis modules.</description>
    <data-containers>
        <container size="0">accT</container>
        <container size="0">accNew</container>
        <container size="0">accTodo</container>
        <container size="0">accRaw</container>
        <container size="0">accAvg</container>
    </data-containers>
    <input>
        <sensor type="accelerometer">
            <output component="t">accT</output>
            <output component="z">accNew</output>
        </sensor>
    </input>
    <views>
        <view label="Graph">
            <graph label="z Raw" timeOnX="true" labelX="[[quantity_short_time]]" unitX="[[unit_short_second]]" labelY="[[quantity_short_acceleration]]" unitY="[[unit_short_meter_per_square_second]]" unitYperX="m/s³" partialUpdate="true" color="red">
                <input axis="x">accT</input>
                <input axis="y">accRaw</input>
            </graph>
            <graph label="z Moving Average" timeOnX="true" labelX="[[quantity_short_time]]" unitX="[[unit_short_second]]" labelY="[[quantity_short_acceleration]]" unitY="[[unit_short_meter_per_square_second]]" unitYperX="m/s³" partialUpdate="true" color="green">
                <input axis="x">accT</input>
                <input axis="y">accAvg</input>
            </graph>
        </view>
    </views>
    <analysis requireFill="accNew" requireFillThreshold="100">

        <split>
            <input as="data">accNew</input>
            <input as="overlap" type="value">99</input>
            <output>accTodo</output>
            <output>accNew</output>
        </split>

        <subrange>
            <input keep="true">accTodo</input>
            <input as="from" type="value">99</input>
            <output append="true">accRaw</output>
        </subrange>

        <movingaverage dropIncomplete="true">
            <input as="data">accTodo</input>
            <input as="width" type="value">100</input>
            <output append="true">accAvg</output>
        </movingaverage>

    </analysis>
</phyphox>

If I ever come across a time machine I will rewrite phyphox with Python support instead of its own exotic XML-based language Smile
Reply


Messages In This Thread
How to shift buffers? - by Trikes - 06-24-2024, 09:14 AM
RE: How to shift buffers? - by Sebastian Staacks - 06-24-2024, 09:47 AM
RE: How to shift buffers? - by Trikes - 06-25-2024, 07:59 AM
RE: How to shift buffers? - by Sebastian Staacks - 06-25-2024, 09:16 AM
RE: How to shift buffers? - by Trikes - 06-27-2024, 08:54 AM
RE: How to shift buffers? - by Jens Noriʇzsɔɥ - 06-27-2024, 10:10 AM
RE: How to shift buffers? - by Sebastian Staacks - 06-28-2024, 12:53 PM
RE: How to shift buffers? - by Trikes - 06-29-2024, 09:28 AM
RE: How to shift buffers? - by Jens Noriʇzsɔɥ - 06-29-2024, 02:41 PM
RE: How to shift buffers? - by Trikes - 06-29-2024, 07:40 PM
RE: How to shift buffers? - by Sebastian Staacks - 06-30-2024, 02:55 PM
RE: How to shift buffers? - by Jens Noriʇzsɔɥ - 06-30-2024, 04:25 PM

Forum Jump: