3 This file is part of the MSP Märklin suite
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
9 #include <msp/core/except.h>
10 #include "controller.h"
17 void Controller::Control::set(float v)
25 else if(type==DISCRETE)
26 value = min_value+floor((v-min_value)/step)*step;
27 else if(type==CONTINUOUS)
31 Controller::Control Controller::Control::binary(const string &n)
33 Controller::Control tc;
44 Controller::Control Controller::Control::discrete(const string &n, float m, float x, float s)
47 throw InvalidParameterValue("Max value must be greater than min value");
49 Controller::Control tc;
53 tc.max_value = m+floor((x-m)/s)*s;
60 Controller::Control Controller::Control::continuous(const string &n, float m, float x)
63 throw InvalidParameterValue("Max value must be greater than min value");
65 Controller::Control tc;
76 } // namespace Marklin