cartesian-add.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 /*
27 Part of Rack development has been done in the BALTRAD projects part-financed
28 by the European Union (European Regional Development Fund and European
29 Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31 
32 #pragma once
33 
34 #ifndef RACK_CART_ADD
35 #define RACK_CART_ADD
36 
37 
38 
39 //#include <drain/prog/CommandRegistry.h>
40 #include <drain/prog/CommandInstaller.h>
41 #include "resources.h"
42 
43 #include "composite.h"
44 
45 
46 namespace rack {
47 
48 
50 
56 class CompositeAdd : public Compositor { //drain::BasicCommand { // NEW 2017/06
57 
58 public:
59 
60  CompositeAdd() : Compositor(__FUNCTION__, "Adds the current product to the composite."){}; //, weight(1.0) {};
61 
62  virtual inline
63  void exec() const {
64  // Accept Cartesian and polar
65  RackContext & ctx = getContext<RackContext>();
66  drain::Logger mout(ctx.log, __FILE__, __FUNCTION__);
67 
68  Composite & composite = ctx.getComposite(RackContext::SHARED);
69 
70  mout.debug("starting add(), thread #", ctx.getName());
71 
72 
73  add(composite, RackContext::CURRENT, true);
74 
75  mout.debug("ended add(), thread #", ctx.getName());
76 
77  // composite.updateInputSelector(ctx.select);
78  // CHECK ctx.select.clear();
79  }
80 
81 
82 protected:
83 
84  //double applyTimeDecay(double w, const ODIM & odim) const;
85 
86 };
87 
88 
89 
90 
95 
96 public:
97 
98  CompositeAddWeighted() : Compositor(__FUNCTION__, "Adds the current product to the composite applying weight.") {
99  getParameters().link("weight", this->weight = weight, "0...1");
100  };
101 
103  //getParameters().link("weight", this->weight = weight, "0...1");
104  getParameters().copyStruct(cmd.getParameters(), cmd, *this, drain::ReferenceMap::LINK);
105  }
106 
107  virtual inline
108  void exec() const {
109 
110  RackContext & ctx = getContext<RackContext>();
111  drain::Logger mout(ctx.log, __FILE__, __FUNCTION__);
112 
113  Composite & composite = ctx.getComposite(RackContext::SHARED);
114  add(composite, RackContext::CURRENT, true);
115  // RackContext & ctx = getContext<RackContext>();
116  // Composite & composite = getComposite();
117  //add(composite, RackContext::CURRENT);
118  // composite.updateInputSelector(ctx.select);
119  // CHECK ctx.select.clear();
120  }
121 };
122 
123 
124 
125 } // rack::
126 
127 
128 
129 #endif
130 
131 // Rack
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition: Log.h:308
Logger & debug(const TT &... args)
Public, yet typically used "internally", when TIMING=true.
Definition: Log.h:676
void copyStruct(const ReferenceMap &m, const T &src, T &dst, extLinkPolicy policy=RESERVE)
Experimental. Copies references and values of a structure to another.
Definition: ReferenceMap.h:399
@ LINK
Definition: ReferenceMap.h:384
Definition: cartesian-add.h:94
virtual void exec() const
Run the command with current parameter values.
Definition: cartesian-add.h:108
Creates a single-radar Cartesian data set (2D data of both quantity and quality).
Definition: cartesian-add.h:56
virtual void exec() const
Run the command with current parameter values.
Definition: cartesian-add.h:63
Cartesian composite (mosaic) of data from several radars.
Definition: Composite.h:105
Definition: composite.h:58
void add(Composite &composite, drain::Flags::ivalue_t inputFilter, bool updateSelector=true) const
Definition: composite.cpp:112
Resources provided separately for each thread.
Definition: resources.h:67
Composite & getComposite(h5_role::ivalue_t filter)
Definition: resources.cpp:139
Definition: DataSelector.cpp:44