Skip to content
Snippets Groups Projects
Commit 4937e1c8 authored by Manuel Krombholz's avatar Manuel Krombholz
Browse files

Finished FrquencySetting and added parsing to test

parent 438f3df1
No related branches found
No related tags found
1 merge request!19dev to master
Pipeline #10036 passed
......@@ -122,5 +122,4 @@ aspect Navigation {
eq Root.getRule().getRoot() = this;
eq Root.getUser().getRoot() = this;
eq Root.getLocation().getRoot() = this;
eq Root.getFrequencySetting().getRoot() = this;
}
......@@ -41,6 +41,9 @@ aspect Printing {
for (Channel c : channels()) {
sb.append(c.prettyPrint());
}
for (FrequencySetting fs : getFrequencySettingList()) {
sb.append(fs.prettyPrint());
}
return sb.toString();
}
......@@ -181,6 +184,14 @@ aspect Printing {
.build();
}
// FrequencySetting: id="" procFrec="";
eq FrequencySetting.prettyPrint() {
return new MemberPrinter("FrequencySetting")
.addNonDefault("id", getID())
.addNonDefault("procFreq", String.valueOf(getEventProcessingFrequency()))
.build();
}
// ExternalHost: "hostName:port"
syn String ExternalHost.prettyPrint() {
if (getHostName().contains(":")) {
......
......@@ -116,7 +116,7 @@ aspect Resolving {
return java.util.Optional.empty();
}
syn java.util.Optional<FrequencySetting> Root.resolveFrequencySetting(String performanceId) {
syn java.util.Optional<FrequencySetting> SmartHomeEntityModel.resolveFrequencySetting(String performanceId) {
for (FrequencySetting performance : getFrequencySettingList()) {
if (performance.getLabel().equals(performanceId)) {
return java.util.Optional.of(performance);
......@@ -133,7 +133,7 @@ aspect Resolving {
// _._ -> FrequencySetting
refine RefResolverStubs eq ASTNode.globallyResolveFrequencySettingByToken(String id) {
return getRoot().resolveFrequencySetting(id).orElseThrow(() -> new RuntimeException("FrequencySetting '" + id + "' not found!"));
return getRoot().getSmartHomeEntityModel().resolveFrequencySetting(id).orElseThrow(() -> new RuntimeException("FrequencySetting '" + id + "' not found!"));
}
// Thing.Channel* -> Channel
......
......@@ -127,7 +127,7 @@ Root root =
| influx_root.ir root.r {: r.setInfluxRoot(ir); return r; :}
| machine_learning_root.ml root.r {: r.setMachineLearningRoot(ml); return r; :}
| rule.rule root.r {: r.addRule(rule); return r; :}
| frequency_setting.ip root.r {: r.addFrequencySetting(ip); return r; :}
| frequency_setting.ip root.r {: insertZero(r.getSmartHomeEntityModel().getFrequencySettingList(), ip); return r; :}
| {: return Root.createEmptyRoot(); :}
;
......
// ---------------- Main ------------------------------
Root ::= SmartHomeEntityModel User* MqttRoot InfluxRoot MachineLearningRoot Rule* Location* FrequencySetting*;
Root ::= SmartHomeEntityModel User* MqttRoot InfluxRoot MachineLearningRoot Rule* Location* ;
// ---------------- Users ------------------------------
User : LabelledModelElement ;
......
// ---------------- openHAB ------------------------------
SmartHomeEntityModel ::= Thing* Group* ThingType* Parameter* ChannelType* Channel* ItemCategory* /ActivityItem:Item/ ;
SmartHomeEntityModel ::= Thing* Group* ThingType* Parameter* ChannelType* Channel* ItemCategory* /ActivityItem:Item/ FrequencySetting*;
abstract ModelElement ::= <ID:String> ;
......
......@@ -453,9 +453,9 @@ class EraserParserHelper {
return result;
}
public Root createRoot(FrequencySetting FrequencySetting) {
public Root createRoot(FrequencySetting frequencySetting) {
Root result = createRoot();
result.addFrequencySetting(FrequencySetting);
result.getSmartHomeEntityModel().addFrequencySetting(frequencySetting);
return result;
}
......
......@@ -922,9 +922,9 @@ public class RulesTest {
TestUtils.ModelAndItem mai = createModelAndItem(0);
NumberItem numberItem = mai.item;
FrequencySetting itemPerformance = new FrequencySetting();
itemPerformance.setEventProcessingFrequency(10);
numberItem.setFrequencySetting(itemPerformance);
FrequencySetting frequencySetting = new FrequencySetting();
frequencySetting.setEventProcessingFrequency(10);
numberItem.setFrequencySetting(frequencySetting);
Rule rule = new Rule();
CountingAction counter = new CountingAction();
......
......@@ -4,4 +4,5 @@ Group: id="my-group" items=["iris1_item"] ;
ThingType: id="skywriter-hat" label="SkyWriterHAT" description="SkyWriterHAT Gesture Recognition" parameters=["brokername"] channelTypes=["flick-type"] ;
ChannelType: id="flick-type" itemType="String" label="Last Flick" description="Last Flick detected (and its direction)" category="Motion" readOnly ;
Parameter: id="brokername" type="text" required label="Broker Name" description="Name of the broker as defined in the &lt;broker&gt;.url in services/mqtt.cfg. See the MQTT Binding for more information on how to configure MQTT broker connections." context="service" default="mosquitto" ;
FrequencySetting: id="ip1" procFreq="10.0";
Influx: host="localhost" ;
......@@ -3,5 +3,6 @@ Group: id="my-group" items=["iris1_item"] ;
ThingType: id="skywriter-hat" label="SkyWriterHAT" description="SkyWriterHAT Gesture Recognition" parameters=["brokername"] channelTypes=["flick-type"] ;
ChannelType: id="flick-type" label="Last Flick" description="Last Flick detected (and its direction)" itemType="String" category="Motion" readOnly ;
Parameter: id="brokername" label="Broker Name" description="Name of the broker as defined in the &lt;broker&gt;.url in services/mqtt.cfg. See the MQTT Binding for more information on how to configure MQTT broker connections." type="Text" context="service" default="mosquitto" required ;
FrequencySetting: id="ip1" procFreq="10.0" ;
Mqtt: incoming="ppc2/" outgoing="oh2/in/" host="localhost" ;
Influx: host="localhost" ;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment