Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
221 changed files
with
20,000 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License. | ||
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/ | ||
or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
# ArenaVision Tester | ||
|
||
## Requirements | ||
|
||
### node.js | ||
|
||
Server-side JavaScript. | ||
|
||
Download: http://nodejs.org/#download | ||
|
||
Installation instructions: https://github.com/joyent/node/wiki/Installation | ||
|
||
### MongoDB | ||
|
||
NoSQL database. | ||
|
||
Download: http://www.mongodb.org/downloads | ||
|
||
Installation instructions: http://www.mongodb.org/display/DOCS/Quickstart | ||
|
||
## Installation | ||
|
||
Clone the repository: | ||
|
||
git clone git://github.com/morkai/walkner-av.git | ||
|
||
or [download](https://github.com/morkai/walkner-av/zipball/master) | ||
and extract it. | ||
|
||
Go to the project's directory: | ||
|
||
$ cd walkner-av/ | ||
|
||
Install the dependencies: | ||
|
||
$ npm install | ||
|
||
## Configuration | ||
|
||
Configuration files are the JavaScript files residing in the `config/` | ||
directory. | ||
|
||
### express.js | ||
|
||
Configuration of the HTTP server [express](http://expressjs.com/). | ||
|
||
* `port` - port on which the HTTP server should listen. | ||
|
||
### mongoose.js | ||
|
||
Configuration of the _MongoDB_ client. | ||
|
||
* `uri` - connection URI in the following format: | ||
`mongodb://<host>[:<port>]/<dbname>`. | ||
|
||
### logging.js | ||
|
||
Logs configuration. Logs of the following levels will be redirected to `stdout`: | ||
`log`, `debug`, `info`, `warn` and `error`. | ||
|
||
* `productionLevels` - object defining what logs should make it through | ||
the log filter, if the `NODE_ENV` is set to `production`. | ||
|
||
* `developmentLevels` - object defining what logs should make it through | ||
the log filter, if the `NODE_ENV` is set to `development`. | ||
|
||
### auth.js | ||
|
||
Configuration of authentication and authorization. | ||
|
||
* `superUser` - object of a user with all privileges. | ||
One can log in as a super user even if it's not in the database. | ||
Handy, if run on an empty database. | ||
|
||
* `guestUser` - object of a user assigned to not logged in browser clients. | ||
|
||
### browser.js | ||
|
||
Configuration of a browser that is started by the server when run in | ||
the production environment. | ||
|
||
* `cmd` - command that opens a browser pointed to the application. | ||
|
||
### controller.js | ||
|
||
* `simulation` - whether to run the simulation of a test if | ||
the `programRunning` tag changes to `1`. | ||
|
||
* `master` - configuration of a MODBUS master: | ||
|
||
* `timerFactor` - tags `programTime`, `hrsTime` and `hrsInterval` | ||
are multiplied by this value before sending them off to the slave. | ||
|
||
* `type` - connection and transport type. | ||
Possible values are: `tcp`, `tcp-rtu`, `tcp-ascii`, `serial-ascii` | ||
and `serial-rtu`. | ||
|
||
* `host` - slave host/IP address if using TCP connection. | ||
|
||
* `port` - slave listening port if using TCP connection. | ||
|
||
* `timeout` - default MODBUS request timeout. | ||
|
||
* `maxTimeouts` - if the number of consecutive timeouts is equal to | ||
`maxTimeouts`, then the connection is destroyed and recreated. | ||
|
||
* `unit` - default MODBUS slave unit ID. | ||
|
||
* `maxRetries` - a number of times a MODBUS request is retried on error | ||
before giving up and handing the error to the user's handler function. | ||
|
||
* `interval` - default interval between requests, | ||
|
||
* `maxConcurrentRequests` - how many parallel requests can be sent to | ||
the slave. | ||
|
||
* `requestOnReconnectDelay` - on reconnect, wait the specified number | ||
of milliseconds before executing the queued requests and transactions. | ||
|
||
* `transactions` - an array of objects describing tags and MODBUS | ||
transactions. The application expects the following 1 bit tags: | ||
`programRunning`, `runMode`, `selectedProgram1`, `selectedProgram2` | ||
and the following 32-bit signed int tags: | ||
`temperature`, `light`, `voltage`, `current`, | ||
`hrsIteration`, `predefinedTime1`, `predefinedTime2` | ||
and the following 4 32-bit signed int tags that must occupy consecutive | ||
registers: `hrsCount`, `hrsInterval`, `hrsTime`, `programTime`. | ||
Each object must have following properties: | ||
|
||
* `id` - an ID of the transaction. | ||
|
||
* `fn` - a MODBUS function code (`0x01`, `0x02` or `0x03`). | ||
|
||
* `address` - a starting address of the first tag. | ||
|
||
* `tags` - an array of tag names, | ||
|
||
* `writable` - whether the tags specified in this transaction are writable. | ||
|
||
* `interval` - a number of milliseconds between executions of | ||
this transaction. | ||
|
||
* `scalers` - an object specifying minimums, maximums and scaling function | ||
for tags. | ||
|
||
* `min` - if the read value is lower than the `min` value, it is set | ||
to `min`. | ||
|
||
* `max` - if the read value is greater than the `max` value, it is set | ||
to `max`. | ||
|
||
* `scaler` - a function that takes a raw value from MODBUS slave and | ||
transforms it to another value before handing it to application for | ||
further processing. | ||
|
||
* `interfaceMonitor` - sets up a network interface monitor | ||
|
||
* `enabled` - whether to monitor the network interface. | ||
|
||
* `ipAddress` - an IP address to look for in `stdout` of `checkCmd`. | ||
|
||
* `checkCmd` - a command that returns the current IP address on | ||
of the monitored network interface. | ||
|
||
* `restartCmd` - a command executed if the `ipAddress` could not be found | ||
in `stdout` of `checkCmd`. | ||
|
||
* `interval` - a number of milliseconds between `checkCmd` executions. | ||
|
||
* `serproxy` - sets up a [serproxy](http://developer.berlios.de/project/showfiles.php?group_id=3590) | ||
|
||
* `enabled` - whether to spawn the process. | ||
|
||
* `cmd` - command to execute if `enabled` is `TRUE`. | ||
|
||
* `args` - an array of command arguments. | ||
|
||
### mongod.conf | ||
|
||
Configuration of the MongoDB server. Description of the individual options can | ||
be found in | ||
[the MongoDB documentation](http://www.mongodb.org/display/DOCS/File+Based+Configuration). | ||
|
||
## Start | ||
|
||
If not yet running, start the MongoDB: | ||
|
||
$ mongod -f walkner-av/config/mongod.conf | ||
|
||
Start the application server in `development` or `production` environment: | ||
|
||
* under *nix: | ||
|
||
$ NODE_ENV=development node walkner-av/server/index.js | ||
|
||
* under Windows: | ||
|
||
$ SET NODE_ENV=development | ||
$ node walkner-av/server/index.js | ||
|
||
To run the application in `production` environment one must have | ||
[r.js](https://github.com/jrburke/r.js) properly set up and then execute the | ||
following commands: | ||
|
||
$ r.js walkner-av/bin/build-client.js | ||
$ r.js walkner-av/bin/build-min.js | ||
|
||
Application should be available on a port defined in `config/express.js` file | ||
(`80` by default). Point the Internet browser to http://127.0.0.1/. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@echo off | ||
r.js -o %~dp0/build-client.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
({ | ||
baseUrl: "../client", | ||
dir: "../client-build", | ||
name: "app/main", | ||
wrap: true, | ||
optimizeCss: "standard", | ||
paths: { | ||
"text" : "vendor/require/text", | ||
"order" : "vendor/require/order", | ||
"domReady" : "vendor/require/domReady", | ||
|
||
"jQuery" : "app/vendor/jQuery", | ||
"Underscore": "app/vendor/Underscore", | ||
"Backbone" : "app/vendor/Backbone", | ||
"moment" : "app/vendor/moment", | ||
|
||
"socket.io": "empty:", | ||
|
||
"app/models/limits": "empty:" | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@echo off | ||
r.js -o %~dp0/build-min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
({ | ||
out: "../client-build/app/min.js", | ||
baseUrl: "../client", | ||
dir: "../client-build", | ||
name: "app/main", | ||
wrap: true, | ||
paths: { | ||
"text" : "vendor/require/text", | ||
"order" : "vendor/require/order", | ||
"domReady" : "vendor/require/domReady", | ||
|
||
"jQuery" : "app/vendor/jQuery", | ||
"Underscore": "app/vendor/Underscore", | ||
"Backbone" : "app/vendor/Backbone", | ||
"moment" : "app/vendor/moment", | ||
|
||
"socket.io": "empty:socket.io/socket.io.js", | ||
|
||
"app/models/limits": "empty:" | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require.config({ | ||
baseUrl: './', | ||
paths: { | ||
'text': 'vendor/require/text', | ||
'order': 'vendor/require/order', | ||
'domReady': 'vendor/require/domReady', | ||
|
||
'jQuery': 'app/vendor/jQuery', | ||
'Underscore': 'app/vendor/Underscore', | ||
'Backbone': 'app/vendor/Backbone', | ||
'moment': 'app/vendor/moment', | ||
|
||
'socket.io': '/socket.io/socket.io.js' | ||
} | ||
}); | ||
|
||
require( | ||
[ | ||
'domReady', | ||
'Backbone', | ||
|
||
'app/time', | ||
'app/socket', | ||
'app/routers/main', | ||
'app/views/viewport', | ||
'app/touch' | ||
], | ||
function( | ||
domReady, | ||
Backbone, | ||
time, | ||
socket, | ||
setupRouting, | ||
viewport) | ||
{ | ||
setupRouting({}); | ||
domReady(function() | ||
{ | ||
viewport.render(); | ||
Backbone.history.start({pushState: false}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
define( | ||
[ | ||
'Backbone', | ||
|
||
'app/models/HistoryEntry' | ||
], | ||
/** | ||
* @param {Backbone} Backbone | ||
* @param {function(new:HistoryEntry)} HistoryEntry | ||
*/ | ||
function(Backbone, HistoryEntry) | ||
{ | ||
/** | ||
* @class History | ||
* @extends Backbone.Collection | ||
* @constructor | ||
* @param {Array.<HistoryEntry>} [models] | ||
* @param {Object} [options] | ||
*/ | ||
var History = Backbone.Collection.extend({ | ||
model: HistoryEntry, | ||
url: '/history' | ||
}); | ||
|
||
/** | ||
* @param {Object} res | ||
* @return {Array.<Object>} | ||
*/ | ||
History.prototype.parse = function(res) | ||
{ | ||
this.page = res.page || 1; | ||
this.limit = res.limit || 10; | ||
this.pages = res.pages || 1; | ||
this.totalCount = res.totalCount || res.data.length; | ||
|
||
return res.data; | ||
}; | ||
|
||
return History; | ||
}); |
Oops, something went wrong.