-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protocol/c-bus): Initial commit.
- Loading branch information
Showing
5 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.plc4x</groupId> | ||
<artifactId>plc4x-protocols</artifactId> | ||
<version>0.10.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>plc4x-protocols-c-bus</artifactId> | ||
|
||
<name>Protocols: C-Bus</name> | ||
<description>Base protocol specifications for the C-Bus protocol</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.plc4x</groupId> | ||
<artifactId>plc4x-code-generation-protocol-base-mspec</artifactId> | ||
<version>0.10.0-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
44 changes: 44 additions & 0 deletions
44
protocols/c-bus/src/main/java/org/apache/plc4x/protocol/cbus/CBusProtocol.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.plc4x.protocol.cbus; | ||
|
||
import org.apache.plc4x.plugins.codegenerator.language.mspec.parser.MessageFormatParser; | ||
import org.apache.plc4x.plugins.codegenerator.protocol.Protocol; | ||
import org.apache.plc4x.plugins.codegenerator.protocol.TypeContext; | ||
import org.apache.plc4x.plugins.codegenerator.types.exceptions.GenerationException; | ||
|
||
import java.io.InputStream; | ||
|
||
public class CBusProtocol implements Protocol { | ||
|
||
@Override | ||
public String getName() { | ||
return "c-bus"; | ||
} | ||
|
||
@Override | ||
public TypeContext getTypeContext() throws GenerationException { | ||
InputStream schemaInputStream = CBusProtocol.class.getResourceAsStream("/protocols/cbus/c-bus.mspec"); | ||
if(schemaInputStream == null) { | ||
throw new GenerationException("Error loading message-format schema for protocol '" + getName() + "'"); | ||
} | ||
return new MessageFormatParser().parse(schemaInputStream); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.protocol.Protocol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
org.apache.plc4x.protocol.cbus.CBusProtocol |
80 changes: 80 additions & 0 deletions
80
protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
[discriminatedType CBusCommand | ||
[const uint 8 initiator '0x5C'] // 0x5C = "/" | ||
[simple CBusHeader header ] | ||
[typeSwitch 'header.destinationAddressType' | ||
['PointToPointToMultiPoint' CBusCommandPointToPointToMultiPoint | ||
[simple CBusPointToPointToMultipointCommand command] | ||
] | ||
['PointToMultiPoint' CBusCommandPointToMultiPoint | ||
[simple CBusPointToMultiPointCommand command] | ||
] | ||
['PointToPoint' CBusCommandPointToPoint | ||
[simple CBusPointToPointCommand command] | ||
] | ||
] | ||
] | ||
|
||
[type CBusHeader | ||
[simple PriorityClass priorityClass ] | ||
[reserved bit 'false' ] // Reserved for internal C-Bus management purposes | ||
[reserved uint 2 '0' ] // Reserved for internal C-Bus management purposes | ||
[simple DestinationAddressType destinationAddressType] | ||
] | ||
|
||
[discriminatedType CBusPointToPointCommand | ||
[peek uint 16 bridgeAddressCountPeek] | ||
[virtual UnitAddress unitAddress ] | ||
[typeSwitch 'bridgeAddressCountPeek && 0x00FF' | ||
['0x0000' CBusPointToPointCommandDirect | ||
[simple UnitAddress unitAddress ] | ||
] | ||
[ CBusPointToPointCommandIndirect | ||
[simple BridgeAddress firstBridgeAddress ] | ||
[simple RouteType routeType ] | ||
[array BridgeAddress additionalBridgeAddresses count 'routeType.additionalBridges'] | ||
[simple UnitAddress unitAddress ] | ||
] | ||
] | ||
|
||
] | ||
|
||
[enum uint 2 PriorityClass | ||
['0x00' Class4] // lowest | ||
['0x01' Class3] // medium low | ||
['0x02' Class2] // medium high | ||
['0x03' Class1] // highest | ||
] | ||
|
||
[enum uint 3 DestinationAddressType | ||
['0x03' PointToPointToMultiPoint] // P-P-M | ||
['0x05' PointToMultiPoint ] // P-M | ||
['0x06' PointToPoint ] // P-P | ||
] | ||
|
||
[enum uint 8 RouteType(uint 3 additionalBridges) | ||
['0x00' NoBridgeAtAll ['0']] | ||
['0x09' NoAdditionalBridge ['1']] | ||
['0x12' OneAdditionalBridge ['2']] | ||
['0x1B' TwoAdditionalBridge ['3']] | ||
['0x24' ThreeAdditionalBridge ['4']] | ||
['0x2D' FourAdditionalBridge ['4']] | ||
['0x36' FiveAdditionalBridge ['4']] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters