Build a new module: mywindturbine

Hi everybody,
I’m a french guy and my english is no perfect.

I’m just coming to register in the new forum.
I’m working to build a module to monitor a wind turbine. I want to see the instantaneous wind direction, wind speed and power product by the wind turbine and I want to see the wind distribution, the wind frequency distribution and the power product on a last period.
I was start this work last years but now it’s to old, this the old post : old post

I have found the module tutorial but, nothing on how to create a module_processlist.
In first, I need to add two process and I put that in a mywindturbine_processlist.php.
So I have copy the eventp_processlist.php and try to add my code.
I’m not a php programmer but I’m trying to understand.
So I start by the first process, to convert the wind direction in degree to a column to put it in a wind rose. I use the ProcessArg::VALUE to define the number of columns (like 8, 16 or 32).

That work, but not fine, because I don’t now how to get the feedid to insert the data. Probably and because I use a copy/paste learning strategy, I have no feed information.

edit: I use emoncms 9.7.2 on a linux shared server (ovh)

Can you help me?

I join you my mywindturbine_processlist.php :

        // mywindturbine Processlist Module
        class mywindturbine_ProcessList
        {
            private $log;
            private $parentProcessModel;
            private $feed;

        // Module required constructor, receives parent as reference
        public function __construct(&$parent)
        {
            $this->log = new EmonLogger(__FILE__);
            $this->parentProcessModel = &$parent;
               $this->feed = &$parent->feed;
        }

        // Module required process configuration, $list array index position is not used, function name is used instead
        public function process_list()
        {
            // 0=>Name | 1=>Arg type | 2=>function | 3=>No. of datafields if creating feed | 4=>Datatype | 5=>Group | 6=>Engines | 'desc'=>Description | 'requireredis'=>true/false
            $list[] = array(_("degree in column"),ProcessArg::VALUE,"degree_to_column",0,DataType::REALTIME,"My wind turbine",array(Engine::PHPFIWA), 'desc'=>"Convert a degree input to the right column. In value, put the number of column : 8, 16 or 32.");
        
            return $list;
        }

        // \/ Below are functions of this module processlist, same name must exist on process_list()
        
        public function degree_to_column($arg, $time, $value, $id)
        {
        $value = floor(($value + (360/(2*$arg)))/(360/$arg));
        if ($value ==$arg) $value =0;
        
        $this->feed->insert_data($id, $time, $time, $value);
            return $value;
        }

    }

Cheers,

Hi,
I’ve fine the solution, in remove the insert_data request, and use a log to feed in addition. So like that pipe the result from degree_to_column in a new feed.
That is a good practice or can I do that directly?

I’ve added the frequency to column process, to draw the frequency distribution.

But my question is, can I create a process with feed and value parameters?

I joins you my update mywindturbine_processlist.php

cheers,
mywindturbine_processlist.txt (3.0 KB)