Try this version <https://raw.githubusercontent.com/weewx/weewx/master/bin/weewx/drivers/simulator.py> of the simulator. It should be a little easier to subclass.
On Tue, Aug 11, 2020 at 7:35 AM Tom Keffer <[email protected]> wrote: > Why not just subclass class Simulator? In the __init__ function of your > new class, call the superclass's initializer, then add additional types to > self.observations. > > You would also have to provide your own loader() function, which would > largely replicate the logic in the existing loader(). > > But, I take your point: class Simulator could be structured to make it > easier to subclass and provide specialized simulators. > > -tk > > > On Tue, Aug 11, 2020 at 6:43 AM Graham Eddy <[email protected]> wrote: > >> enhancement request to be able to add new value generators to >> weewx.drivers.Simulator from user.extensions (rather than edit a private >> copy) >> >> easiest way i see is to just move self.observations to class attribute >> and let folk extend the list. this would be facilitated by an abstract >> class for Observation, Rain, Solar, BatteryStatus, BatteryVoltage, >> SignalStrength of form >> >> class AbstractObservation(object): >> def value_at(self, time_ts): >> raise NotImplementedError >> >> for developers to subclass their own value generators. mind you, the >> existing ones are pretty flexible - i used BatteryStatus as stimulus for >> lightning_strike_count. >> otherwise, to avoid class attribute, could add method like >> add_observation_type(obs_type, value_generator) >> >> -- >> You received this message because you are subscribed to the Google Groups >> "weewx-user" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/weewx-user/A9B73A87-8EC7-4B37-8458-5FDA979FC4CF%40gmail.com >> <https://groups.google.com/d/msgid/weewx-user/A9B73A87-8EC7-4B37-8458-5FDA979FC4CF%40gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zEA_iY4_noqo5v0mnV_mFnB5%2BPHbDK21h%2B8pTrLjK1dRoA%40mail.gmail.com.
