Vuo  2.0.0
VuoRealRegulation.c
Go to the documentation of this file.
1 
10 #include "type.h"
11 #include "VuoRealRegulation.h"
12 
14 #ifdef VUO_COMPILER
16  "title" : "Real Regulation",
17  "description" : "Parameters describing how to regulate a real number.",
18  "keywords" : [ ],
19  "version" : "1.0.0",
20  "dependencies" : [
21  "VuoReal",
22  "VuoText"
23  ]
24  });
25 #endif
26 
42 {
43  return (VuoRealRegulation){
44  VuoJson_getObjectValue(VuoText, js, "name", NULL),
45  VuoJson_getObjectValue(VuoReal, js, "minimumValue", 0),
46  VuoJson_getObjectValue(VuoReal, js, "maximumValue", 0),
47  VuoJson_getObjectValue(VuoReal, js, "defaultValue", 0),
48  VuoJson_getObjectValue(VuoReal, js, "smoothDuration", 0)
49  };
50 }
51 
56 {
57  json_object *js = json_object_new_object();
58  json_object_object_add(js, "name", VuoText_getJson(value.name));
59  json_object_object_add(js, "minimumValue", VuoReal_getJson(value.minimumValue));
60  json_object_object_add(js, "maximumValue", VuoReal_getJson(value.maximumValue));
61  json_object_object_add(js, "defaultValue", VuoReal_getJson(value.defaultValue));
62  json_object_object_add(js, "smoothDuration", VuoReal_getJson(value.smoothDuration));
63  return js;
64 }
65 
70 {
71  return VuoText_format("Ensures %s is between %g and %g, with default %g and smooth duration %g", value.name, value.minimumValue, value.maximumValue, value.defaultValue, value.smoothDuration);
72 }
73 
77 VuoRealRegulation VuoRealRegulation_make(VuoText name, VuoReal minimumValue, VuoReal maximumValue, VuoReal defaultValue, VuoReal smoothDuration)
78 {
79  VuoRealRegulation value;
80 
81  value.name = name;
82 
83  // Allow the max and min to be in any order (so the user can specify an inverted mapping)…
84  value.minimumValue = minimumValue;
85  value.maximumValue = maximumValue;
86 
87  value.defaultValue = VuoReal_clamp(defaultValue, minimumValue, maximumValue);
88 
89  value.smoothDuration = smoothDuration;
90 
91  return value;
92 }