update OSC Devices on every oscmessage with all states

save states to file, to recover on restart
This commit is contained in:
hennieliminator 2013-01-10 15:06:30 +01:00
parent 0dacc9ee59
commit 6dcea928c1
3 changed files with 56 additions and 16 deletions

View File

@ -2,9 +2,9 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="72d93b4a-de8e-43f1-9d4b-34713e827c14" name="Default" comment="">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/states.json" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app.js" afterPath="$PROJECT_DIR$/app.js" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/oscMap.json" afterPath="$PROJECT_DIR$/oscMap.json" />
</list>
<ignored path="nodeartnet.iws" />
<ignored path=".idea/workspace.xml" />
@ -70,19 +70,28 @@
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="app.js" pinned="false" current="false" current-in-tab="false">
<file leaf-file-name="app.js" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/app.js">
<provider selected="true" editor-type-id="text-editor">
<state line="73" column="5" selection-start="1984" selection-end="1984" vertical-scroll-proportion="0.0">
<state line="17" column="35" selection-start="646" selection-end="646" vertical-scroll-proportion="0.2628205">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="oscMap.json" pinned="false" current="true" current-in-tab="true">
<file leaf-file-name="states.json" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/states.json">
<provider selected="true" editor-type-id="text-editor">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="oscMap.json" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/oscMap.json">
<provider selected="true" editor-type-id="text-editor">
<state line="33" column="18" selection-start="669" selection-end="689" vertical-scroll-proportion="0.8717949">
<state line="24" column="37" selection-start="496" selection-end="496" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@ -122,8 +131,8 @@
<option value="$PROJECT_DIR$/bootstrap/css/screen.css" />
<option value="$PROJECT_DIR$/bootstrap/css/style.css" />
<option value="$PROJECT_DIR$/index.html" />
<option value="$PROJECT_DIR$/app.js" />
<option value="$PROJECT_DIR$/oscMap.json" />
<option value="$PROJECT_DIR$/app.js" />
</list>
</option>
</component>
@ -481,7 +490,11 @@
<created>1357780906470</created>
<updated>1357780906470</updated>
</task>
<option name="localTasksCounter" value="6" />
<task id="LOCAL-00006" summary="only devices in oscMap trigger dmxsend">
<created>1357781130763</created>
<updated>1357781130763</updated>
</task>
<option name="localTasksCounter" value="7" />
<servers />
</component>
<component name="ToolWindowManager">
@ -504,7 +517,7 @@
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24961948" sideWeight="0.81383854" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24961948" sideWeight="0.81383854" order="0" side_tool="false" content_ui="combo" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
@ -552,7 +565,7 @@
<option name="SHOW_VCS_ERROR_NOTIFICATIONS" value="true" />
<option name="FORCE_NON_EMPTY_COMMENT" value="false" />
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="false" />
<option name="LAST_COMMIT_MESSAGE" value="round dmx value" />
<option name="LAST_COMMIT_MESSAGE" value="only devices in oscMap trigger dmxsend" />
<option name="MAKE_NEW_CHANGELIST_ACTIVE" value="false" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
<option name="CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT" value="false" />
@ -570,6 +583,7 @@
<MESSAGE value="blub" />
<MESSAGE value="bugfix" />
<MESSAGE value="round dmx value" />
<MESSAGE value="only devices in oscMap trigger dmxsend" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
@ -645,16 +659,23 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app.js">
<entry file="file://$PROJECT_DIR$/oscMap.json">
<provider selected="true" editor-type-id="text-editor">
<state line="73" column="5" selection-start="1984" selection-end="1984" vertical-scroll-proportion="0.0">
<state line="24" column="37" selection-start="496" selection-end="496" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/oscMap.json">
<entry file="file://$PROJECT_DIR$/states.json">
<provider selected="true" editor-type-id="text-editor">
<state line="33" column="18" selection-start="669" selection-end="689" vertical-scroll-proportion="0.8717949">
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app.js">
<provider selected="true" editor-type-id="text-editor">
<state line="17" column="35" selection-start="646" selection-end="646" vertical-scroll-proportion="0.2628205">
<folding />
</state>
</provider>

View File

@ -3,6 +3,7 @@ var app = express();
var server = require('http').createServer(app), io = require('socket.io').listen(server);
var osc = require('node-osc');
var oscMap = require('./oscMap.json');
var fs = require('fs');
var host = process.argv.length > 2 ? process.argv[2] : '192.168.8.101';
var port = process.argv.length > 3 ? process.argv[3] : '9000';
@ -14,7 +15,7 @@ var dmxClient = artnetclient.createClient("192.168.8.255", 6454);
var states = [];
var states = require("./states.json");
var dmxData = new Array(512);
for(var i=0; i<512;i++) {
dmxData[i] = 0;
@ -77,6 +78,12 @@ function handleMessage(msg) {
}
// update osc devices to show the current state
// to be done in extra function (with whole states array?)
oscSender.send(chan, value);
updateDevices();
fs.writeFile("./states.json", JSON.stringify(states, null, 4));
}
function updateDevices() {
for(var chan in states) {
oscSender.send(chan, states[chan]);
console.log(chan);
}
}

12
nodeartnet/states.json Normal file
View File

@ -0,0 +1,12 @@
{
"/1/lamp1/white": 1,
"/1/lamp2/white": 0,
"/1/voucher2": 1,
"/1/wabe9/2/2": 1,
"/1/wabe9/1/1": 1,
"/1/wabe2/2/2": 1,
"/1/wabe2/1/2": 1,
"/1/wabe6/1/1": 1,
"/1/wabe5/2/1": 1,
"/1/wabe7/1/1": 1
}