WIP / Refactored Switch Software
This commit is contained in:
13
OpenHab/org.openhab.binding.meycan/.vscode/launch.json
vendored
Normal file
13
OpenHab/org.openhab.binding.meycan/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Attach) - openHAB",
|
||||||
|
"request": "attach",
|
||||||
|
"hostName": "localhost",
|
||||||
|
"port": 5005,
|
||||||
|
"preLaunchTask": "Build"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
149
OpenHab/org.openhab.binding.meycan/.vscode/tasks.json
vendored
Normal file
149
OpenHab/org.openhab.binding.meycan/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"openhab_home": "C://source//openhab_runtime",
|
||||||
|
"openhab_runtime": "C://source//openhab_runtime//runtime",
|
||||||
|
"openhab_addons": "C://source//openhab_runtime//addons",
|
||||||
|
"openhab_logs": "C://source//openhab_runtime//userdata/logs",
|
||||||
|
"dist" : "org.openhab.binding.meycan-4.0.0-SNAPSHOT.jar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Start openHAB (Debug)",
|
||||||
|
"type": "shell",
|
||||||
|
"isBackground": true,
|
||||||
|
"command": "$openhab_home/start.sh debug",
|
||||||
|
"windows": {
|
||||||
|
"command": "& $env:openhab_home/start.bat debug"
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "always",
|
||||||
|
"panel": "new"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Stop openHAB",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "$openhab_runtime/bin/stop",
|
||||||
|
"windows": {
|
||||||
|
"command": "& $env:openhab_runtime/bin/stop.bat"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "mvn Compile (Release)",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "mvn",
|
||||||
|
"args": [
|
||||||
|
"clean",
|
||||||
|
"install"
|
||||||
|
],
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "mvn Compile (Online)",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "mvn",
|
||||||
|
"args": [
|
||||||
|
"clean",
|
||||||
|
"install",
|
||||||
|
"-DskipChecks"
|
||||||
|
],
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "mvn Compile (Offline)",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "mvn",
|
||||||
|
"args": [
|
||||||
|
"-o",
|
||||||
|
"clean",
|
||||||
|
"install",
|
||||||
|
"-DskipChecks"
|
||||||
|
],
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Copy Distribution to Addons",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "cp",
|
||||||
|
"args": [
|
||||||
|
"${workspaceFolder}/target/$dist",
|
||||||
|
"$openhab_addons"
|
||||||
|
],
|
||||||
|
"windows": {
|
||||||
|
"command": "copy",
|
||||||
|
"args": [
|
||||||
|
"${workspaceFolder}/target/$env:dist",
|
||||||
|
"$env:openhab_addons"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dependsOn": [
|
||||||
|
"mvn Compile (Offline)"
|
||||||
|
],
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Build",
|
||||||
|
"dependsOn": [
|
||||||
|
"Copy Distribution to Addons"
|
||||||
|
],
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Tail events.log",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "tail",
|
||||||
|
"args": [
|
||||||
|
"-n",
|
||||||
|
"50",
|
||||||
|
"-F",
|
||||||
|
"$openhab_logs/events.log"
|
||||||
|
],
|
||||||
|
"windows": {
|
||||||
|
"command": "Get-Content",
|
||||||
|
"args": [
|
||||||
|
"-Last",
|
||||||
|
"50",
|
||||||
|
"-Path",
|
||||||
|
"$env:openhab_logs/events.log",
|
||||||
|
"-Wait"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "always",
|
||||||
|
"panel": "new"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Tail openhab.log",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "tail",
|
||||||
|
"args": [
|
||||||
|
"-n",
|
||||||
|
"50",
|
||||||
|
"-F",
|
||||||
|
"$openhab_logs/openhab.log"
|
||||||
|
],
|
||||||
|
"windows": {
|
||||||
|
"command": "Get-Content",
|
||||||
|
"args": [
|
||||||
|
"-Last",
|
||||||
|
"50",
|
||||||
|
"-Path",
|
||||||
|
"$env:openhab_logs/openhab.log",
|
||||||
|
"-Wait"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "always",
|
||||||
|
"panel": "new"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
13
OpenHab/org.openhab.binding.meycan/NOTICE
Normal file
13
OpenHab/org.openhab.binding.meycan/NOTICE
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
This content is produced and maintained by the openHAB project.
|
||||||
|
|
||||||
|
* Project home: https://www.openhab.org
|
||||||
|
|
||||||
|
== Declared Project Licenses
|
||||||
|
|
||||||
|
This program and the accompanying materials are made available under the terms
|
||||||
|
of the Eclipse Public License 2.0 which is available at
|
||||||
|
https://www.eclipse.org/legal/epl-2.0/.
|
||||||
|
|
||||||
|
== Source Code
|
||||||
|
|
||||||
|
https://github.com/openhab/openhab-addons
|
||||||
94
OpenHab/org.openhab.binding.meycan/README.md
Normal file
94
OpenHab/org.openhab.binding.meycan/README.md
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# MeyCan Binding
|
||||||
|
|
||||||
|
_Give some details about what this binding is meant for - a protocol, system, specific device._
|
||||||
|
|
||||||
|
_If possible, provide some resources like pictures (only PNG is supported currently), a video, etc. to give an impression of what can be done with this binding._
|
||||||
|
_You can place such resources into a `doc` folder next to this README.md._
|
||||||
|
|
||||||
|
_Put each sentence in a separate line to improve readability of diffs._
|
||||||
|
|
||||||
|
## Supported Things
|
||||||
|
|
||||||
|
_Please describe the different supported things / devices including their ThingTypeUID within this section._
|
||||||
|
_Which different types are supported, which models were tested etc.?_
|
||||||
|
_Note that it is planned to generate some part of this based on the XML files within ```src/main/resources/OH-INF/thing``` of your binding._
|
||||||
|
|
||||||
|
- `bridge`: Short description of the Bridge, if any
|
||||||
|
- `sample`: Short description of the Thing with the ThingTypeUID `sample`
|
||||||
|
|
||||||
|
## Discovery
|
||||||
|
|
||||||
|
_Describe the available auto-discovery features here._
|
||||||
|
_Mention for what it works and what needs to be kept in mind when using it._
|
||||||
|
|
||||||
|
## Binding Configuration
|
||||||
|
|
||||||
|
_If your binding requires or supports general configuration settings, please create a folder ```cfg``` and place the configuration file ```<bindingId>.cfg``` inside it._
|
||||||
|
_In this section, you should link to this file and provide some information about the options._
|
||||||
|
_The file could e.g. look like:_
|
||||||
|
|
||||||
|
```
|
||||||
|
# Configuration for the MeyCan Binding
|
||||||
|
#
|
||||||
|
# Default secret key for the pairing of the MeyCan Thing.
|
||||||
|
# It has to be between 10-40 (alphanumeric) characters.
|
||||||
|
# This may be changed by the user for security reasons.
|
||||||
|
secret=openHABSecret
|
||||||
|
```
|
||||||
|
|
||||||
|
_Note that it is planned to generate some part of this based on the information that is available within ```src/main/resources/OH-INF/binding``` of your binding._
|
||||||
|
|
||||||
|
_If your binding does not offer any generic configurations, you can remove this section completely._
|
||||||
|
|
||||||
|
## Thing Configuration
|
||||||
|
|
||||||
|
_Describe what is needed to manually configure a thing, either through the UI or via a thing-file._
|
||||||
|
_This should be mainly about its mandatory and optional configuration parameters._
|
||||||
|
|
||||||
|
_Note that it is planned to generate some part of this based on the XML files within ```src/main/resources/OH-INF/thing``` of your binding._
|
||||||
|
|
||||||
|
### `sample` Thing Configuration
|
||||||
|
|
||||||
|
| Name | Type | Description | Default | Required | Advanced |
|
||||||
|
|-----------------|---------|---------------------------------------|---------|----------|----------|
|
||||||
|
| hostname | text | Hostname or IP address of the device | N/A | yes | no |
|
||||||
|
| password | text | Password to access the device | N/A | yes | no |
|
||||||
|
| refreshInterval | integer | Interval the device is polled in sec. | 600 | no | yes |
|
||||||
|
|
||||||
|
## Channels
|
||||||
|
|
||||||
|
_Here you should provide information about available channel types, what their meaning is and how they can be used._
|
||||||
|
|
||||||
|
_Note that it is planned to generate some part of this based on the XML files within ```src/main/resources/OH-INF/thing``` of your binding._
|
||||||
|
|
||||||
|
| Channel | Type | Read/Write | Description |
|
||||||
|
|---------|--------|------------|-----------------------------|
|
||||||
|
| control | Switch | RW | This is the control channel |
|
||||||
|
|
||||||
|
## Full Example
|
||||||
|
|
||||||
|
_Provide a full usage example based on textual configuration files._
|
||||||
|
_*.things, *.items examples are mandatory as textual configuration is well used by many users._
|
||||||
|
_*.sitemap examples are optional._
|
||||||
|
|
||||||
|
### Thing Configuration
|
||||||
|
|
||||||
|
```java
|
||||||
|
Example thing configuration goes here.
|
||||||
|
```
|
||||||
|
### Item Configuration
|
||||||
|
|
||||||
|
```java
|
||||||
|
Example item configuration goes here.
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sitemap Configuration
|
||||||
|
|
||||||
|
```perl
|
||||||
|
Optional Sitemap configuration goes here.
|
||||||
|
Remove this section, if not needed.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Any custom content here!
|
||||||
|
|
||||||
|
_Feel free to add additional sections for whatever you think should also be mentioned about your binding!_
|
||||||
17
OpenHab/org.openhab.binding.meycan/pom.xml
Normal file
17
OpenHab/org.openhab.binding.meycan/pom.xml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.openhab.addons.bundles</groupId>
|
||||||
|
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
|
||||||
|
<version>4.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>org.openhab.binding.meycan</artifactId>
|
||||||
|
|
||||||
|
<name>openHAB Add-ons :: Bundles :: MeyCan Binding</name>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<features name="org.openhab.binding.meycan-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
|
||||||
|
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>
|
||||||
|
|
||||||
|
<feature name="openhab-binding-meycan" description="MeyCan Binding" version="${project.version}">
|
||||||
|
<feature>openhab-runtime-base</feature>
|
||||||
|
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.meycan/${project.version}</bundle>
|
||||||
|
</feature>
|
||||||
|
</features>
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2023 Contributors to the openHAB project
|
||||||
|
*
|
||||||
|
* See the NOTICE file(s) distributed with this work for additional
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
|
*/
|
||||||
|
package org.openhab.binding.meycan.internal;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.openhab.core.thing.ThingTypeUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link MeyCanBindingConstants} class defines common constants, which are
|
||||||
|
* used across the whole binding.
|
||||||
|
*
|
||||||
|
* @author Martin Linkwitz - Initial contribution
|
||||||
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
|
public class MeyCanBindingConstants {
|
||||||
|
|
||||||
|
private static final String BINDING_ID = "meycan";
|
||||||
|
|
||||||
|
// List of all Thing Type UIDs
|
||||||
|
public static final ThingTypeUID THING_TYPE_SAMPLE = new ThingTypeUID(BINDING_ID, "sample");
|
||||||
|
|
||||||
|
// List of all Channel ids
|
||||||
|
public static final String CHANNEL_1 = "channel1";
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2023 Contributors to the openHAB project
|
||||||
|
*
|
||||||
|
* See the NOTICE file(s) distributed with this work for additional
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
|
*/
|
||||||
|
package org.openhab.binding.meycan.internal;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link MeyCanConfiguration} class contains fields mapping thing configuration parameters.
|
||||||
|
*
|
||||||
|
* @author Martin Linkwitz - Initial contribution
|
||||||
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
|
public class MeyCanConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sample configuration parameters. Replace with your own.
|
||||||
|
*/
|
||||||
|
public String hostname = "";
|
||||||
|
public String password = "";
|
||||||
|
public int refreshInterval = 600;
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2023 Contributors to the openHAB project
|
||||||
|
*
|
||||||
|
* See the NOTICE file(s) distributed with this work for additional
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
|
*/
|
||||||
|
package org.openhab.binding.meycan.internal;
|
||||||
|
|
||||||
|
import static org.openhab.binding.meycan.internal.MeyCanBindingConstants.*;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
import org.openhab.core.thing.ChannelUID;
|
||||||
|
import org.openhab.core.thing.Thing;
|
||||||
|
import org.openhab.core.thing.ThingStatus;
|
||||||
|
import org.openhab.core.thing.binding.BaseThingHandler;
|
||||||
|
import org.openhab.core.types.Command;
|
||||||
|
import org.openhab.core.types.RefreshType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link MeyCanHandler} is responsible for handling commands, which are
|
||||||
|
* sent to one of the channels.
|
||||||
|
*
|
||||||
|
* @author Martin Linkwitz - Initial contribution
|
||||||
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
|
public class MeyCanHandler extends BaseThingHandler {
|
||||||
|
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(MeyCanHandler.class);
|
||||||
|
|
||||||
|
private @Nullable MeyCanConfiguration config;
|
||||||
|
|
||||||
|
public MeyCanHandler(Thing thing) {
|
||||||
|
super(thing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||||
|
if (CHANNEL_1.equals(channelUID.getId())) {
|
||||||
|
if (command instanceof RefreshType) {
|
||||||
|
// TODO: handle data refresh
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: handle command
|
||||||
|
|
||||||
|
// Note: if communication with thing fails for some reason,
|
||||||
|
// indicate that by setting the status with detail information:
|
||||||
|
// updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
||||||
|
// "Could not control device at IP address x.x.x.x");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
config = getConfigAs(MeyCanConfiguration.class);
|
||||||
|
|
||||||
|
// TODO: Initialize the handler.
|
||||||
|
// The framework requires you to return from this method quickly, i.e. any network access must be done in
|
||||||
|
// the background initialization below.
|
||||||
|
// Also, before leaving this method a thing status from one of ONLINE, OFFLINE or UNKNOWN must be set. This
|
||||||
|
// might already be the real thing status in case you can decide it directly.
|
||||||
|
// In case you can not decide the thing status directly (e.g. for long running connection handshake using WAN
|
||||||
|
// access or similar) you should set status UNKNOWN here and then decide the real status asynchronously in the
|
||||||
|
// background.
|
||||||
|
|
||||||
|
// set the thing status to UNKNOWN temporarily and let the background task decide for the real status.
|
||||||
|
// the framework is then able to reuse the resources from the thing handler initialization.
|
||||||
|
// we set this upfront to reliably check status updates in unit tests.
|
||||||
|
updateStatus(ThingStatus.UNKNOWN);
|
||||||
|
|
||||||
|
// Example for background initialization:
|
||||||
|
scheduler.execute(() -> {
|
||||||
|
boolean thingReachable = true; // <background task with long running initialization here>
|
||||||
|
// when done do:
|
||||||
|
if (thingReachable) {
|
||||||
|
updateStatus(ThingStatus.ONLINE);
|
||||||
|
} else {
|
||||||
|
updateStatus(ThingStatus.OFFLINE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// These logging types should be primarily used by bindings
|
||||||
|
// logger.trace("Example trace message");
|
||||||
|
// logger.debug("Example debug message");
|
||||||
|
// logger.warn("Example warn message");
|
||||||
|
//
|
||||||
|
// Logging to INFO should be avoided normally.
|
||||||
|
// See https://www.openhab.org/docs/developer/guidelines.html#f-logging
|
||||||
|
|
||||||
|
// Note: When initialization can NOT be done set the status with more details for further
|
||||||
|
// analysis. See also class ThingStatusDetail for all available status details.
|
||||||
|
// Add a description to give user information to understand why thing does not work as expected. E.g.
|
||||||
|
// updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||||
|
// "Can not access device as username and/or password are invalid");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2023 Contributors to the openHAB project
|
||||||
|
*
|
||||||
|
* See the NOTICE file(s) distributed with this work for additional
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* This program and the accompanying materials are made available under the
|
||||||
|
* terms of the Eclipse Public License 2.0 which is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-2.0
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: EPL-2.0
|
||||||
|
*/
|
||||||
|
package org.openhab.binding.meycan.internal;
|
||||||
|
|
||||||
|
import static org.openhab.binding.meycan.internal.MeyCanBindingConstants.*;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
import org.openhab.core.thing.Thing;
|
||||||
|
import org.openhab.core.thing.ThingTypeUID;
|
||||||
|
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
|
||||||
|
import org.openhab.core.thing.binding.ThingHandler;
|
||||||
|
import org.openhab.core.thing.binding.ThingHandlerFactory;
|
||||||
|
import org.osgi.service.component.annotations.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link MeyCanHandlerFactory} is responsible for creating things and thing
|
||||||
|
* handlers.
|
||||||
|
*
|
||||||
|
* @author Martin Linkwitz - Initial contribution
|
||||||
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
|
@Component(configurationPid = "binding.meycan", service = ThingHandlerFactory.class)
|
||||||
|
public class MeyCanHandlerFactory extends BaseThingHandlerFactory {
|
||||||
|
|
||||||
|
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_SAMPLE);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
|
||||||
|
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected @Nullable ThingHandler createHandler(Thing thing) {
|
||||||
|
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
|
||||||
|
|
||||||
|
if (THING_TYPE_SAMPLE.equals(thingTypeUID)) {
|
||||||
|
return new MeyCanHandler(thing);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<addon:addon id="meycan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:addon="https://openhab.org/schemas/addon/v1.0.0"
|
||||||
|
xsi:schemaLocation="https://openhab.org/schemas/addon/v1.0.0 https://openhab.org/schemas/addon-1.0.0.xsd">
|
||||||
|
|
||||||
|
<type>binding</type>
|
||||||
|
<name>MeyCan Binding</name>
|
||||||
|
<description>This is the binding for MeyCan.</description>
|
||||||
|
|
||||||
|
</addon:addon>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# FIXME: please add all English translations to this file so the texts can be translated using Crowdin
|
||||||
|
# FIXME: to generate the content of this file run: mvn i18n:generate-default-translations
|
||||||
|
# FIXME: see also: https://www.openhab.org/docs/developer/utils/i18n.html
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<thing:thing-descriptions bindingId="meycan"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
|
||||||
|
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
|
||||||
|
|
||||||
|
<!-- Sample Thing Type -->
|
||||||
|
<thing-type id="sample">
|
||||||
|
<!-- Comment this in for Things which need a Bridge to function.
|
||||||
|
<supported-bridge-type-refs>
|
||||||
|
<bridge-type-ref id="MeyCanBridge" />
|
||||||
|
</supported-bridge-type-refs>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<label>MeyCan Binding Thing</label>
|
||||||
|
<description>Sample thing for MeyCan Binding</description>
|
||||||
|
|
||||||
|
<channels>
|
||||||
|
<channel id="channel1" typeId="sample-channel"/>
|
||||||
|
</channels>
|
||||||
|
|
||||||
|
<config-description>
|
||||||
|
<parameter name="hostname" type="text" required="true">
|
||||||
|
<context>network-address</context>
|
||||||
|
<label>Hostname</label>
|
||||||
|
<description>Hostname or IP address of the device</description>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="password" type="text" required="true">
|
||||||
|
<context>password</context>
|
||||||
|
<label>Password</label>
|
||||||
|
<description>Password to access the device</description>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="refreshInterval" type="integer" unit="s" min="1">
|
||||||
|
<label>Refresh Interval</label>
|
||||||
|
<description>Interval the device is polled in sec.</description>
|
||||||
|
<default>600</default>
|
||||||
|
<advanced>true</advanced>
|
||||||
|
</parameter>
|
||||||
|
</config-description>
|
||||||
|
</thing-type>
|
||||||
|
|
||||||
|
<!-- Sample Channel Type -->
|
||||||
|
<channel-type id="sample-channel">
|
||||||
|
<item-type>Number:Temperature</item-type>
|
||||||
|
<label>Example Temperature</label><!-- Use uppercase words, except prepositions. 2-3 words, max 25 chars -->
|
||||||
|
<description>Sample channel for MeyCan Binding</description>
|
||||||
|
</channel-type>
|
||||||
|
</thing:thing-descriptions>
|
||||||
185
Software/Switch/Swtich/MeyCan.cpp
Normal file
185
Software/Switch/Swtich/MeyCan.cpp
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
#include "MeyCan.h";
|
||||||
|
#include <SPI.h>;
|
||||||
|
#include <mcp2515.h>;
|
||||||
|
|
||||||
|
|
||||||
|
PinState MeyPins[8];
|
||||||
|
MCP2515* canInterfaces[4];
|
||||||
|
uint16_t myDeviceId;
|
||||||
|
|
||||||
|
|
||||||
|
void SetupMeyCan()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < sizeof(MeyPins) / sizeof(PinState); i++)
|
||||||
|
{
|
||||||
|
pinMode(MeyPins[i].pin_id, OUTPUT);
|
||||||
|
digitalWrite(MeyPins[i].pin_id, LOW);
|
||||||
|
MeyPins[i].pin_state = false;
|
||||||
|
}
|
||||||
|
CalculateMyDeviceId();
|
||||||
|
|
||||||
|
for (int i = 0; i < sizeof(canInterfaces) / sizeof(MCP2515*); i++) {
|
||||||
|
|
||||||
|
canInterfaces[i]->reset();
|
||||||
|
canInterfaces[i]->setBitrate(CAN_500KBPS, MCP_8MHZ); //Sets CAN at speed 500KBPS and Clock 8MHz
|
||||||
|
canInterfaces[i]->setNormalMode();
|
||||||
|
|
||||||
|
|
||||||
|
SendVersionPackage(canInterfaces[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetCanInterface(byte index, byte pinId)
|
||||||
|
{
|
||||||
|
canInterfaces[index] = new MCP2515(pinId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetMeyPin(byte index, byte meyPinId, byte pinId)
|
||||||
|
{
|
||||||
|
MeyPins[index] = PinState();
|
||||||
|
MeyPins[index].Init(pinId, (byte) meyPinId);
|
||||||
|
|
||||||
|
canInterfaces[index] = new MCP2515(pinId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandleFrame(can_frame *frame)
|
||||||
|
{
|
||||||
|
HandleTriggerMeypinCanPackage(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HandleTriggerMeypinCanPackage(can_frame *frame)
|
||||||
|
{
|
||||||
|
if (GetPackageType(frame->can_id) == TRIGGER_SWITCH_CAN_ID)
|
||||||
|
{
|
||||||
|
uint16_t adressedDeviceId = ((uint16_t )frame->data[0] << 8) | frame->data[1] ;
|
||||||
|
if (adressedDeviceId != myDeviceId) return;
|
||||||
|
|
||||||
|
|
||||||
|
int meyPinId = frame->data[2];
|
||||||
|
bool state = frame->data[3] > 0;
|
||||||
|
|
||||||
|
PinState *adressedPin = NULL;
|
||||||
|
for (int i = 0; i < sizeof(MeyPins) / sizeof(PinState); i++)
|
||||||
|
if (MeyPins[i].meyPinId == meyPinId)
|
||||||
|
{
|
||||||
|
adressedPin = &MeyPins[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (adressedPin != NULL)
|
||||||
|
{
|
||||||
|
if (adressedPin->is_input == true)
|
||||||
|
{
|
||||||
|
pinMode(adressedPin->pin_id, OUTPUT);
|
||||||
|
adressedPin->is_input = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pinChanged = adressedPin->pin_state != state;
|
||||||
|
adressedPin->pin_state = state;
|
||||||
|
|
||||||
|
if (pinChanged) {
|
||||||
|
digitalWrite(adressedPin->pin_id, state);
|
||||||
|
SendSwitchedTriggeredCanPackage(adressedPin->meyPinId, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
byte CircularShift(byte b)
|
||||||
|
{
|
||||||
|
return (b << 1) | (b >> 7 & 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t GetDeviceId(uint32_t canFrameId)
|
||||||
|
{
|
||||||
|
return canFrameId & 0xFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t GetPackageType(uint32_t canFrameId)
|
||||||
|
{
|
||||||
|
return (canFrameId / 0x10000) & 0xFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte GetDeviceIdLow() {
|
||||||
|
return (SIGROW.SERNUM0 ^
|
||||||
|
CircularShift(SIGROW.SERNUM2) << 1 ^
|
||||||
|
CircularShift( CircularShift(SIGROW.SERNUM4)) ^
|
||||||
|
CircularShift( CircularShift( CircularShift(SIGROW.SERNUM6))) ^
|
||||||
|
CircularShift( CircularShift( CircularShift( CircularShift(SIGROW.SERNUM8)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
byte GetDeviceIdHigh() {
|
||||||
|
return (SIGROW.SERNUM1 ^
|
||||||
|
CircularShift(SIGROW.SERNUM3) << 1 ^
|
||||||
|
CircularShift( CircularShift(SIGROW.SERNUM5)) ^
|
||||||
|
CircularShift( CircularShift( CircularShift(SIGROW.SERNUM7))) ^
|
||||||
|
CircularShift( CircularShift( CircularShift( CircularShift(SIGROW.SERNUM9)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t CreateCanId(uint16_t commandId)
|
||||||
|
{
|
||||||
|
return ((((uint32_t)commandId) & 0xFFF) * 0x10000) | myDeviceId | CAN_EFF_FLAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendVersionPackage(MCP2515 *interface)
|
||||||
|
{
|
||||||
|
can_frame toSend;
|
||||||
|
toSend.can_id = CreateCanId(HELP_PACKAGE_CAN_ID);
|
||||||
|
toSend.can_dlc = 6;
|
||||||
|
|
||||||
|
toSend.data[0] = SOFTWARE_VERSION_HIGH;
|
||||||
|
toSend.data[1] = SOFTWARE_VERSION_LOW;
|
||||||
|
toSend.data[2] = HARDWARE_VERSION_HIGH;
|
||||||
|
toSend.data[3] = HARDWARE_VERSION_LOW;
|
||||||
|
toSend.data[4] = (myDeviceId >> 8) & 0xFF;
|
||||||
|
toSend.data[5] = myDeviceId & 0xFF;
|
||||||
|
|
||||||
|
DoSendCanPkg(interface, &toSend);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendDoTriggerSwitchCanPackage(uint16_t targetCanId, byte pinId, byte state)
|
||||||
|
{
|
||||||
|
can_frame toSend;
|
||||||
|
|
||||||
|
toSend.can_id = CreateCanId(TRIGGER_SWITCH_CAN_ID);
|
||||||
|
toSend.can_dlc = 4;
|
||||||
|
toSend.data[0] = (targetCanId & 0xFF00) >> 8;
|
||||||
|
toSend.data[1] = targetCanId & 0xFF;
|
||||||
|
toSend.data[2] = pinId;
|
||||||
|
toSend.data[3] = state;
|
||||||
|
|
||||||
|
DoSendCanPkg(&toSend);
|
||||||
|
HandleFrame(&toSend);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendSwitchedTriggeredCanPackage(byte pinId, int state)
|
||||||
|
{
|
||||||
|
can_frame toSend;
|
||||||
|
toSend.can_id = CreateCanId(SWITCH_TRIGGERED_CAN_ID);
|
||||||
|
toSend.can_dlc = 2;
|
||||||
|
toSend.data[0] = pinId;
|
||||||
|
toSend.data[1] = state;
|
||||||
|
|
||||||
|
DoSendCanPkg(&toSend);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoSendCanPkg(can_frame *frame)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < sizeof(canInterfaces) / sizeof(MCP2515*); i++)
|
||||||
|
DoSendCanPkg(canInterfaces[i], frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoSendCanPkg(MCP2515* interface, can_frame *frame)
|
||||||
|
{
|
||||||
|
byte cnt = 0;
|
||||||
|
while (interface->sendMessage(frame))
|
||||||
|
{
|
||||||
|
if (++cnt > 10) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CalculateMyDeviceId()
|
||||||
|
{
|
||||||
|
myDeviceId = (GetDeviceIdHigh() << 8) | GetDeviceIdLow();
|
||||||
|
}
|
||||||
67
Software/Switch/Swtich/MeyCan.h
Normal file
67
Software/Switch/Swtich/MeyCan.h
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
#ifndef MEYCAN_H
|
||||||
|
#define MEYCAN_H
|
||||||
|
|
||||||
|
#include <SPI.h>
|
||||||
|
#include <mcp2515.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int pin_id;
|
||||||
|
bool pin_state;
|
||||||
|
bool is_input;
|
||||||
|
byte meyPinId;
|
||||||
|
|
||||||
|
PinState() {}
|
||||||
|
void Init(int pin_id, byte meyPinId)
|
||||||
|
{
|
||||||
|
this->pin_id = pin_id;
|
||||||
|
this->pin_state = true;
|
||||||
|
this->is_input = true;
|
||||||
|
this->meyPinId = meyPinId;
|
||||||
|
}
|
||||||
|
} PinState;
|
||||||
|
|
||||||
|
|
||||||
|
/* START MEYCAN */
|
||||||
|
|
||||||
|
const byte SOFTWARE_VERSION_HIGH = 5;
|
||||||
|
const byte SOFTWARE_VERSION_LOW = 0;
|
||||||
|
const byte HARDWARE_VERSION_HIGH = 7;
|
||||||
|
const byte HARDWARE_VERSION_LOW = 0;
|
||||||
|
|
||||||
|
const uint16_t HELP_PACKAGE_CAN_ID = 0x0FFFUL;
|
||||||
|
const uint16_t SWITCH_TRIGGERED_CAN_ID = 0x0050;
|
||||||
|
const uint16_t TRIGGER_SWITCH_CAN_ID = 0x0055;
|
||||||
|
|
||||||
|
extern MCP2515* canInterfaces[4];
|
||||||
|
|
||||||
|
void SetCanInterface(byte index, byte pinId);
|
||||||
|
void SetMeyPin(byte index, byte meyPinId, byte pinId);
|
||||||
|
|
||||||
|
void SetupMeyCan();
|
||||||
|
|
||||||
|
void HandleFrame(can_frame *frame);
|
||||||
|
void HandleTriggerMeypinCanPackage(can_frame *frame);
|
||||||
|
byte CircularShift(byte b);
|
||||||
|
uint16_t GetDeviceId(uint32_t canFrameId);
|
||||||
|
uint16_t GetPackageType(uint32_t canFrameId);
|
||||||
|
byte GetDeviceIdLow();
|
||||||
|
|
||||||
|
byte GetDeviceIdHigh();
|
||||||
|
|
||||||
|
uint32_t CreateCanId(uint16_t commandId);
|
||||||
|
void SendVersionPackage(MCP2515 *interface);
|
||||||
|
|
||||||
|
void SendSwitchedTriggeredCanPackage(byte pinId, int state);
|
||||||
|
void SendDoTriggerSwitchCanPackage(uint16_t targetCanId, byte pinId, byte state);
|
||||||
|
|
||||||
|
void DoSendCanPkg(can_frame *frame);
|
||||||
|
void DoSendCanPkg(MCP2515 *interface, can_frame *frame);
|
||||||
|
|
||||||
|
void CalculateMyDeviceId();
|
||||||
|
|
||||||
|
/* STOP MEYCAN */
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
97
Software/Switch/Swtich/MeyRule.cpp
Normal file
97
Software/Switch/Swtich/MeyRule.cpp
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
#include "MeyRule.h"
|
||||||
|
#include "MeyCan.h"
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <mcp2515.h>;
|
||||||
|
|
||||||
|
RemotePinInfo remotePinInfo = RemotePinInfo();
|
||||||
|
Rule *rules = NULL;
|
||||||
|
|
||||||
|
void PutRule(Rule *rule)
|
||||||
|
{
|
||||||
|
if (rules == NULL)
|
||||||
|
rules = rule;
|
||||||
|
else
|
||||||
|
rules->AddRule(rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddSimple(uint16_t sourceDevId, byte sourceMeyPinId, uint16_t targetDevId, byte targetMeyPinId)
|
||||||
|
{
|
||||||
|
Rule *rule = new Rule();
|
||||||
|
|
||||||
|
rule->sourceDevId = sourceDevId;
|
||||||
|
rule->sourceMeyPinId = sourceMeyPinId;
|
||||||
|
rule->targetDevId = targetDevId;
|
||||||
|
rule->targetMeyPinId = targetMeyPinId;
|
||||||
|
rule->toggle = false;
|
||||||
|
rule->inverse = false;
|
||||||
|
|
||||||
|
PutRule(rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddToggle(uint16_t sourceDevId, byte sourceMeyPinId, uint16_t targetDevId, byte targetMeyPinId)
|
||||||
|
{
|
||||||
|
Rule *rule = new Rule();
|
||||||
|
|
||||||
|
rule->sourceDevId = sourceDevId;
|
||||||
|
rule->sourceMeyPinId = sourceMeyPinId;
|
||||||
|
rule->targetDevId = targetDevId;
|
||||||
|
rule->targetMeyPinId = targetMeyPinId;
|
||||||
|
rule->toggle = true;
|
||||||
|
rule->inverse = false;
|
||||||
|
|
||||||
|
PutRule(rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddToggleInverse(uint16_t sourceDevId, byte sourceMeyPinId, uint16_t targetDevId, byte targetMeyPinId)
|
||||||
|
{
|
||||||
|
Rule *rule = new Rule();
|
||||||
|
|
||||||
|
rule->sourceDevId = sourceDevId;
|
||||||
|
rule->sourceMeyPinId = sourceMeyPinId;
|
||||||
|
rule->targetDevId = targetDevId;
|
||||||
|
rule->targetMeyPinId = targetMeyPinId;
|
||||||
|
rule->toggle = true;
|
||||||
|
rule->inverse = true;
|
||||||
|
|
||||||
|
PutRule(rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CheckRule(uint16_t deviceId, uint8_t dt, uint8_t state, Rule *rule)
|
||||||
|
{
|
||||||
|
RemotePinInfo *currentPinState = remotePinInfo.FindOrAdd(rule->targetDevId);
|
||||||
|
|
||||||
|
if (currentPinState == NULL) return;
|
||||||
|
|
||||||
|
bool pinState = state > 0;
|
||||||
|
if (rule->inverse)
|
||||||
|
pinState = !pinState;
|
||||||
|
|
||||||
|
if (rule->toggle)
|
||||||
|
pinState = (currentPinState->getPinState(rule->targetMeyPinId) ^ true);
|
||||||
|
|
||||||
|
|
||||||
|
SendDoTriggerSwitchCanPackage(rule->targetDevId, rule->targetMeyPinId, pinState);
|
||||||
|
// //digitalWrite(foundPinId->pin_id, pinState);
|
||||||
|
// //foundPinId->pin_state = pinState;
|
||||||
|
//
|
||||||
|
currentPinState->setPinState(rule->targetMeyPinId, pinState);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HandleRules(can_frame *frame)
|
||||||
|
{
|
||||||
|
if (rules == NULL) return;
|
||||||
|
if (GetPackageType(frame->can_id) == SWITCH_TRIGGERED_CAN_ID)
|
||||||
|
{
|
||||||
|
uint16_t deviceId = GetDeviceId(frame->can_id);
|
||||||
|
uint8_t dt = frame->data[1];
|
||||||
|
uint8_t state = frame->data[0];
|
||||||
|
|
||||||
|
rules->Traverse(deviceId, dt, state, CheckRule);
|
||||||
|
}
|
||||||
|
}
|
||||||
110
Software/Switch/Swtich/MeyRule.h
Normal file
110
Software/Switch/Swtich/MeyRule.h
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
#ifndef MEYRULE_H
|
||||||
|
#define MEYRULE_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <mcp2515.h>;
|
||||||
|
|
||||||
|
struct Rule
|
||||||
|
{
|
||||||
|
uint16_t sourceDevId;
|
||||||
|
byte sourceMeyPinId;
|
||||||
|
uint16_t targetDevId;
|
||||||
|
byte targetMeyPinId;
|
||||||
|
bool toggle;
|
||||||
|
bool inverse;
|
||||||
|
Rule *nextRule = NULL;
|
||||||
|
|
||||||
|
void AddRule(Rule *rule)
|
||||||
|
{
|
||||||
|
if (this->nextRule == NULL)
|
||||||
|
{
|
||||||
|
this->nextRule = rule;
|
||||||
|
rule->nextRule = NULL;
|
||||||
|
} else {
|
||||||
|
this->nextRule->AddRule(rule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Traverse( uint16_t deviceId, uint8_t dt, uint8_t state, void (*handle)(uint16_t, uint8_t, uint8_t, Rule*))
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( this->sourceDevId == deviceId && this->sourceMeyPinId == state)
|
||||||
|
handle(deviceId, dt, state, this);
|
||||||
|
|
||||||
|
if (this->nextRule != NULL)
|
||||||
|
this->nextRule->Traverse(deviceId, dt, state, handle);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct RemotePinInfo
|
||||||
|
{
|
||||||
|
const byte MAX_REMOTE_PIN_COUNT = 64;
|
||||||
|
uint16_t DeviceId = 0; // the id of the device
|
||||||
|
uint8_t pinState = 0; // bitmap of 8 MeyPin states of the device. 0000 0100, MeyPin #3 is HIGH in this example
|
||||||
|
RemotePinInfo *next = NULL;
|
||||||
|
|
||||||
|
bool getPinState(byte meyPin)
|
||||||
|
{
|
||||||
|
return (this->pinState >> (meyPin - 1)) & 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPinState(byte meyPin, bool state)
|
||||||
|
{
|
||||||
|
if (state)
|
||||||
|
this->pinState = this->pinState | (1 << (meyPin - 1)); // 0001 0000
|
||||||
|
else
|
||||||
|
this->pinState = this->pinState & (~(1 << (meyPin - 1))); // 1110 1111 -> not
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int16_t Count()
|
||||||
|
{
|
||||||
|
if (this->next == NULL) return 1;
|
||||||
|
return this->next->Count() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
RemotePinInfo* FindOrAdd(uint16_t deviceId, byte count = 0)
|
||||||
|
{
|
||||||
|
if (count > MAX_REMOTE_PIN_COUNT)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
|
||||||
|
if (this->DeviceId == 0 && this->pinState == 0)
|
||||||
|
{
|
||||||
|
this->DeviceId = deviceId;
|
||||||
|
this->pinState = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->DeviceId == deviceId)
|
||||||
|
{
|
||||||
|
//ToggleDebug();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (next != NULL)
|
||||||
|
{
|
||||||
|
return next->FindOrAdd(deviceId, count + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
RemotePinInfo *theNext = new RemotePinInfo;
|
||||||
|
theNext->DeviceId = deviceId;
|
||||||
|
theNext->pinState = 0;
|
||||||
|
theNext->next = NULL;
|
||||||
|
|
||||||
|
this->next = theNext;
|
||||||
|
return this->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
extern RemotePinInfo remotePinInfo;
|
||||||
|
extern Rule *rules;
|
||||||
|
|
||||||
|
void AddSimple(uint16_t sourceDevId, byte sourceMeyPinId, uint16_t targetDevId, byte targetMeyPinId);
|
||||||
|
void AddToggle(uint16_t sourceDevId, byte sourceMeyPinId, uint16_t targetDevId, byte targetMeyPinId);
|
||||||
|
void AddToggleInverse(uint16_t sourceDevId, byte sourceMeyPinId, uint16_t targetDevId, byte targetMeyPinId);
|
||||||
|
void HandleRules(can_frame *frame);
|
||||||
|
void PutRule(Rule *rule);
|
||||||
|
#endif
|
||||||
@@ -1,527 +1,69 @@
|
|||||||
#include <SPI.h>;
|
#include <SPI.h>;
|
||||||
#include <mcp2515.h>;
|
#include <mcp2515.h>;
|
||||||
|
#include "MeyCan.h";
|
||||||
|
#include "MeyRule.h";
|
||||||
|
|
||||||
const byte SoftwareVersionHigh = 3;
|
struct can_frame incomingCanFrame;
|
||||||
const byte SoftwareVersionLow = 1;
|
|
||||||
const byte HardwareVersionHigh = 6;
|
|
||||||
const byte HardwareVersionLow = 0;
|
|
||||||
const uint32_t HELP_PACKAGE_CAN_ID = 0xFFFF;
|
|
||||||
const uint32_t SWITCH_TRIGGERED_CAN_ID = 0x050;
|
|
||||||
const uint32_t TRIGGER_SWITCH_CAN_ID = 0x055;
|
|
||||||
const uint32_t DEBUG_CAN_ID = 0x000;
|
|
||||||
|
|
||||||
struct can_frame _frame;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t sourceDevId;
|
|
||||||
byte sourceMeyPinId;
|
|
||||||
uint32_t targetDevId;
|
|
||||||
byte targetMeyPinId;
|
|
||||||
bool toggle;
|
|
||||||
bool inverse;
|
|
||||||
|
|
||||||
void InitSimple(uint32_t sourceDevId, byte sourceMeyPinId, uint32_t targetDevId, byte targetMeyPinId)
|
|
||||||
{
|
|
||||||
this->sourceDevId = sourceDevId;
|
|
||||||
this->sourceMeyPinId = sourceMeyPinId;
|
|
||||||
this->targetDevId = targetDevId;
|
|
||||||
this->targetMeyPinId = targetMeyPinId;
|
|
||||||
toggle = false;
|
|
||||||
inverse = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitToggle(uint32_t sourceDevId, byte sourceMeyPinId, uint32_t targetDevId, byte targetMeyPinId)
|
|
||||||
{
|
|
||||||
this->sourceDevId = sourceDevId;
|
|
||||||
this->sourceMeyPinId = sourceMeyPinId;
|
|
||||||
this->targetDevId = targetDevId;
|
|
||||||
this->targetMeyPinId = targetMeyPinId;
|
|
||||||
toggle = true;
|
|
||||||
inverse = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitToggleInverse(uint32_t sourceDevId, byte sourceMeyPinId, uint32_t targetDevId, byte targetMeyPinId)
|
|
||||||
{
|
|
||||||
this->sourceDevId = sourceDevId;
|
|
||||||
this->sourceMeyPinId = sourceMeyPinId;
|
|
||||||
this->targetDevId = targetDevId;
|
|
||||||
this->targetMeyPinId = targetMeyPinId;
|
|
||||||
toggle = true;
|
|
||||||
inverse = true;
|
|
||||||
}
|
|
||||||
} Rule;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int pin_id;
|
|
||||||
bool pin_state;
|
|
||||||
bool is_input;
|
|
||||||
byte meyPinId;
|
|
||||||
|
|
||||||
PinState() {}
|
|
||||||
void Init(int pin_id, byte meyPinId)
|
|
||||||
{
|
|
||||||
this->pin_id = pin_id;
|
|
||||||
this->pin_state = true;
|
|
||||||
this->is_input = true;
|
|
||||||
this->meyPinId = meyPinId;
|
|
||||||
}
|
|
||||||
} PinState;
|
|
||||||
|
|
||||||
struct RemotePinInfo
|
|
||||||
{
|
|
||||||
const byte MAX_REMOTE_PIN_COUNT = 50;
|
|
||||||
uint16_t DeviceId = 0; // the id of the device
|
|
||||||
uint16_t pinState = 0; // bitmap of 8 MeyPin states of the device. 0000 0100, MeyPin #3 is HIGH in this example
|
|
||||||
RemotePinInfo *next = NULL;
|
|
||||||
|
|
||||||
bool getPinState(byte meyPin)
|
|
||||||
{
|
|
||||||
return (this->pinState >> (meyPin - 1)) & 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPinState(byte meyPin, bool state)
|
|
||||||
{
|
|
||||||
if (state)
|
|
||||||
this->pinState = this->pinState | (1 << (meyPin - 1)); // 0001 0000
|
|
||||||
else
|
|
||||||
this->pinState = this->pinState & (~(1 << (meyPin - 1))); // 1110 1111 -> not
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int16_t Count()
|
|
||||||
{
|
|
||||||
if (this->next == NULL) return 1;
|
|
||||||
return this->next->Count() + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
RemotePinInfo* FindOrAdd(uint16_t deviceId, byte count = 0)
|
|
||||||
{
|
|
||||||
if (count > MAX_REMOTE_PIN_COUNT)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
|
|
||||||
if (this->DeviceId == 0 && this->pinState == 0)
|
|
||||||
{
|
|
||||||
this->DeviceId = deviceId;
|
|
||||||
this->pinState = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->DeviceId == deviceId)
|
|
||||||
{
|
|
||||||
//ToggleDebug();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (next != NULL)
|
|
||||||
{
|
|
||||||
return next->FindOrAdd(deviceId, count + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
RemotePinInfo *theNext = new RemotePinInfo;
|
|
||||||
theNext->DeviceId = deviceId;
|
|
||||||
theNext->pinState = 0;
|
|
||||||
theNext->next = NULL;
|
|
||||||
|
|
||||||
this->next = theNext;
|
|
||||||
return this->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RemotePinInfo remotePinInfos = RemotePinInfo();
|
|
||||||
PinState MeyPins[8];
|
|
||||||
|
|
||||||
bool flag = false;
|
|
||||||
int16_t myDeviceId;
|
|
||||||
|
|
||||||
Rule Rules[16];
|
|
||||||
|
|
||||||
MCP2515 mcp2515_0(PIN_PA2);
|
|
||||||
MCP2515 mcp2515_1(PIN_PA3);
|
|
||||||
MCP2515 mcp2515_2(PIN_PB0);
|
|
||||||
MCP2515 mcp2515_3(PIN_PB1);
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
SPI.begin();
|
SPI.begin();
|
||||||
|
|
||||||
|
AddToggleInverse(0x051F, 5, 0x3D2D, 4); // Lichtschalter Wohnzimmer Licht 1
|
||||||
|
AddToggleInverse(0x051F, 5, 0x3D2D, 3); // Lichtschalter Wohnzimmer Licht 2
|
||||||
Rules[0] = Rule();
|
AddToggle(0x05df, 1, 0x3D2D, 4); // Licht 1 von Terassenschalter
|
||||||
Rules[0].InitToggleInverse(0x051F, 5, 0x3D2D, 4); // Lichtschalter Wohnzimmer Licht 1
|
AddToggle(0x05df, 1, 0x3D2D, 3); // Licht 2 von Terassenschalter
|
||||||
Rules[1] = Rule();
|
AddToggle(0x0769, 1, 0x3D2D, 6); // Eingangstür Flur Licht 2
|
||||||
Rules[1].InitToggleInverse(0x051F, 5, 0x3D2D, 3); // Lichtschalter Wohnzimmer Licht 2
|
AddToggle(0x0769, 1, 0x9829, 1); //Eingangstür Flur Licht 1
|
||||||
|
AddSimple(0x051F, 3, 0x3D2D, 1); // Licht 1 Wochzimmer Eingangstür
|
||||||
Rules[2] = Rule();
|
AddSimple(0x051F, 4, 0x3D2D, 2); // Licht 2 Wochzimmer Eingangstür
|
||||||
Rules[2].InitToggle(0x05df, 1, 0x3D2D, 4); // Licht 1 von Terassenschalter
|
AddToggle(0x1177, 1, 0x3D2D, 7); // Licht Papa Büro
|
||||||
Rules[3] = Rule();
|
AddToggle(0x05A1, 1, 0x3D2D, 6); // Flurlicht von Papas Büro
|
||||||
Rules[3].InitToggle(0x05df, 1, 0x3D2D, 3); // Licht 2 von Terassenschalter
|
AddToggle(0x05A1, 1, 0x9829, 1); // Flurlicht von Papas Büro
|
||||||
|
AddToggle(0x01EF, 1, 0x3D2D, 6); // Flurlicht von Papas Büro
|
||||||
Rules[4] = Rule();
|
AddToggle(0x01EF, 1, 0x9829, 1); // Flurlicht von Papas Büro
|
||||||
Rules[4].InitToggle(0x0769, 1, 0x3D2D, 6); // Eingangstür Flur Licht 2
|
AddToggle(0x0196, 3, 0x3D2D, 6); // Flurlicht von Papas Büro
|
||||||
Rules[5] = Rule();
|
AddToggle(0x0196, 3, 0x9829, 1); // Flurlicht von Papas Büro
|
||||||
Rules[5].InitToggle(0x0769, 1, 0x9829, 1); //Eingangstür Flur Licht 1
|
AddToggle(0x0632, 1, 0x9829, 5); // Flurlicht von Papas Büro
|
||||||
|
|
||||||
Rules[6] = Rule();
|
|
||||||
Rules[6].InitSimple(0x051F, 3, 0x3D2D, 1); // Licht 1 Wochzimmer Eingangstür
|
|
||||||
Rules[7] = Rule();
|
|
||||||
Rules[7].InitSimple(0x051F, 4, 0x3D2D, 2); // Licht 2 Wochzimmer Eingangstür
|
|
||||||
|
|
||||||
Rules[8] = Rule();
|
|
||||||
Rules[8].InitToggle(0x1177, 1, 0x3D2D, 7); // Licht Papa Büro
|
|
||||||
|
|
||||||
Rules[9] = Rule();
|
|
||||||
Rules[9].InitToggle(0x05A1, 1, 0x3D2D, 6); // Flurlicht von Papas Büro
|
|
||||||
|
|
||||||
Rules[10] = Rule();
|
|
||||||
Rules[10].InitToggle(0x05A1, 1, 0x9829, 1); // Flurlicht von Papas Büro
|
|
||||||
|
|
||||||
Rules[11] = Rule();
|
|
||||||
Rules[11].InitToggle(0x01EF, 1, 0x3D2D, 6); // Flurlicht von Papas Büro
|
|
||||||
Rules[12] = Rule();
|
|
||||||
Rules[12].InitToggle(0x01EF, 1, 0x9829, 1); // Flurlicht von Papas Büro#
|
|
||||||
|
|
||||||
Rules[13] = Rule();
|
|
||||||
Rules[13].InitToggle(0x0196, 3, 0x3D2D, 6); // Flurlicht von Papas Büro
|
|
||||||
|
|
||||||
Rules[14] = Rule();
|
|
||||||
Rules[14].InitToggle(0x0196, 3, 0x9829, 1); // Flurlicht von Papas Büro
|
|
||||||
|
|
||||||
Rules[15] = Rule();
|
|
||||||
Rules[15].InitToggle(0x0632, 1, 0x9829, 5); // Flurlicht von Papas Büro
|
|
||||||
|
|
||||||
delay(10);
|
|
||||||
MeyPins[0] = PinState();
|
|
||||||
MeyPins[0].Init(PIN_PC7, (byte) 1);
|
|
||||||
|
|
||||||
MeyPins[1] = PinState();
|
|
||||||
MeyPins[1].Init(PIN_PC6, (byte) 2);
|
|
||||||
|
|
||||||
MeyPins[2] = PinState();
|
|
||||||
MeyPins[2].Init(PIN_PC5, (byte) 3);
|
|
||||||
|
|
||||||
MeyPins[3] = PinState();
|
|
||||||
MeyPins[3].Init(PIN_PC4, (byte) 4);
|
|
||||||
|
|
||||||
MeyPins[4] = PinState();
|
|
||||||
MeyPins[4].Init(PIN_PC3, (byte) 5);
|
|
||||||
|
|
||||||
MeyPins[5] = PinState();
|
|
||||||
MeyPins[5].Init(PIN_PC2, (byte) 6);
|
|
||||||
|
|
||||||
MeyPins[6] = PinState();
|
|
||||||
MeyPins[6].Init(PIN_PC1, (byte) 7);
|
|
||||||
|
|
||||||
MeyPins[7] = PinState();
|
|
||||||
MeyPins[7].Init(PIN_PC0, (byte) 8);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_PROTECTED_WRITE(CLKCTRL.MCLKCTRLA, CLKCTRL.MCLKCTRLA | 1 << 7);
|
_PROTECTED_WRITE(CLKCTRL.MCLKCTRLA, CLKCTRL.MCLKCTRLA | 1 << 7);
|
||||||
|
|
||||||
|
delay(10); // a bit delay for mcp2515 to get the clock
|
||||||
|
|
||||||
mcp2515_0.reset();
|
SetMeyPin(0, 1, PIN_PC7);
|
||||||
mcp2515_0.setBitrate(CAN_500KBPS, MCP_8MHZ); //Sets CAN at speed 500KBPS and Clock 8MHz
|
SetMeyPin(1, 2, PIN_PC6);
|
||||||
mcp2515_0.setNormalMode();
|
SetMeyPin(2, 3, PIN_PC5);
|
||||||
|
SetMeyPin(3, 4, PIN_PC4);
|
||||||
|
SetMeyPin(4, 5, PIN_PC3);
|
||||||
|
SetMeyPin(5, 6, PIN_PC2);
|
||||||
|
SetMeyPin(6, 7, PIN_PC1);
|
||||||
|
SetMeyPin(7, 8, PIN_PC0);
|
||||||
|
|
||||||
mcp2515_1.reset();
|
SetCanInterface(0, PIN_PA2);
|
||||||
mcp2515_1.setBitrate(CAN_500KBPS, MCP_8MHZ); //Sets CAN at speed 500KBPS and Clock 8MHz
|
SetCanInterface(1, PIN_PA3);
|
||||||
mcp2515_1.setNormalMode();
|
SetCanInterface(2, PIN_PB0);
|
||||||
|
SetCanInterface(3, PIN_PB1);
|
||||||
|
|
||||||
mcp2515_2.reset();
|
|
||||||
mcp2515_2.setBitrate(CAN_500KBPS, MCP_8MHZ); //Sets CAN at speed 500KBPS and Clock 8MHz
|
|
||||||
mcp2515_2.setNormalMode();
|
|
||||||
|
|
||||||
mcp2515_3.reset();
|
SetupMeyCan();
|
||||||
mcp2515_3.setBitrate(CAN_500KBPS, MCP_8MHZ); //Sets CAN at speed 500KBPS and Clock 8MHz
|
|
||||||
mcp2515_3.setNormalMode();
|
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(MeyPins) / sizeof(PinState); i++)
|
|
||||||
{
|
|
||||||
pinMode(MeyPins[i].pin_id, OUTPUT);
|
|
||||||
|
|
||||||
digitalWrite(MeyPins[i].pin_id, LOW);
|
|
||||||
|
|
||||||
}
|
|
||||||
CalculateMyDeviceId();
|
|
||||||
|
|
||||||
SendSerialPackage(&mcp2515_0);
|
|
||||||
SendSerialPackage(&mcp2515_1);
|
|
||||||
SendSerialPackage(&mcp2515_2);
|
|
||||||
SendSerialPackage(&mcp2515_3);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool debugState = false;
|
|
||||||
void ToggleDebug()
|
|
||||||
{
|
|
||||||
debugState = debugState ^ true;
|
|
||||||
if (debugState)
|
|
||||||
digitalWrite(PIN_PC1, HIGH);
|
|
||||||
else
|
|
||||||
digitalWrite(PIN_PC1, LOW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
if (mcp2515_0.readMessage(&_frame) == MCP2515::ERROR_OK)
|
for (int i = 0; i < sizeof(canInterfaces) / sizeof(MCP2515*); i++)
|
||||||
{
|
{
|
||||||
|
if (canInterfaces[i]->readMessage(&incomingCanFrame) == MCP2515::ERROR_OK)
|
||||||
DoSendCanPkg(&mcp2515_1, &_frame);
|
|
||||||
DoSendCanPkg(&mcp2515_2, &_frame);
|
|
||||||
DoSendCanPkg(&mcp2515_3, &_frame);
|
|
||||||
HandleFrame(&_frame);
|
|
||||||
}
|
|
||||||
if (mcp2515_1.readMessage(&_frame) == MCP2515::ERROR_OK)
|
|
||||||
{
|
{
|
||||||
DoSendCanPkg(&mcp2515_0, &_frame);
|
// A received CAN Frame is forwarded to all other MCPs given, but not to the receiving one (no echo )
|
||||||
DoSendCanPkg(&mcp2515_2, &_frame);
|
for (int j = 0; j < sizeof(canInterfaces) / sizeof(MCP2515*); j++)
|
||||||
DoSendCanPkg(&mcp2515_3, &_frame);
|
|
||||||
HandleFrame(&_frame);
|
|
||||||
}
|
|
||||||
if (mcp2515_2.readMessage(&_frame) == MCP2515::ERROR_OK)
|
|
||||||
{
|
{
|
||||||
DoSendCanPkg(&mcp2515_0, &_frame);
|
if (j == i) continue; // thats for the echo
|
||||||
DoSendCanPkg(&mcp2515_1, &_frame);
|
DoSendCanPkg(canInterfaces[j], &incomingCanFrame);
|
||||||
DoSendCanPkg(&mcp2515_3, &_frame);
|
|
||||||
HandleFrame(&_frame);
|
|
||||||
}
|
|
||||||
if (mcp2515_3.readMessage(&_frame) == MCP2515::ERROR_OK)
|
|
||||||
{
|
|
||||||
DoSendCanPkg(&mcp2515_0, &_frame);
|
|
||||||
DoSendCanPkg(&mcp2515_1, &_frame);
|
|
||||||
DoSendCanPkg(&mcp2515_2, &_frame);;
|
|
||||||
HandleFrame(&_frame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleFrame(can_frame *frame)
|
HandleFrame(&incomingCanFrame);
|
||||||
{
|
HandleRules(&incomingCanFrame);
|
||||||
// ToggleDebug();
|
|
||||||
HandleMeyPinTriggeredCanPackage(frame);
|
|
||||||
HandleTriggerMeypinCanPackage(frame);
|
|
||||||
// Handle rules needs to be the last call
|
|
||||||
HandleRules(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
// this method will save the state of the triggered pin to be present for the rules
|
|
||||||
void HandleMeyPinTriggeredCanPackage(can_frame *frame)
|
|
||||||
{
|
|
||||||
if (GetPackageType(frame->can_id) == SWITCH_TRIGGERED_CAN_ID)
|
|
||||||
{
|
|
||||||
|
|
||||||
RemotePinInfo *currentPinState = remotePinInfos.FindOrAdd(GetDeviceId(frame->can_id) );
|
|
||||||
|
|
||||||
|
|
||||||
if (currentPinState == NULL)
|
|
||||||
{
|
|
||||||
int16_t test2[3];
|
|
||||||
test2[0] = 'S';
|
|
||||||
test2[1] = 'O';
|
|
||||||
test2[2] = 'S';
|
|
||||||
// SendDebugCanPackage(&mcp2515_3, test2, sizeof(test2) / sizeof(int16_t));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t test[1];
|
|
||||||
test[0] = remotePinInfos.Count();
|
|
||||||
// SendDebugCanPackage(&mcp2515_3, test, sizeof(test) / sizeof(int16_t));
|
|
||||||
|
|
||||||
currentPinState->setPinState(frame->data[0], frame->data[1]);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleTriggerMeypinCanPackage(can_frame *frame)
|
|
||||||
{
|
|
||||||
if (GetPackageType(frame->can_id) == TRIGGER_SWITCH_CAN_ID && (GetDeviceId(frame->can_id) == GetMyDeviceId()))
|
|
||||||
{
|
|
||||||
int meyPinId = frame->data[2];
|
|
||||||
bool state = frame->data[3] > 0;
|
|
||||||
|
|
||||||
PinState *adressedPin;
|
|
||||||
for (int i = 0; i < sizeof(MeyPins) / sizeof(PinState); i++)
|
|
||||||
if (MeyPins[i].meyPinId == meyPinId)
|
|
||||||
{
|
|
||||||
adressedPin = &MeyPins[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (adressedPin != NULL)
|
|
||||||
{
|
|
||||||
if (adressedPin->is_input == true)
|
|
||||||
{
|
|
||||||
pinMode(adressedPin->pin_id, OUTPUT);
|
|
||||||
adressedPin->is_input = false;
|
|
||||||
}
|
|
||||||
adressedPin->pin_state = state;
|
|
||||||
digitalWrite(adressedPin->pin_id, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleRules(can_frame *frame)
|
|
||||||
{
|
|
||||||
if (GetPackageType(frame->can_id) == SWITCH_TRIGGERED_CAN_ID)
|
|
||||||
{
|
|
||||||
uint16_t deviceId = GetDeviceId(frame->can_id);
|
|
||||||
uint8_t dt = _frame.data[1];
|
|
||||||
uint8_t state = frame->data[0];
|
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(Rules) / sizeof(Rule); i++)
|
|
||||||
{
|
|
||||||
if ( Rules[i].sourceDevId == deviceId)
|
|
||||||
if (Rules[i].sourceMeyPinId == state)
|
|
||||||
HandleRule(&Rules[i], dt );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleRule(Rule *rule, byte state)
|
|
||||||
{
|
|
||||||
struct RemotePinInfo *currentPinState = remotePinInfos.FindOrAdd(rule->targetDevId);
|
|
||||||
|
|
||||||
if (currentPinState == NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pinState = state > 0;
|
|
||||||
if (rule->inverse)
|
|
||||||
pinState = !pinState;
|
|
||||||
|
|
||||||
|
|
||||||
if (rule->toggle)
|
|
||||||
{
|
|
||||||
pinState = (currentPinState->getPinState(rule->targetMeyPinId) ^ true) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SendDoTriggerSwitchCanPackage(&mcp2515_0, rule->targetDevId, rule->targetMeyPinId, pinState);
|
|
||||||
SendDoTriggerSwitchCanPackage(&mcp2515_1, rule->targetDevId, rule->targetMeyPinId, pinState);
|
|
||||||
SendDoTriggerSwitchCanPackage(&mcp2515_2, rule->targetDevId, rule->targetMeyPinId, pinState);
|
|
||||||
SendDoTriggerSwitchCanPackage(&mcp2515_3, rule->targetDevId, rule->targetMeyPinId, pinState);
|
|
||||||
//digitalWrite(foundPinId->pin_id, pinState);
|
|
||||||
//foundPinId->pin_state = pinState;
|
|
||||||
|
|
||||||
HandleFrame(&_frame);
|
|
||||||
currentPinState->setPinState(rule->targetMeyPinId, pinState);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
byte CircularShift(byte b)
|
|
||||||
{
|
|
||||||
return (b << 1) | (b >> 7 & 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t GetDeviceId(uint32_t canFrameId)
|
|
||||||
{
|
|
||||||
return canFrameId & 0xFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t GetPackageType(uint32_t canFrameId)
|
|
||||||
{
|
|
||||||
return (canFrameId / 0x10000) & 0xFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t CreateCanId(uint16_t commandId)
|
|
||||||
{
|
|
||||||
return ((commandId & 0xFFF) * 0x10000) | myDeviceId | CAN_EFF_FLAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t CreateCanId(uint16_t commandId, uint16_t deviceId)
|
|
||||||
{
|
|
||||||
return ((commandId & 0xFFF) * 0x10000) | deviceId | CAN_EFF_FLAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalculateMyDeviceId()
|
|
||||||
{
|
|
||||||
myDeviceId = (GetDeviceIdHigh() << 8) | GetDeviceIdLow();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t GetMyDeviceId()
|
|
||||||
{
|
|
||||||
return myDeviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte GetDeviceIdLow() {
|
|
||||||
return (SIGROW.SERNUM0 ^
|
|
||||||
CircularShift(SIGROW.SERNUM2) << 1 ^
|
|
||||||
CircularShift( CircularShift(SIGROW.SERNUM4)) ^
|
|
||||||
CircularShift( CircularShift( CircularShift(SIGROW.SERNUM6))) ^
|
|
||||||
CircularShift( CircularShift( CircularShift( CircularShift(SIGROW.SERNUM8)))));
|
|
||||||
}
|
|
||||||
|
|
||||||
byte GetDeviceIdHigh() {
|
|
||||||
return (SIGROW.SERNUM1 ^
|
|
||||||
CircularShift(SIGROW.SERNUM3) << 1 ^
|
|
||||||
CircularShift( CircularShift(SIGROW.SERNUM5)) ^
|
|
||||||
CircularShift( CircularShift( CircularShift(SIGROW.SERNUM7))) ^
|
|
||||||
CircularShift( CircularShift( CircularShift( CircularShift(SIGROW.SERNUM9)))));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendSerialPackage(MCP2515 *interface)
|
|
||||||
{
|
|
||||||
_frame.can_id = CreateCanId(HELP_PACKAGE_CAN_ID);
|
|
||||||
_frame.can_dlc = 4;
|
|
||||||
|
|
||||||
_frame.data[0] = SoftwareVersionHigh;
|
|
||||||
_frame.data[1] = SoftwareVersionLow;
|
|
||||||
_frame.data[2] = HardwareVersionHigh;
|
|
||||||
_frame.data[3] = HardwareVersionLow;
|
|
||||||
DoSendCanPkg(interface, &_frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendSwitchedTriggeredCanPackage(MCP2515 *interface, byte pinId, int state)
|
|
||||||
{
|
|
||||||
_frame.can_id = CreateCanId(SWITCH_TRIGGERED_CAN_ID);
|
|
||||||
_frame.can_dlc = 2;
|
|
||||||
_frame.data[0] = pinId;
|
|
||||||
_frame.data[1] = state;
|
|
||||||
DoSendCanPkg(interface, &_frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SendDoTriggerSwitchCanPackage(MCP2515 *interface, uint16_t targetCanId, byte pinId, byte state)
|
|
||||||
{
|
|
||||||
_frame.can_id = CreateCanId(TRIGGER_SWITCH_CAN_ID, targetCanId);
|
|
||||||
_frame.can_dlc = 4;
|
|
||||||
_frame.data[0] = (targetCanId & 0xFF00) >> 8;
|
|
||||||
_frame.data[1] = targetCanId & 0xFF;
|
|
||||||
_frame.data[2] = pinId;
|
|
||||||
_frame.data[3] = state;
|
|
||||||
|
|
||||||
DoSendCanPkg(interface, &_frame);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void DoSendCanPkg(MCP2515 *interface, can_frame *frame)
|
|
||||||
{
|
|
||||||
// ToggleDebug();
|
|
||||||
byte cnt = 0;
|
|
||||||
while (interface->sendMessage(&_frame)) {
|
|
||||||
cnt++;
|
|
||||||
if (cnt > 10) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
void SendDebugCanPackage(MCP2515 *interface, int16_t *data, int len)
|
|
||||||
{
|
|
||||||
can_frame frame = can_frame();
|
|
||||||
frame.can_id = 0;
|
|
||||||
frame.can_id = CreateCanId(DEBUG_CAN_ID);
|
|
||||||
|
|
||||||
|
|
||||||
frame.can_dlc = len * 2;
|
|
||||||
|
|
||||||
for (int i = 0; i < frame.can_dlc / 2; i++)
|
|
||||||
{
|
|
||||||
frame.data[2 * i] = ((byte[])data)[2 * i + 1];
|
|
||||||
frame.data[2 * i + 1] = ((byte[])data)[2 * i];
|
|
||||||
}
|
|
||||||
|
|
||||||
DoSendCanPkg(interface, &frame);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,318 +1,257 @@
|
|||||||
:1000000050C0000073C0000071C000006FC000004D
|
:1000000050C0000068C0000066C0000064C000006E
|
||||||
:100010006DC000006BC0000069C0000067C0000038
|
:1000100062C0000060C000005EC000005CC0000064
|
||||||
:1000200065C0000063C0000061C000005FC0000048
|
:100020005AC0000058C0000056C0000054C0000074
|
||||||
:100030005DC000005BC0000059C0000057C0000058
|
:1000300052C0000050C000004EC000004CC0000084
|
||||||
:1000400055C0000053C0000051C000004FC0000068
|
:100040004AC0000048C0000046C0000044C0000094
|
||||||
:100050004DC000004BC0000049C0000047C0000078
|
:1000500042C0000040C000003EC000003CC00000A4
|
||||||
:1000600045C00000A8C6000041C000003FC000001D
|
:100060003AC0000072C5000036C0000034C0000075
|
||||||
:100070003DC000003BC0000039C0000037C0000098
|
:1000700032C0000030C000002EC000002CC00000C4
|
||||||
:1000800035C0000033C0000031C000002FC00000A8
|
:100080002AC0000028C0000026C0000024C00000D4
|
||||||
:100090002DC000002BC0000029C0000027C00000B8
|
:1000900022C0000020C000001EC000001CC00000E4
|
||||||
:1000A000110711241FBECFEFCDBFDFE3DEBF1CE37E
|
:1000A000DB0511241FBECFEFCDBFDFE3DEBF2CE3A6
|
||||||
:1000B000A0E0BCE3E0EBF3E102C005900D92AE30AE
|
:1000B000A0E0BCE301C01D92A838B207E1F710E050
|
||||||
:1000C000B107D9F72CE3AEE0BCE301C01D92A43721
|
:1000C000C1E5D0E003C02197FE011BD7C035D107A1
|
||||||
:1000D000B207E1F710E0C1E5D0E003C02197FE01CF
|
:1000D000D1F78BD531C794CF90E0FC01EE52F04BB5
|
||||||
:1000E000C9D7C035D107D1F7B6D604C989CF90E0BA
|
:1000E00020812F3F51F08755904BDC01EC91B0E21D
|
||||||
:1000F000FC01E957FC4A20812F3F51F0825A9C4A6B
|
:1000F000EB9FF0011124FC5F218308958091433C24
|
||||||
:10010000DC01EC91B0E2EB9FF0011124FC5F218354
|
:10010000811117C01092443C1092453C1092463C1D
|
||||||
:10011000089580912D3C811117C010922E3C1092B1
|
:100110001092473C1092483C1092493C10924A3C45
|
||||||
:100120002F3C1092303C1092313C1092323C109295
|
:1001200010924B3C10924C3C10924D3C81E08093DD
|
||||||
:10013000333C1092343C1092353C1092363C109275
|
:10013000433C8091E3058C7F9091423C892B8093D6
|
||||||
:10014000373C81E080932D3C8091E3058C7F90913A
|
:10014000E305911117C084E0C7DF86E0C5DF809129
|
||||||
:100150002C3C892B8093E305911117C084E0C7DF05
|
:10015000C10884608093C1088091C0088162809347
|
||||||
:1001600086E0C5DF8091C10884608093C1088091DA
|
:10016000C00890917D3C80917E3C9093C008809324
|
||||||
:10017000C00881628093C0089091673C8091683C80
|
:10017000C1080895913021F48EE0AEDF80E1E6CF32
|
||||||
:100180009093C0088093C1080895913021F48EE0C7
|
:10018000923029F78EE1A8DF80E2E0CF0000809373
|
||||||
:10019000AEDF80E1E6CF923029F78EE1A8DF80E282
|
:10019000C4088091C30887FFFCCF8091C4080895EC
|
||||||
:1001A000E0CF00008093C4088091C30887FFFCCF94
|
:1001A000282F30E0F901EE52F04B40814F3F09F427
|
||||||
:1001B0008091C4080895282F30E0F901E957FC4ADE
|
:1001B00050C0893258F4F901E95AF04BE081EE233E
|
||||||
:1001C00040814F3F09F450C0893258F4F901EC5F87
|
:1001C00029F0E13099F010F0E63020F1F901E7551F
|
||||||
:1001D000FC4AE081EE2329F0E13099F010F0E6309E
|
:1001D000F04BE081A0E2EA9FF0011124FC5F8081F6
|
||||||
:1001E00020F1F901E25AFC4AE081A0E2EA9FF00125
|
:1001E000842321F1611120C046830895F901E0586C
|
||||||
:1001F0001124FC5F8081842321F1611120C046839A
|
:1001F000F04B5081533008F05F5F7091010A81E04D
|
||||||
:100200000895F901EB5CFC4A5081533008F05F5FC0
|
:1002000090E001C0880F5A95EAF780958723809384
|
||||||
:100210007091010A81E090E001C0880F5A95EAF7D9
|
:10021000010ADCCF80E1E89FF0011124E05AF54F9C
|
||||||
:10022000809587238093010ADCCF80E1E89FF0016D
|
:1002200081818F7E8183D2CF458308952058304BC2
|
||||||
:100230001124E05AF54F81818F7E8183D2CF45838F
|
:10023000D9018C91309771F08F3F61F07096E80F83
|
||||||
:1002400008952B5C3C4AD9018C91309771F08F3F17
|
:10024000F11D9FB7F8948081611107C0877F80837B
|
||||||
:1002500061F07096E80FF11D9FB7F89480816111ED
|
:100250009FBF0895F0E0E0E0F4CF8860F8CF8FB75B
|
||||||
:1002600007C0877F80839FBF0895F0E0E0E0F4CF70
|
:10026000F8942091103C3091113C4091123C5091F7
|
||||||
:100270008860F8CF8FB7F8942091103C3091113CF2
|
:10027000133CE091AA0AF091AB0A9091A60A90FF74
|
||||||
:100280004091123C5091133CE091AA0AF091AB0AC4
|
:1002800008C02F5F3F4F4F4F5F4FE091AA0AF09198
|
||||||
:100290009091A60A90FF08C02F5F3F4F4F4F5F4FCE
|
:10029000AB0A8FBFA8EEB3E001D623E0F695E79551
|
||||||
:1002A000E091AA0AF091AB0A8FBFA8EEB3E0AFD6F7
|
:1002A0002A95E1F76E0F7F1F811D911D08958F9292
|
||||||
:1002B00023E0F695E7952A95E1F76E0F7F1F811DE4
|
:1002B0009F92AF92BF92CF92DF92EF92FF924B014B
|
||||||
:1002C000911D0895CF92DF92EF92FF92D3DF6B01E1
|
:1002C0005C01CDDF6B017C01A8EEB3E0A5019401D8
|
||||||
:1002D0007C0120E1C20E27E2D21EE11CF11C80E16C
|
:1002D000E5D5C60ED71EE81EF91EC616D706E806D7
|
||||||
:1002E000C81687E2D806E104F10430F4C3DFC6166D
|
:1002E000F90610F4BCDFF9CFBADF6C157D058E0579
|
||||||
:1002F000D706E806F906D0F3BDDF6C157D058E053F
|
:1002F0009F05D0F3FF90EF90DF90CF90BF90AF902D
|
||||||
:100300009F05D0F3FF90EF90DF90CF9008958F92EC
|
:100300009F908F9008958F929F92AF92BF92CF92BD
|
||||||
:100310009F92AF92BF92CF92DF92EF92FF920F9394
|
:10031000DF92EF92FF920F93CF93DF93FC018081E6
|
||||||
:10032000CF93DF93FC018081893210F461E043DFD9
|
:10032000893210F461E03CDF8091443C882319F06D
|
||||||
:1003300080912E3C882319F081FF0DC07894DF91C5
|
:1003300081FF0DC07894DF91CF910F91FF90EF90E6
|
||||||
:10034000CF910F91FF90EF90DF90CF90BF90AF9043
|
:10034000DF90CF90BF90AF909F908F90089580FFE7
|
||||||
:100350009F908F90089580FFF2CF8090303C9090D6
|
:10035000F2CF8090463C9090473CA090483CB090B3
|
||||||
:10036000313CA090323CB090333CC12CD12C760172
|
:10036000493CC12CD12C7601E0E09401A501B601F5
|
||||||
:10037000E0E09401A501B601C701A0E06FD681F1CC
|
:10037000C701A0E0BAD581F1217030E040E050E043
|
||||||
:10038000217030E040E050E060E070E080E090E01C
|
:1003800060E070E080E090E0B0D5D1F0B0E0A0E0B7
|
||||||
:1003900065D6D1F0B0E0A0E0E03370F4AE2FA695C2
|
:10039000E03370F4AE2FA695A695A695F0E2AF9F38
|
||||||
:1003A000A695A695F0E2AF9FD0011124A05FBB4FA8
|
:1003A000D0011124A05FBB4F8E2F8770A80FB11D05
|
||||||
:1003B0008E2F8770A80FB11DCE2FD0E0C85DD34C13
|
:1003B000CE2FD0E0C25CD34C88899C91892B8C9342
|
||||||
:1003C00088899C91892B8C939401A501B601C70162
|
:1003C0009401A501B601C70101E074D549015A01A4
|
||||||
:1003D00001E029D649015A016B017C01EF5FC9CFC9
|
:1003D0006B017C01EF5FC9CF80904A3C90904B3C11
|
||||||
:1003E0008090343C9090353CA090363CB090373CA7
|
:1003E000A0904C3CB0904D3CC12CD12C7601E0E269
|
||||||
:1003F000C12CD12C7601E0E29401A501B601C70120
|
:1003F0009401A501B601C701A0E077D509F49BCF10
|
||||||
:10040000A0E02CD609F49BCF217030E040E050E012
|
:10040000217030E040E050E060E070E080E090E09B
|
||||||
:1004100060E070E080E090E021D6D1F0B0E0A0E0B4
|
:100410006CD5D1F0B0E0A0E0E03370F4AE2FA6953B
|
||||||
:10042000E03370F4AE2FA695A695A69580E2A89F1E
|
:10042000A695A69580E2A89FD0011124A05FBB4F9E
|
||||||
:10043000D0011124A05FBB4F8E2F8770A80FB11D74
|
:100430008E2F8770A80FB11DCE2FD0E0C25CD34C99
|
||||||
:10044000CE2FD0E0C85DD34C88899C91892B8C93AA
|
:1004400088899C91892B8C939401A501B601C701E1
|
||||||
:100450009401A501B601C70101E0E5D549015A01A2
|
:1004500001E030D549015A016B017C01EF5FC8CF43
|
||||||
:100460006B017C01EF5FC8CFE0E0F1E14481968150
|
:100460006F927F928F929F92AF92BF92CF92DF92C4
|
||||||
:10047000308522858485990F911D990F9427330F1C
|
:10047000EF92FF920F93CF93DF933C018091443C26
|
||||||
:10048000311D330F311D9327229520FB279527F926
|
:10048000882319F081FF1BC0F89481E38093C00892
|
||||||
:100490009227829589270895E0E0F1E143819581D3
|
:1004900084E08093C108F3018081893208F09CC018
|
||||||
:1004A000378121858385990F911D990F9427330FEB
|
:1004A00060E0DF91CF910F91FF90EF90DF90CF90C0
|
||||||
:1004B000311D330F311D9327229520FB279527F9F6
|
:1004B000BF90AF909F908F907F906F9071CE80FF94
|
||||||
:1004C0009227829589270895CF92DF92EF92FF922B
|
:1004C000E4CF8090463C9090473CA090483CB09050
|
||||||
:1004D000CF93DF9361E085E16EDEC090183CD09051
|
:1004D000493CC12CD12C7601B0E09401A501B601B4
|
||||||
:1004E000193CE0901A3CF0901B3CC7019F7080358E
|
:1004E000C701A0E002D591F1217030E040E050E07A
|
||||||
:1004F000910571F5A60180E0C0E0DCE398819817D2
|
:1004F00060E070E080E090E0F8D4E1F0D0E0C0E0AF
|
||||||
:1005000038F129813A81232B31F42B813C81232B33
|
:10050000B03370F4CB2FC695C695C69580E2C89FD0
|
||||||
:1005100011F449835A8329813A8142175307F9F02C
|
:10051000E0011124C05FDB4F8B2F8770C80FD11D06
|
||||||
:100520002D813E812115310519F08F5FE901E6CF5C
|
:100520008B2F90E02881825C934CFC01208B88818A
|
||||||
:1005300087E090E0B1D5FC0182E3808313821482CE
|
:10053000887F88839401A501B601C70101E0BAD480
|
||||||
:1005400015821682C182D282ED83FE83309741F4F8
|
:1005400049015A016B017C01BF5FC7CF80904A3CD3
|
||||||
:10055000DF91CF91FF90EF90DF90CF900895FE0153
|
:1005500090904B3CA0904C3CB0904D3CC12CD12C89
|
||||||
:10056000438154812091203C2150330B81E090E065
|
:100560007601B0E29401A501B601C701A0E0BDD4B7
|
||||||
:1005700002C0880F991F2A95E2F72091213C22237F
|
:1005700009F48BCF217030E040E050E060E070E0A3
|
||||||
:1005800029F0842B952B83839483E2CF80959095DB
|
:1005800080E090E0B2D4E1F0D0E0C0E0B03370F4AD
|
||||||
:1005900084239523F8CF6F927F928F929F92AF9290
|
:10059000CB2FC695C695C695F0E2CF9FE0011124FA
|
||||||
:1005A000BF92CF92DF92EF92FF920F93CF93DF93A0
|
:1005A000C05FDB4F8B2F8770C80FD11D8B2F90E062
|
||||||
:1005B0003C0180912E3C882319F081FF1BC0F894E8
|
:1005B0002881825C934CFC01208B8881887F888312
|
||||||
:1005C00081E38093C00884E08093C108F3018081B7
|
:1005C0009401A501B601C70101E074D449015A01A3
|
||||||
:1005D000893208F09CC060E0DF91CF910F91FF90CD
|
:1005D0006B017C01BF5FC6CFDF91CF910F91FF9080
|
||||||
:1005E000EF90DF90CF90BF90AF909F908F907F90D3
|
:1005E000EF90DF90CF90BF90AF909F908F907F90D3
|
||||||
:1005F0006F90E1CD80FFE4CF8090303C9090313C13
|
:1005F0006F900895FF920F931F93CF93DF93EC01B9
|
||||||
:10060000A090323CB090333CC12CD12C7601B0E0AC
|
:10060000F62E042F122F2CDF85E0C0DD8F2DBEDDEE
|
||||||
:100610009401A501B601C701A0E020D591F1217098
|
:10061000802FBCDD812FBADDCE01DF91CF911F91FC
|
||||||
:1006200030E040E050E060E070E080E090E016D51F
|
:100620000F91FF9070CEDF92EF92FF920F931F9386
|
||||||
:10063000E1F0D0E0C0E0B03370F4CB2FC695C695A2
|
:10063000CF93DF937C01C62FD42E152F022F10DF0E
|
||||||
:10064000C69580E2C89FE0011124C05FDB4F8B2F6D
|
:1006400082E0A4DD8C2FA2DDCD2DD12F0C0F1D2F2C
|
||||||
:100650008770C80FD11D8B2F90E02881885D934C47
|
:10065000111DC017D10719F0899198DDFACFC70194
|
||||||
:10066000FC01208B8881887F88839401A501B601D5
|
:10066000DF91CF911F910F91FF90EF90DF904BCED4
|
||||||
:10067000C70101E0D8D449015A016B017C01BF5F79
|
:100670000F931F93CF93DF93EC01062F142FF0DE1F
|
||||||
:10068000C7CF8090343C9090353CA090363CB090E1
|
:1006800082E084DD802F82DD812F80DDCE01DF914D
|
||||||
:10069000373CC12CD12C7601B0E29401A501B60102
|
:10069000CF911F910F9137CE1F93CF93DF93EC0132
|
||||||
:1006A000C701A0E0DBD409F48BCF217030E040E03B
|
:1006A000162FDEDE83E072DD812F70DD80E06EDDEF
|
||||||
:1006B00050E060E070E080E090E0D0D4E1F0D0E085
|
:1006B000182FCE0128DE812FDF91CF911F91089551
|
||||||
:1006C000C0E0B03370F4CB2FC695C695C695F0E266
|
:1006C000CF92DF92EF92FF921F93CF93DF93EC01D3
|
||||||
:1006D000CF9FE0011124C05FDB4F8B2F8770C80FC5
|
:1006D000162F262F40EE6FE08DDF8FB7F894C09075
|
||||||
:1006E000D11D8B2F90E02881885D934CFC01208BDD
|
:1006E000103CD090113CE090123CF090133C8FBF36
|
||||||
:1006F0008881887F88839401A501B601C70101E044
|
:1006F0008AE0C80ED11CE11CF11C2FB7F894809140
|
||||||
:1007000092D449015A016B017C01BF5FC6CFDF91D2
|
:10070000103C9091113CA091123CB091133C2FBF32
|
||||||
:10071000CF910F91FF90EF90DF90CF90BF90AF906F
|
:100710008C159D05AE05BF0590F46EE0CE01BCDFE3
|
||||||
:100720009F908F907F906F900895FF920F931F93EB
|
:10072000807E1813EACF81E091E0892790E0DF9185
|
||||||
:10073000CF93DF93EC01F62E042F122F2CDF85E0F0
|
:10073000CF911F91FF90EF90DF90CF90089580E0D0
|
||||||
:1007400030DD8F2D2EDD802F2CDD812F2ADDCE0197
|
:10074000F3CF0F931F93CF93DF93EC0160E8B8DFF3
|
||||||
:10075000DF91CF911F910F91FF90D9CDDF92EF9252
|
:100750008C01892B61F440E06AE2CE0189DF40E937
|
||||||
:10076000FF920F931F93CF93DF937C01C62FD42E5C
|
:1007600069E2CE0185DF42E868E2CE0181DFC8019F
|
||||||
:10077000152F022F10DF82E014DD8C2F12DDCD2D1E
|
:10077000DF91CF911F910F91089560E0A1CF7F92FB
|
||||||
:10078000D12F0C0F1D2F111DC017D10719F0899102
|
:100780008F929F92AF92BF92CF92DF92EF92FF92A1
|
||||||
:1007900008DDFACFC701DF91CF911F910F91FF9034
|
:100790000F931F93CF93DF93CDB7DEB7A297CDBF53
|
||||||
:1007A000EF90DF90B4CD0F931F93CF93DF93EC01C5
|
:1007A000DEBF8C015DDE80ECF1DCC801ACDD6AE00F
|
||||||
:1007B000062F142FF0DE82E0F4DC802FF2DC812F94
|
:1007B00070E080E090E07BDDCE0101967C018EE070
|
||||||
:1007C000F0DCCE01DF91CF911F910F91A0CDDF9290
|
:1007C000F70111928A95E9F72EE0A70160E3C801CD
|
||||||
:1007D000EF92FF920F931F93CF93DF937C01C62F6D
|
:1007D0002ADF2EE0A70160E4C80125DF2EE0A70193
|
||||||
:1007E000D42E152F022FD7DE83E0DBDC8C2FD9DC53
|
:1007E00060E5C80120DF40E060E6C80141DF40E08D
|
||||||
:1007F000CD2DD12F0C0F1D2F111DC017D10721F0AA
|
:1007F00060E7C8013DDF43EA6BE2C80139DF24E06E
|
||||||
:1008000080E0CFDC8993F9CFC701DF91CF911F91B1
|
:1008000047E660E6C801F6DE21E047E660E7C8019A
|
||||||
:100810000F91FF90EF90DF907ACD1F93CF93DF93EE
|
:10081000F1DE8CE0ECE3FFE4DE011F9601900D9227
|
||||||
:10082000EC01162FB8DE83E0BCDC812FBADC80E05F
|
:100820008A95E1F74E01FFE08F0E911CB12CA12CAF
|
||||||
:10083000B8DC182FCE016BDD812FDF91CF911F9196
|
:1008300028E0722EF401E190F1904F0160E8C801C8
|
||||||
:1008400008954F925F926F927F928F929F92AF9294
|
:100840003FDF6C01892B09F065C0F2E0EF16F1047F
|
||||||
:10085000BF92CF92DF92EF92FF921F93CF93DF93DD
|
:1008500009F472C058F4E114F10409F473C0EA9485
|
||||||
:10086000CDB7DEB72D97CDBFDEBF10911C3C193040
|
:10086000EF2889F0CC24C394D12C54C0E4E0EE16D8
|
||||||
:1008700008F061C04091183C5091193C60911A3CBD
|
:10087000F10409F465C008F461C085E0E816F104EC
|
||||||
:1008800070911B3C6A017B01CC24F7FCC394DD24EE
|
:1008800089F768E101C064E091E0A916B10409F0BC
|
||||||
:10089000EE24FF244A015B0188249924AA2420E441
|
:100890005BC01E8E1D8E7C8E1B8E24E0AE01455EDD
|
||||||
:1008A000B22244244A94542C642CBFE17B2EC11004
|
:1008A0005F4FC801C0DEEFEFAE1ABE0AF6E0AF162A
|
||||||
:1008B00006C044244A94A7E05A2E612C712C44218E
|
:1008B000B10409F0BFCF1F8E18A281E090E089A398
|
||||||
:1008C000552166217721CC20C9F14C835B83AB0194
|
:1008C0009AA37E018FE1E80EF11C4E0193E2890E9E
|
||||||
:1008D00066277727242F23702860342F330F330F98
|
:1008D000911C98E0792EF701A190B1907F0160E81A
|
||||||
:1008E000330F307E232B2A83F5E056954795FA95F2
|
:1008E000C801EEDE6C01892BA9F41E8E1D8E7C8E54
|
||||||
:1008F000E1F74983212F89288A288B2809F0206471
|
:1008F0001B8EA114B10469F1AA94AB2809F0B2CF00
|
||||||
:100900007C012D83412F50E060E27CE3CE0106960E
|
:1009000064E224E0AE01455E5F4FC8018CDE8E14C8
|
||||||
:10091000E8D425E0210FAE014F5F5F4F61E4C701CE
|
:100910009F0409F7C601A296CDBFDEBFDF91CF913C
|
||||||
:100920001DDF28E048E060E4C701FFDE60E4C701A6
|
:100920001F910F91FF90EF90DF90CF90BF90AF900D
|
||||||
:1009300074DF807789F084E090E010C09A0153E082
|
:100930009F908F907F90089568E0A6CF60E1A4CF4C
|
||||||
:10094000369527955A95E1F729834295440F407EC5
|
:1009400064E1A2CF60E0A0CF1B8E1C8E1E8E1D8E98
|
||||||
:100950004A831C821B82CECF90E080E02D96CDBFD3
|
:10095000A4CF60E2D6CF2F923F924F925F926F92D8
|
||||||
:10096000DEBFDF91CF911F91FF90EF90DF90CF908E
|
:100960007F928F929F92AF92BF92CF92DF92EF923F
|
||||||
:10097000BF90AF909F908F907F906F905F904F90BF
|
:10097000FF920F931F93CF93DF93CDB7DEB76397AB
|
||||||
:1009800008950F931F93CF93DF938C01C8E1DCE3AD
|
:10098000CDBFDEBF7C018091143C9091153C092EB7
|
||||||
:100990008091143C9091153CB0E0A0E0AF6FBF682F
|
:10099000000CAA0BBB0BAF6FBF688093003C909319
|
||||||
:1009A00088839983AA83BB8386E08C8393E09887AE
|
:1009A000013CA093023CB093033C84E08093043C60
|
||||||
:1009B00019868A871B8658DD8C876EDD8D87C80176
|
:1009B00083E08093083C81E08093093C86E080934B
|
||||||
:1009C000DF91CF911F910F913CCF9F92AF92BF9239
|
:1009C0000A3C10920B3C4BE0942E5E0184E1A80E91
|
||||||
:1009D000CF92DF92EF92FF920F931F93CF93DF930B
|
:1009D000B11C8091043C893008F08BC086E0E8E4CB
|
||||||
:1009E000CDB7DEB72597CDBFDEBF5C018B01000F11
|
:1009E000FFE4DE011E9601900D928A95E1F73E012B
|
||||||
:1009F000111F000F111FF801E35DFC4A25E0AE0155
|
:1009F000EEE06E0E711CF301C190D1903F018601B3
|
||||||
:100A00004F5F5F4F6181E3DE8A81C98098E0C99EB4
|
:100A0000000F111FF801EC0DFD1DE25BF04B808023
|
||||||
:100A100060011124282F30E055E0359527955A952F
|
:100A1000682DC70141DE83FD93C07090043CF8E06F
|
||||||
:100A2000E1F7C20ED31E0D2C000CEE08FF0883FF69
|
:100A2000F71508F466C08091003C9091013CA091BC
|
||||||
:100A300020C092E0CC0CDD1CEE1CFF1C9A95D1F777
|
:100A3000023CB091033CAC01BD01442777FD4395D6
|
||||||
:100A40008370C80ED11CE11CF11CFE2CED2CDC2C9B
|
:100A4000552766277727242FAC01BD01442755275A
|
||||||
:100A5000CC248B81C80ED11CE11CF11CFE2CED2C8A
|
:100A50006627707422242A94322C422CFFE15F2EE8
|
||||||
:100A6000DC2CCC248C81C80ED11CE11CF11C6894B8
|
:100A6000211106C022242A94E7E03E2E412C512C6D
|
||||||
:100A7000F7F88D818F70982EE8E081E090E0E9151D
|
:100A700082219321A421B521222309F453C08C8320
|
||||||
:100A800028F1F801E35DFC4A6081C501C6DE83FF01
|
:100A80009B83CD01AA27BB27282F220F220F220FDD
|
||||||
:100A900002C06894F6F8C092183CD092193CE092DB
|
:100A9000207E382F33703860232B2A8335E09695DB
|
||||||
:100AA0001A3CF0921B3C90921C3C035D1C4A292D81
|
:100AA00087953A95E1F78983872D452B462B472B70
|
||||||
:100AB00040E25CE3F8016281C50189DE20E0F801D3
|
:100AB00009F080648D83472D50E068E07CE3CE012F
|
||||||
:100AC00043816CE2C50131DE90E080E02596CDBF28
|
:100AC000069631D225E0270D0C0D1D1DF801E25BC5
|
||||||
:100AD000DEBFDF91CF911F910F91FF90EF90DF90DC
|
:100AD000F04BAE014F5F5F4F6181C701A4DD28E09D
|
||||||
:100AE000CF90BF90AF909F9008951F93CF93DF93C7
|
:100AE00048E0682DC70186DD682DC701D5DD807718
|
||||||
:100AF000EC0151DD80EA55DB80E053DB182FCE019D
|
:100AF00019F09A9491106DCF6396CDBFDEBFDF9150
|
||||||
:100B000006DC70E060E010FD04C011FF07C061E08A
|
:100B0000CF911F910F91FF90EF90DF90CF90BF900A
|
||||||
:100B100070E0CE01DF91CF911F9157CF85E090E03B
|
:100B1000AF909F908F907F906F905F904F903F909D
|
||||||
:100B2000DF91CF911F910895CF92DF92EF92FF92C4
|
:100B20002F9008959C0193E0369527959A95E1F7CB
|
||||||
:100B30001F93CF93DF93EC01162F262F40EE6FE02B
|
:100B300029838295880F807E8A831C821B82B4CF92
|
||||||
:100B4000F4DD8FB7F894C090103CD090113CE09049
|
:100B40006A147B0409F057CFD4CF1F920F920FB6CF
|
||||||
:100B5000123CF090133C8FBF8AE0C80ED11CE11C00
|
:100B50000F9211248F939F93AF93BF938091103C7A
|
||||||
:100B6000F11C2FB7F8948091103C9091113CA0910A
|
:100B60009091113CA091123CB091133C0196A11DB3
|
||||||
:100B7000123CB091133C2FBF8C159D05AE05BF05EF
|
:100B7000B11D8093103C9093113CA093123CB09314
|
||||||
:100B800090F46EE0CE0149DE807E1813EACF81E05A
|
:100B8000133C81E08093A60ABF91AF919F918F9112
|
||||||
:100B900091E0892790E0DF91CF911F91FF90EF9036
|
:100B90000F900FBE0F901F9018951F93CF93DF9368
|
||||||
:100BA000DF90CF90089580E0F3CF0F931F93CF9302
|
:100BA000EC01162FABDA1883812F96DACE01DF9194
|
||||||
:100BB000DF93EC0160E8B8DF8C01892B61F440E041
|
:100BB000CF911F91A8CBEDE7FCE384E0818381E333
|
||||||
:100BC0006AE2CE01F0DD40E969E2CE01ECDD42E807
|
:100BC0008083EEE3FCE31582148262E082E89CE31A
|
||||||
:100BD00068E2CE01E8DDC801DF91CF911F910F914E
|
:100BD000E4DF63E081E89CE3E0DF68E080E89CE339
|
||||||
:100BE000089560E0A1CF7F928F929F92AF92BF92C3
|
:100BE000DCDF69E08FE79CE3D8CF91E088ED84BF3C
|
||||||
:100BF000CF92DF92EF92FF920F931F93CF93DF93E9
|
:100BF0009093610080910206856080930206809147
|
||||||
:100C0000CDB7DEB7A297CDBFDEBF8C01C4DC80ECD0
|
:100C00000006816080930006809102068F7C8065DB
|
||||||
:100C1000C8DAC8017CDB56DBCE0101967C018EE090
|
:100C1000809302061092E20582E08093E4059093AF
|
||||||
:100C2000F70111928A95E9F72EE0A70160E3C80168
|
:100C2000030A8EEF8093270A8093260A80E8809338
|
||||||
:100C300095DD2EE0A70160E4C80190DD2EE0A7015C
|
:100C30002D0A80932B0A8093290A80932C0A809393
|
||||||
:100C400060E5C8018BDD40E060E6C801ACDD40E056
|
:100C40002A0A8093280A89E08093000A87E080932B
|
||||||
:100C500060E7C801A8DD43EA6BE2C801A4DD24E037
|
:100C5000E505E0E8FAE0C7E09EEF80E8D5E0C18373
|
||||||
:100C600047E660E6C80161DD21E047E660E7C801CC
|
:100C600094878587D0837096E03C2AE0F207B9F735
|
||||||
:100C70005CDD8CE0E8EFF2E5DE011F9601900D925D
|
:100C70001092A10A8FE39FE18093AC0A9093AD0A92
|
||||||
:100C80008A95E1F74E01FFE08F0E911CB12CA12C4B
|
:100C80008091A50A81608093A50A1092A00A8091A4
|
||||||
:100C900028E0722EF401E190F1904F0160E8C80164
|
:100C9000A00A81608093A00A789430DA6AE070E05C
|
||||||
:100CA00043DF6C01892B09F065C0F2E0EF16F10417
|
:100CA00080E090E004DB85E190E08093163C909337
|
||||||
:100CB00009F472C058F4E114F10409F473C0EA9421
|
:100CB000173C81E08093183C8093193C80931A3C48
|
||||||
:100CC000EF2889F0CC24C394D12C54C0E4E0EE1674
|
:100CC00024E130E020931B3C30931C3C80931D3C7E
|
||||||
:100CD000F10409F465C008F461C085E0E816F10488
|
:100CD00080931E3C92E090931F3C23E130E02093F0
|
||||||
:100CE00089F768E101C064E091E0A916B10409F058
|
:100CE000203C3093213C8093223C8093233C93E032
|
||||||
:100CF0005BC01E8E1D8E7C8E1B8E24E0AE01455E79
|
:100CF0009093243C22E130E02093253C3093263C25
|
||||||
:100D00005F4FC8012BDDEFEFAE1ABE0AF6E0AF165B
|
:100D00008093273C8093283C94E09093293C21E1F8
|
||||||
:100D1000B10409F0BFCF1F8E18A281E090E089A333
|
:100D100030E020932A3C30932B3C80932C3C8093F2
|
||||||
:100D20009AA37E018FE1E80EF11C4E0193E2890E39
|
:100D20002D3CD0932E3C20E130E020932F3C30939B
|
||||||
:100D3000911C98E0792EF701A190B1907F0160E8B5
|
:100D3000303C8093313C8093323C96E09093333C3E
|
||||||
:100D4000C801F2DE6C01892BA9F41E8E1D8E7C8EEB
|
:100D40002FE030E02093343C3093353C8093363CA8
|
||||||
:100D50001B8EA114B10469F1AA94AB2809F0B2CF9B
|
:100D50008093373CC093383C2EE030E02093393C00
|
||||||
:100D600064E224E0AE01455E5F4FC801F7DC8E14FB
|
:100D600030933A3C80933B3C80933C3C88E08093BA
|
||||||
:100D70009F0409F7C601A296CDBFDEBFDF91CF91D8
|
:100D70003D3C80916000806890E028ED24BF809326
|
||||||
:100D80001F910F91FF90EF90DF90CF90BF90AF90A9
|
:100D8000600082E89CE3FBDC82E89CE3DADC82E83A
|
||||||
:100D90009F908F907F90089568E0A6CF60E1A4CFE8
|
:100D90009CE3F3DC81E89CE3F2DC81E89CE3D1DCBA
|
||||||
:100DA00064E1A2CF60E0A0CF1B8E1C8E1E8E1D8E34
|
:100DA00081E89CE3EADC80E89CE3E9DC80E89CE302
|
||||||
:100DB000A4CF60E2D6CF1F920F920FB60F921124EC
|
:100DB000C8DC80E89CE3E1DC8FE79CE3E0DC8FE7C4
|
||||||
:100DC0008F939F93AF93BF938091103C9091113C70
|
:100DC0009CE3BFDC8FE79CE3D8DCC6E1DCE38EE389
|
||||||
:100DD000A091123CB091133C0196A11DB11D8093CE
|
:100DD000E82E8CE3F82EEC16FD0651F0188119323E
|
||||||
:100DE000103C9093113CA093123CB093133C81E0D3
|
:100DE00028F4812F79D960E0812FDAD92596F3CFC5
|
||||||
:100DF0008093A60ABF91AF919F918F910F900FBEE4
|
:100DF000F0910411809106117091081160910A110F
|
||||||
:100E00000F901F9018951F93CF93DF93EC01162F2F
|
:100E000090910C11E091031120910511509107115F
|
||||||
:100E100080D91883812F6BD9CE01DF91CF911F919B
|
:100E10004091091130910B11880F811D880F8F2788
|
||||||
:100E200076CAE7E6FCE384E0818381E38083E8E23D
|
:100E2000770F711D770F711D8727629560FB67959E
|
||||||
:100E3000FCE31582148262E08CE69CE3E4DF63E06D
|
:100E300067F9862792959827822F880F811D880F42
|
||||||
:100E40008BE69CE3E0DF68E08AE69CE3DCDF69E0B8
|
:100E40008E27252F220F211D220F211D8227242FBF
|
||||||
:100E500089E69CE3D8CF91E088ED84BF9093610050
|
:100E5000229520FB279527F98227232F2295822789
|
||||||
:100E60008091020685608093020680910006816071
|
:100E60008093143C9093153C82E89CE374DD81E808
|
||||||
:100E700080930006809102068F7C80658093020635
|
:100E70009CE371DD80E89CE36EDD8FE79CE36BDD36
|
||||||
:100E80001092E20582E08093E4059093030A8EEFCE
|
:100E8000C0E0D0E082E89CE366DD68EE73E080E0DD
|
||||||
:100E90008093270A8093260A80E880932D0A809306
|
:100E900090E00DDA2097B1F3B3D8F4CF38D0A59F06
|
||||||
:100EA0002B0A8093290A80932C0A80932A0A809324
|
:100EA000900DB49F900DA49F800D911D1124089565
|
||||||
:100EB000280A89E08093000A87E08093E505E0E84E
|
:100EB00097FD1094002E083098F00850232F342FFF
|
||||||
:100EC000FAE037E02EEF90E885E0318324879587BC
|
:100EC000452F562F672F782F892F912DF4CF15940A
|
||||||
:100ED00080837096E03C4AE0F407B9F71092A10ACB
|
:100ED0009795879577956795579547953795279572
|
||||||
:100EE0008FE39FE18093AC0A9093AD0A8091A50AAD
|
:100EE0000A95AAF71124002D08950024A7FD009467
|
||||||
:100EF00081608093A50A1092A00A8091A00A816067
|
:100EF0002A173005400550056005700580059005EE
|
||||||
:100F00008093A00A789405D980916000806890E071
|
:100F00000895EE0FFF1F0590F491E02D0994A29F24
|
||||||
:100F100028ED24BF809360008CE69CE364DE8CE6C1
|
:100F1000B001B39FC001A39F01D0B29F700D811D8E
|
||||||
:100F20009CE343DE8CE69CE35CDE8BE69CE35BDECD
|
:100F20001124911D0895FB01DC0102C001900D9276
|
||||||
:100F30008BE69CE33ADE8BE69CE353DE8AE69CE399
|
:0C0F300041505040D8F70895F894FFCFCE
|
||||||
:100F400052DE8AE69CE331DE8AE69CE34ADE89E6ED
|
:100F3C000000010002000300040005000000010095
|
||||||
:100F50009CE349DE89E69CE328DE89E69CE341DEEA
|
:100F4C00020030313640414650515600000000003E
|
||||||
:100F600083DAC82F99DA9C2F8093143C9093153C18
|
:100F5C00000000000000000005010101010101007A
|
||||||
:100F70008CE69CE306DD8BE69CE303DD8AE69CE3DE
|
:100F6C000000000000000000000000000000000075
|
||||||
:100F800000DD89E69CE3FDDCC0E0D0E08CE69CE37C
|
:100F7C00000203000001020304050607000102033E
|
||||||
:100F9000ACDD892B51F48BE69CE353DC8AE69CE3C1
|
:100F8C000405000102030405060700010203040521
|
||||||
:100FA00050DC89E69CE34DDC8FDA8BE69CE39DDD2B
|
:100F9C00060700010203000102030405060000001D
|
||||||
:100FB000892B51F48CE69CE344DC8AE69CE341DC1B
|
:100FAC000000000000010101010101020202020225
|
||||||
:100FC00089E69CE33EDC80DA8AE69CE38EDD892BB1
|
:100FBC0002020203030303030303030404040405F2
|
||||||
:100FD00051F48CE69CE335DC8BE69CE332DC89E65D
|
:100FCC0005050505050501020408102040800102F5
|
||||||
:100FE0009CE32FDC71DA89E69CE37FDD892B51F4E9
|
:100FDC0004081020010204081020408001020408BB
|
||||||
:100FF0008CE69CE326DC8BE69CE323DC8AE69CE320
|
:0F0FEC0010204080010204080102040810204078
|
||||||
:1010000020DC62DA5FD9209709F2FAD7BFCF38D057
|
|
||||||
:10101000A59F900DB49F900DA49F800D911D11244C
|
|
||||||
:10102000089597FD1094002E083098F00850232F53
|
|
||||||
:10103000342F452F562F672F782F892F912DF4CFDE
|
|
||||||
:101040001594979587957795679557954795379513
|
|
||||||
:1010500027950A95AAF71124002D08950024A7FDCD
|
|
||||||
:1010600000942A173005400550056005700580057D
|
|
||||||
:1010700090050895EE0FFF1F0590F491E02D09945F
|
|
||||||
:10108000A29FB001B39FC001A39F01D0B29F700D7A
|
|
||||||
:10109000811D1124911D08950F931F93CF93DF930A
|
|
||||||
:1010A0008230910510F482E090E0E091723CF09182
|
|
||||||
:1010B000733C30E020E0B0E0A0E0309799F42115D7
|
|
||||||
:1010C000310509F44AC0281B390B24303105D8F505
|
|
||||||
:1010D0008A819B816115710589F1FB01828393836C
|
|
||||||
:1010E000FE0111C0408151810281138148175907C7
|
|
||||||
:1010F000E0F04817590799F4109761F012960C9395
|
|
||||||
:10110000129713961C933296CF01DF91CF911F91C6
|
|
||||||
:101110000F9108950093723C1093733CF4CF211506
|
|
||||||
:10112000310551F04217530738F0A901DB019A014C
|
|
||||||
:10113000BD01DF01F801C1CFEF01F9CF8093723C0F
|
|
||||||
:101140009093733CCDCFFE01E20FF31F81939193F7
|
|
||||||
:101150002250310928833983D7CF2091703C3091B8
|
|
||||||
:10116000713C232B41F42091093C30910A3C20939F
|
|
||||||
:10117000703C3093713C2091073C3091083C211524
|
|
||||||
:10118000310541F42DB73EB740910B3C50910C3CDA
|
|
||||||
:10119000241B350BE091703CF091713CE217F30792
|
|
||||||
:1011A000A0F42E1B3F0B2817390778F0AC014E5FD7
|
|
||||||
:1011B0005F4F2417350748F04E0F5F1F4093703C78
|
|
||||||
:1011C0005093713C819391939FCFF0E0E0E09CCFEE
|
|
||||||
:1011D000CF93DF930097E9F0FC01329712821382DC
|
|
||||||
:1011E000A091723CB091733CED0130E020E010978B
|
|
||||||
:1011F000A1F420813181820F931F2091703C3091A6
|
|
||||||
:10120000713C2817390709F061C0E093703CF093F6
|
|
||||||
:10121000713CDF91CF910895EA01CE17DF07E8F521
|
|
||||||
:101220004A815B819E0141155105B1F7E901EA83CD
|
|
||||||
:10123000FB8349915991C40FD51FEC17FD0761F449
|
|
||||||
:10124000808191810296840F951FE901888399839B
|
|
||||||
:10125000828193818A839B83F0E0E0E012968D91F6
|
|
||||||
:101260009C9113970097B9F52D913C911197CD0161
|
|
||||||
:101270000296820F931F2091703C3091713C281789
|
|
||||||
:10128000390739F6309751F51092723C1092733C41
|
|
||||||
:10129000A093703CB093713CBCCFC283D383408198
|
|
||||||
:1012A0005181840F951FC817D90761F44E5F5F4FB6
|
|
||||||
:1012B00088819981480F591F408351838A819B817E
|
|
||||||
:1012C000828393832115310509F0B0CFE093723CFE
|
|
||||||
:1012D000F093733C9ECFFD01DC01C0CF12821382DC
|
|
||||||
:1012E000D7CFFB01DC0102C001900D92415050406C
|
|
||||||
:0812F000D8F70895F894FFCF30
|
|
||||||
:1012F80000000100020003000400050000000000D7
|
|
||||||
:1013080000000000000000000005010101010101CA
|
|
||||||
:1013180000000000000000000000000000000000C5
|
|
||||||
:10132800000002030060616601707176020001022C
|
|
||||||
:101338000304050607000102030405000102030473
|
|
||||||
:101348000506070001020304050607000102030061
|
|
||||||
:10135800010203040506000000000000000001016E
|
|
||||||
:101368000101010102020202020202020303030355
|
|
||||||
:101378000303030304040404050505050505050125
|
|
||||||
:101388000204081020408001020408102001020411
|
|
||||||
:101398000810204080010204081020408001020447
|
|
||||||
:0813A8000801020408102040B6
|
|
||||||
:0E13B000320000000000000000743C800000CD
|
|
||||||
:00000001FF
|
:00000001FF
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,13 @@
|
|||||||
|
|
||||||
#include <SPI.h>;
|
#include <SPI.h>;
|
||||||
#include <mcp2515.h>;
|
#include <mcp2515.h>;
|
||||||
|
|
||||||
|
|
||||||
struct can_frame _frame;
|
struct can_frame _frame;
|
||||||
MCP2515 mcp2515(PIN_PD4);
|
MCP2515 mcp2515(PIN_PD4);
|
||||||
const byte SoftwareVersionHigh = 3;
|
const byte SoftwareVersionHigh = 4;
|
||||||
const byte SoftwareVersionLow = 0;
|
const byte SoftwareVersionLow = 0;
|
||||||
const byte HardwareVersionHigh = 5;
|
const byte HardwareVersionHigh = 2;
|
||||||
const byte HardwareVersionLow = 0;
|
const byte HardwareVersionLow = 0;
|
||||||
|
|
||||||
typedef struct PinState
|
typedef struct PinState
|
||||||
@@ -33,30 +34,29 @@ int16_t myDeviceId;
|
|||||||
void setup() {
|
void setup() {
|
||||||
SPI.begin();
|
SPI.begin();
|
||||||
|
|
||||||
|
|
||||||
MeyPins[0] = PinState();
|
MeyPins[0] = PinState();
|
||||||
MeyPins[0].Init(PIN_PD0, (byte) 1);
|
MeyPins[0].Init(PIN_PC7, (byte) 1);
|
||||||
|
|
||||||
MeyPins[1] = PinState();
|
MeyPins[1] = PinState();
|
||||||
MeyPins[1].Init(PIN_PD2, (byte) 2);
|
MeyPins[1].Init(PIN_PD0, (byte) 2);
|
||||||
|
|
||||||
MeyPins[2] = PinState();
|
MeyPins[2] = PinState();
|
||||||
MeyPins[2].Init(PIN_PD5, (byte) 3);
|
MeyPins[2].Init(PIN_PD1, (byte) 3);
|
||||||
|
|
||||||
MeyPins[3] = PinState();
|
MeyPins[3] = PinState();
|
||||||
MeyPins[3].Init(PIN_PD7, (byte) 4);
|
MeyPins[3].Init(PIN_PD2, (byte) 4);
|
||||||
|
|
||||||
MeyPins[4] = PinState();
|
MeyPins[4] = PinState();
|
||||||
MeyPins[4].Init(PIN_PC7, (byte) 5);
|
MeyPins[4].Init(PIN_PD6, (byte) 5);
|
||||||
|
|
||||||
MeyPins[5] = PinState();
|
MeyPins[5] = PinState();
|
||||||
MeyPins[5].Init(PIN_PD1, (byte) 6);
|
MeyPins[5].Init(PIN_PD5, (byte) 6);
|
||||||
|
|
||||||
MeyPins[6] = PinState();
|
MeyPins[6] = PinState();
|
||||||
MeyPins[6].Init(PIN_PD3, (byte) 7);
|
MeyPins[6].Init(PIN_PD4, (byte) 7);
|
||||||
|
|
||||||
MeyPins[7] = PinState();
|
MeyPins[7] = PinState();
|
||||||
MeyPins[7].Init(PIN_PD6, (byte) 8);
|
MeyPins[7].Init(PIN_PD3, (byte) 8);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -80,6 +80,9 @@ void setup() {
|
|||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
delay(1000);
|
||||||
|
SendSerialPackage();
|
||||||
|
|
||||||
for (int i = 0; i <= PinCount - 1; i++)
|
for (int i = 0; i <= PinCount - 1; i++)
|
||||||
{
|
{
|
||||||
if (CheckPinStatus(&MeyPins[i]))
|
if (CheckPinStatus(&MeyPins[i]))
|
||||||
@@ -88,10 +91,8 @@ void loop()
|
|||||||
|
|
||||||
if (mcp2515.readMessage(&_frame) == MCP2515::ERROR_OK)
|
if (mcp2515.readMessage(&_frame) == MCP2515::ERROR_OK)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (GetDeviceId(_frame.can_id) == GetMyDeviceId())
|
if (GetDeviceId(_frame.can_id) == GetMyDeviceId())
|
||||||
{
|
{
|
||||||
|
|
||||||
int meyPinId = _frame.data[0];
|
int meyPinId = _frame.data[0];
|
||||||
bool state = _frame.data[1] > 0;
|
bool state = _frame.data[1] > 0;
|
||||||
|
|
||||||
@@ -116,7 +117,6 @@ void loop()
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay(20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ void SendSerialPackage()
|
|||||||
_frame.data[1] = SoftwareVersionLow;
|
_frame.data[1] = SoftwareVersionLow;
|
||||||
_frame.data[2] = HardwareVersionHigh;
|
_frame.data[2] = HardwareVersionHigh;
|
||||||
_frame.data[3] = HardwareVersionLow;
|
_frame.data[3] = HardwareVersionLow;
|
||||||
mcp2515.sendMessage(MCP2515::TXB1, &_frame);
|
DoSendCanPkg(&mcp2515, &_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -139,9 +139,19 @@ void SendSwitchedTriggeredCanPackage(byte pinId, int state)
|
|||||||
_frame.can_dlc = 2;
|
_frame.can_dlc = 2;
|
||||||
_frame.data[0] = pinId;
|
_frame.data[0] = pinId;
|
||||||
_frame.data[1] = state;
|
_frame.data[1] = state;
|
||||||
mcp2515.sendMessage(MCP2515::TXB1, &_frame);
|
DoSendCanPkg(&mcp2515, &_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DoSendCanPkg(MCP2515 *interface, can_frame *frame)
|
||||||
|
{
|
||||||
|
// ToggleDebug();
|
||||||
|
byte cnt = 0;
|
||||||
|
while (interface->sendMessage(&_frame)) {
|
||||||
|
cnt++;
|
||||||
|
if (cnt > 10) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void SendDoTriggerSwitchCanPackage(uint32_t targetCanId, byte pinId, byte state)
|
void SendDoTriggerSwitchCanPackage(uint32_t targetCanId, byte pinId, byte state)
|
||||||
{
|
{
|
||||||
@@ -151,7 +161,7 @@ void SendDoTriggerSwitchCanPackage(uint32_t targetCanId, byte pinId, byte state)
|
|||||||
_frame.data[1] = (targetCanId & 0xFF00) >> 8;
|
_frame.data[1] = (targetCanId & 0xFF00) >> 8;
|
||||||
_frame.data[2] = pinId;
|
_frame.data[2] = pinId;
|
||||||
_frame.data[3] = state;
|
_frame.data[3] = state;
|
||||||
mcp2515.sendMessage(MCP2515::TXB1, &_frame);
|
DoSendCanPkg(&mcp2515, &_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadPin(PinState * state)
|
bool ReadPin(PinState * state)
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
BIN
Switch1/Switch1-backups/Switch1-2023-06-04_083455.zip
Normal file
BIN
Switch1/Switch1-backups/Switch1-2023-06-04_083455.zip
Normal file
Binary file not shown.
BIN
Switch1/Switch1-backups/Switch1-2023-07-03_095513.zip
Normal file
BIN
Switch1/Switch1-backups/Switch1-2023-07-03_095513.zip
Normal file
Binary file not shown.
@@ -466,7 +466,7 @@
|
|||||||
(property "Sheetname" "")
|
(property "Sheetname" "")
|
||||||
(path "/ba8b88eb-80e4-4fa1-9e77-db96a7193967")
|
(path "/ba8b88eb-80e4-4fa1-9e77-db96a7193967")
|
||||||
(attr through_hole)
|
(attr through_hole)
|
||||||
(fp_text reference "J10" (at -0.114 2.616 180) (layer "F.SilkS")
|
(fp_text reference "IN-" (at -0.114 2.616 180) (layer "F.SilkS")
|
||||||
(effects (font (size 1 1) (thickness 0.15)))
|
(effects (font (size 1 1) (thickness 0.15)))
|
||||||
(tstamp 5681b125-1ab3-4762-b889-d34158dea436)
|
(tstamp 5681b125-1ab3-4762-b889-d34158dea436)
|
||||||
)
|
)
|
||||||
@@ -1955,7 +1955,7 @@
|
|||||||
(property "Sheetname" "")
|
(property "Sheetname" "")
|
||||||
(path "/adf496a2-b1d1-4408-a764-eaacdf8ff9f4")
|
(path "/adf496a2-b1d1-4408-a764-eaacdf8ff9f4")
|
||||||
(attr through_hole)
|
(attr through_hole)
|
||||||
(fp_text reference "J11" (at 0 -2.54) (layer "F.SilkS")
|
(fp_text reference "OUT-" (at 0 -2.54) (layer "F.SilkS")
|
||||||
(effects (font (size 1 1) (thickness 0.15)))
|
(effects (font (size 1 1) (thickness 0.15)))
|
||||||
(tstamp a4e94926-228e-4e5b-81fe-35294b63372e)
|
(tstamp a4e94926-228e-4e5b-81fe-35294b63372e)
|
||||||
)
|
)
|
||||||
@@ -2881,7 +2881,7 @@
|
|||||||
(property "Sheetname" "")
|
(property "Sheetname" "")
|
||||||
(path "/130b8d97-84bf-49f0-8f83-80a1750f718c")
|
(path "/130b8d97-84bf-49f0-8f83-80a1750f718c")
|
||||||
(attr through_hole)
|
(attr through_hole)
|
||||||
(fp_text reference "J12" (at 0.762 -2.54) (layer "F.SilkS")
|
(fp_text reference "OUT+" (at 0.762 -2.54) (layer "F.SilkS")
|
||||||
(effects (font (size 1 1) (thickness 0.15)))
|
(effects (font (size 1 1) (thickness 0.15)))
|
||||||
(tstamp 5f517e43-64b4-4d95-9b9c-e24038b26175)
|
(tstamp 5f517e43-64b4-4d95-9b9c-e24038b26175)
|
||||||
)
|
)
|
||||||
@@ -3068,7 +3068,7 @@
|
|||||||
(property "Sheetname" "")
|
(property "Sheetname" "")
|
||||||
(path "/a236a182-ca21-4f11-8942-7dd1facb015f")
|
(path "/a236a182-ca21-4f11-8942-7dd1facb015f")
|
||||||
(attr through_hole)
|
(attr through_hole)
|
||||||
(fp_text reference "J9" (at -0.098 2.736) (layer "F.SilkS")
|
(fp_text reference "IN+" (at -0.098 2.736) (layer "F.SilkS")
|
||||||
(effects (font (size 1 1) (thickness 0.15)))
|
(effects (font (size 1 1) (thickness 0.15)))
|
||||||
(tstamp 5154fc01-cd41-4624-b9b4-9bd3a602fede)
|
(tstamp 5154fc01-cd41-4624-b9b4-9bd3a602fede)
|
||||||
)
|
)
|
||||||
@@ -3302,7 +3302,7 @@
|
|||||||
(property "Sheetname" "")
|
(property "Sheetname" "")
|
||||||
(path "/366377f0-a55b-44a1-a28b-40d54f0e0078")
|
(path "/366377f0-a55b-44a1-a28b-40d54f0e0078")
|
||||||
(attr through_hole)
|
(attr through_hole)
|
||||||
(fp_text reference "J13" (at 1.27 -2.33) (layer "F.SilkS")
|
(fp_text reference "5V On/Off" (at 1.27 -2.33) (layer "F.SilkS")
|
||||||
(effects (font (size 1 1) (thickness 0.15)))
|
(effects (font (size 1 1) (thickness 0.15)))
|
||||||
(tstamp b0832c13-4191-4709-be8c-9d4cf865d6e3)
|
(tstamp b0832c13-4191-4709-be8c-9d4cf865d6e3)
|
||||||
)
|
)
|
||||||
@@ -4144,6 +4144,9 @@
|
|||||||
(gr_text "1" (at 204.774326 77.266326) (layer "F.SilkS") (tstamp 307ea962-06e6-4965-b781-4ac960686bf1)
|
(gr_text "1" (at 204.774326 77.266326) (layer "F.SilkS") (tstamp 307ea962-06e6-4965-b781-4ac960686bf1)
|
||||||
(effects (font (size 1 1) (thickness 0.15)))
|
(effects (font (size 1 1) (thickness 0.15)))
|
||||||
)
|
)
|
||||||
|
(gr_text "UPDI" (at 195.58 56.134 90) (layer "F.SilkS") (tstamp 3b6d6bb7-d0e7-4500-a5b2-d6ec3609e7b5)
|
||||||
|
(effects (font (size 1 1) (thickness 0.15)))
|
||||||
|
)
|
||||||
(gr_text "H" (at 248.666 129.716) (layer "F.SilkS") (tstamp 3e9ed8b8-af63-44fc-a471-6d5f30734a97)
|
(gr_text "H" (at 248.666 129.716) (layer "F.SilkS") (tstamp 3e9ed8b8-af63-44fc-a471-6d5f30734a97)
|
||||||
(effects (font (size 1 1) (thickness 0.15)))
|
(effects (font (size 1 1) (thickness 0.15)))
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user