Doc : Counters family : use cases and recommended usage
I think it would be good to have a section in the doc that describes which counter type should be used in the different use cases.
for example:
SoftCounters: usage => "on the fly" (use a method of an existing obj of the session to count) usually not attached to a top controller, lives alone during session runtime
CalcCounter:
usage => introduce a new counter which performs a calculation based on other counters
works with 'real' counters already existing in the config (or session).
can be defined in the config.
usually not attached to a top controller, lives alone.
SamplingCounter: usage => associate a counter to something (a variable) that can be read by an HW device. 'fixed' counter with a CounterController attached to (or herited by) a top controller. defined in the implementation of the top controller. designed for instantaneous measurements.
Integrating: like SamplingCounters but designed for integrated measurements
With an implementation example for each kind.
class CyberstarCC(SamplingCounterController):
def __init__(self, name, cyberstar):
super().__init__(name)
self.cyberstar = cyberstar
def read_all(self, *counters):
values = []
for cnt in counters:
if cnt.name == "sca_low":
values.append(self.cyberstar.sca_low)
elif cnt.name == "sca_up":
values.append(self.cyberstar.sca_up)
return values
class Cyberstar:
def __init__(self, name, config):
...
self._cc = CyberstarCC( cc_name)
self._cc.create_counter(SamplingCounter, "sca_low", unit="V", mode="SINGLE")
self._cc.create_counter(SamplingCounter, "sca_up", unit="V", mode="SINGLE")
@autocomplete_property
def counters(self):
""" Standard counter namespace """
return self._cc.counters