+++ /dev/null
-<html>
- <head>
- <title>Denco</title>
- <style type="text/css">
- <!--
- .style-classdef {
- border: 1px solid gray;
- text-indent: 1em;
- margin-top: 8px;
- margin-bottom: 8px;
- }
- .style-cell {
- border: 1px solid gray;
- text-indent: 1em;
- margin-top: 8px;
- margin-bottom: 8px;
-
- }
-
- pre.dennco-script {
- border: 1px solid gray;
- background-color: #f0f0cc;
- margin-left: 2em;
- }
-
- -->
- </style>
- </head>
-<body>
- <H1>dennco Project. Sample</H1>
-
- <h2>Cell Code Class Definitions</h2>
- <a name='SampleScript1' class='dennco-classdef'>
- <div class="style-classdef">
- <dl>
- <dt>Code class:</dt>
- <dd>SampleScript1</dd>
- <dt>API TYPE:</dt>
- <dd class="dennco-api">TKJSBasicCell</dd>
- </dl>
-
- <pre class="dennco-script">
-
- function doTick(time)
- {
- print("JavaScript doTick called. time:" + time);
- var val = 0;
- var len = 0;
- for (var key in this.cell.receptors) {
- print("JS script... key:" + key + " value:" + this.cell.receptors[key]);
- val += this.cell.receptors[key] + 5;
- len++;
- }
- val = val / len;
-
- this.cell.setAxonValue(val);
-
- }
-
- </pre>
- </div>
- </a>
- <a name="SampleScript2" class="dennco-classdef">
- <div class="style-classdef">
- <dl>
- <dt>Code class2:</dt>
- <dd>SampleScript2</dd>
- <dt>API TYPE2:</dt>
- <dd class="dennco-api">TKJSBasicCell</dd>
- </dl>
-
- <pre class="dennco-script">
-
- var positiveInputs;
- var negativeInputs;
-
- var maxValue = 100.0;
- var minValue = -100.0;
-
- function doTick(time)
- {
- print("JavaScript doTick called. time:" + time);
- var pval = 0;
- var nval = 0;
- var len = 0;
- var key;
- for (key in this.positiveInputs) {
- print("Positive input:" + key + " value:" + this.cell.receptors[key]);
- pval += this.cell.receptors[key];
- len++;
- }
- pval = pval / len;
- len = 0;
- for (key in this.negativeInputs) {
- print("Negative input:" + key + " value:" + this.cell.receptors[key]);
- nval += this.cell.receptors[key];
- len++;
- }
- nval = nval / len;
-
- var t = this.cell.getAxonValue();
- if (t > maxValue) t = maxValue;
- else if (t < minValue) t = minValue;
-
- this.cell.axonValue = t;
-
- }
-
- </pre>
- </div>
- </a>
-
-
- <h2>Cells (Neurons)</h2>
-
- <a name="cell1-1" class="dennco-cell">
- <div class="style-cell">
- <dl>
- <dt>Cell Name:</dt>
- <dd>cell1-1</dd>
- <dt>Code class:</dt>
- <dd><a href="#SampleScript1" class="dennco-script">SampleScript1</a></dd>
- <dt>Init Script:</dt>
- <dd>
- <pre class="dennco-script">
-
- // init code here
- </pre>
- </dd>
- <dt>Connections:</dt>
- <dd>
- <a class="decco-connect" href="#cell2-1">cell2-1</a>
- <a class="decco-connect" href="#cell2-2">cell2-2</a>
- </dd>
- </dl>
- </div>
- </a>
-
- <a name="cell1-2" class="dennco-cell">
- <div class="style-cell">
- Cell name : cell1-2 </br>
- Code class : <a href="#SampleScript1" class="dennco-script">SampleScript1</a>
- <pre class="dennco-script">
-
- // init code here
- </pre>
- Connections:
- <ul>
- <li><a class="decco-connect" href="#cell2-1">cell2-1</a></li>
- <li><a class="decco-connect" href="#cell2-2">cell2-2</a></li>
- </ul>
- </div>
- </a>
-
- <a name="cell1-3" class="dennco-cell">
- <div class="style-cell">
- Cell name : cell1-3 </br>
- Code class : <a href="#SampleScript1" class="dennco-script">SampleScript1</a>
- <pre class="dennco-script">
-
- // init code here
- </pre>
- <ul>
- <li><a class="decco-connect" href="#cell2-1">cell2-1</a></li>
- <li><a class="decco-connect" href="#cell2-2">cell2-2</a></li>
- </ul>
- </div>
- </a>
-
- <a name="cell2-1" class="dennco-cell">
- <div class="style-cell">
- Cell name : cell2-1 </br>
- Code class : <a href="#SampleScript2" class="dennco-script">SampleScript2</a>
- <pre class="dennco-script">
-
- positiveInputs = {FQN("/sample.html#cell1-1"), FQN("sample2.html#cell1-2")};
- negativeInputs = {FQN("../sample3.html#cell1-3")}
- </pre>
- Connections:
- <ul>
- <li><a class="decco-connect" href="#cell3-1">cell3-1</a></li>
- </ul>
- </div>
- </a>
-
- <a name="cell2-2" class="dennco-cell">
- <div class="style-cell">
- Cell name : cell2-2 </br>
- Code class : <a href="#SampleScript2" class="dennco-script">SampleScript2</a>
- <pre class="dennco-script">
-
- positiveInputs = {FQN("cell1-3")};
- negativeInputs = {FQN("../cell1-1"), FQN("cell1-2")}
- </pre>
- Connections:
- <ul>
- <li><a class="decco-connect" href="#cell3-1">cell3-1</a></li>
- </ul>
- </div>
- </a>
-
- <a name='cell3-1' class='dennco-cell'>
- <div class="style-cell">
- Cell name : cell3-1 </br>
- Code class : <a href="#SampleScript1" class="dennco-script">SampleScript2</a>
- <pre class='dennco-script'>
-
- positiveInputs = {FQN("cell2-1")};
- negativeInputs = {FQN("cell2-2")}
- </pre>
- </div>
- </a>
-
-</body>
-</html>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head><title>Dennco - test1</title>
+<link rel="stylesheet" type="text/css" href="dstyle.css" />
+</head>
+
+<body>
+<h1>Sample1 - simple cells</h1>
+
+<a define="cell" name="ConsoleOut">
+<a parameter="cellcode" type="B"> </a>
+<pre parameter="script">
+<![CDATA[
+function doTick(time)
+{
+ print("\nTickTime: " + time.toFixed(3));
+ print(" autoCounter :" + this.cell.receptors.CounterValue);
+ print(" DoublerValue1 :" + this.cell.receptors.DoublerValue);
+ print(" TotalVarValue1 :" + this.cell.receptors.TotalVarValue);
+ print(" DoublerValue2 :" + this.cell.receptors.DoublerValue2);
+}
+]]>
+</pre>
+</a>
+
+<a define="cell" name="AutoCounter">
+<a parameter="cellcode" type="B"> </a>
+<pre parameter="script">
+<![CDATA[
+var counter = 0;
+function doTick(time)
+{
+ this.counter ++;
+ this.cell.axonValue = counter;
+}
+]]>
+</pre>
+<a parameter="connection" href="#ConsoleOut" receptor="CounterValue"></a>
+<a parameter="connection" href="#output1" receptor="autoCounter"></a>
+</a>
+
+<a define="cell" name="DoublerCell1">
+<a parameter="cellcode" href="#Doubler"> </a>
+<a parameter="connection" href="#ConsoleOut" receptor="DoublerValue"></a>
+<a parameter="connection" href="#output2" receptor="DoublerValue"></a>
+</a>
+
+<a define="cell" name="TotalVarCell1">
+<a parameter="cellcode" href="#TotalVar"> </a>
+<a parameter="connection" href="#ConsoleOut" receptor="TotalVarValue"></a>
+<a parameter="connection" href="#output3" receptor="TotalVarValue"></a>
+</a>
+
+<a define="cell" name="TotalVarCell2">
+<a parameter="cellcode" href="#TotalVar"> </a>
+<a parameter="connection" href="#DoublerCell2" receptor="input"></a>
+</a>
+
+<a define="cell" name="DoublerCell2">
+<a parameter="cellcode" href="#Doubler"> </a>
+<a parameter="connection" href="#ConsoleOut" receptor="DoublerValue2"></a>
+<a parameter="connection" href="#output4" receptor="DoublerValue2"></a>
+</a>
+
+
+<a define="cell" name="input1">
+<a parameter="cellcode" type="I"> </a>
+<a parameter="connection" href="#DoublerCell1" receptor="input"></a>
+<a parameter="connection" href="#TotalVarCell1" receptor="input1"></a>
+<a parameter="connection" href="#TotalVarCell2" receptor="input1"></a>
+</a>
+
+<a define="cell" name="input2">
+<a parameter="cellcode" type="I"> </a>
+<a parameter="connection" href="#TotalVarCell1" receptor="input2"></a>
+<a parameter="connection" href="#TotalVarCell2" receptor="input2"></a>
+</a>
+
+<a define="cell" name="output1"><a parameter="cellcode" type="O"></a></a>
+<a define="cell" name="output2"><a parameter="cellcode" type="O"></a></a>
+<a define="cell" name="output3"><a parameter="cellcode" type="O"></a></a>
+<a define="cell" name="output4"><a parameter="cellcode" type="O"></a></a>
+
+<a define="cellcode" name="Doubler" type="B">
+<pre parameter="script">
+<![CDATA[
+function doTick(time)
+{
+ this.cell.axonValue = this.cell.receptors.input * 2;
+}
+]]>
+</pre>
+</a>
+
+<a define="cellcode" name="TotalVar" type="B">
+<pre parameter="script">
+<![CDATA[
+function doTick(time)
+{
+ var r = this.cell.receptors.input1 + this.cell.receptors.input2;
+ this.cell.axonValue = r;
+}
+]]>
+</pre>
+</a>
+
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+
+a[define] {
+ border-top: 1px solid gray;
+ text-indent: 1em;
+ display: block;
+ margin-top: 32px;
+ margin-bottom: 8px;
+}
+
+a[define="cellcode"]:before {
+ content: "Definition of CellCode : " attr(name) " (type:" attr(type) ")" ;
+ font-size: large;
+ font-weight: bold;
+ display: inline;
+ white-space: pre;
+}
+
+
+a[define="cell"]:before {
+ content: "Definition of Cell : " attr(name) ;
+ font-size: large;
+ font-weight: bold;
+ display: inline;
+ white-space: pre;
+}
+
+a[parameter="cellcode"]:before {
+ content: "CellCode : " attr(href) attr(type);
+ display: inline;
+}
+
+a[parameter="cellcode"] {
+ text-indent: 1em;
+ display: block;
+}
+
+a[parameter="connection"]:before {
+ content: "-> " attr(href) "(" attr(name) ")";
+ display: inline;
+}
+
+a[parameter="connection"] {
+ text-indent: 2em;
+ display: block;
+}
+
+[parameter="script"] {
+ border: 1px solid gray;
+ background-color: #f0f0cc;
+ margin-left: 2em;
+}
--- /dev/null
+<dennco>
+
+<TickIntervalSec>1.0</TickIntervalSec>
+<UIPath>/ui/index.html</UIPath>
+<EnableHTTPServer>no</EnableHTTPServer> <!-- not implemented yet -->
+<EnableSerialServer>no</EnableSerialServer> <!-- not implemented yet -->
+
+</dennco>
\ No newline at end of file
--- /dev/null
+<html>
+<head>
+<title>Dennco Sample1</title>
+<script type="text/javascript">
+var timerId = setInterval("updateOutput()", 500);
+
+function updateOutput()
+{
+ document.getElementById("output1Value").value = engine.getValue('/cells.xhtml#output1');
+ document.getElementById("output2Value").value = engine.getValue('/cells.xhtml#output2');
+ document.getElementById("output3Value").value = engine.getValue('/cells.xhtml#output3');
+ document.getElementById("output4Value").value = engine.getValue('/cells.xhtml#output4');
+}
+
+function updateInput1(newValue)
+{
+ engine.setValue('/cells.xhtml#input1', newValue);
+ document.getElementById("input1Value").value = newValue;
+}
+
+function updateInput2(newValue)
+{
+ engine.setValue('/cells.xhtml#input2', newValue);
+ document.getElementById("input2Value").value = newValue;
+}
+
+function stopTimer()
+{
+ clearInterval(timerId);
+}
+</script>
+</head>
+<body onunload="stopTimer()">
+<h3>Sample1 - simple cells </h3>
+<table border=1 cellspacing=0 cellpadding=2>
+<tr>
+<th>Input</th><th>Output summary</th><th>Output Value</th>
+</tr>
+<tr>
+<td rowspan="4">
+IN1:<input type="range" min="0" max="100" value="0" onChange="updateInput1(this.value)" />
+<input type="text" value="0" disabled size="4" style="text-align:right" id="input1Value"/>
+<p>
+IN2:<input type="range" min="0" max="100" value="0" onChange="updateInput2(this.value)" />
+<input type="text" value="0" disabled size="4" style="text-align:right" id="input2Value"/>
+</td>
+<td>Value of AutoCounter</td>
+<td><input type="text" disabled size="6" style="text-align:right" id="output1Value"/></td>
+</tr>
+
+<tr>
+<td>Value of DoublerCell1 (IN1 x 2)</td>
+<td><input type="text" disabled size="6" style="text-align:right" id="output2Value"/></td>
+</tr>
+
+<tr>
+<td>Value of TotalVarCell1(IN1 + IN2)</td>
+<td><input type="text" disabled size="6" style="text-align:right" id="output3Value"/></td>
+</tr>
+
+<tr>
+<td>Value of TotalVarCell2 -> DoublerCell2 (IN1+IN2 -> x2)</td>
+<td><input type="text" disabled size="6" style="text-align:right" id="output4Value"/></td>
+</tr>
+</table>
+
+</body>
+</html>
{
valid = true;
DNXMLElement *element = xml->getRoot();
- if (element->name != "dennco")
+ if (!element)
+ {
+ valid = false;
+ std::string message = "Failed to load property.xml file";
+ TKLog::printf("ERROR wile loading property.xml file.\n%s\n",message.c_str());
+ if (dnGlobal()->updateErrorStatus(DNGlobal::ERROR))
+ {
+ dnGlobal()->setMessage1("Initialization failed");
+ dnGlobal()->setMessage2(message);
+ }
+ else
+ {
+ dnGlobal()->setMessage1("Initialization failed");
+ }
+ }
+
+ if (valid && element->name != "dennco")
{
valid = false;
std::string message = "First element of property.xml should be <dennco>";
monofont.setStyleHint(QFont::Monospace);
ui->console->setFont(monofont);
TKLog::setDestination(this);
+ connect(this, SIGNAL(consoleUpdated()), this, SLOT(update()), Qt::AutoConnection);
}
MainWindow::~MainWindow()
QWebFrame *frame = page->mainFrame();
if (frame)
{
- frame->addToJavaScriptWindowObject("dennco", mWebInterface);
+ frame->addToJavaScriptWindowObject("engine", mWebInterface);
connect(frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(attachWebInterface()));
}
}
mPendingConsoleMessage.append(msg);
mHasPendingConsoleMessage = true;
mConsoleLock.unlock();
- update();
+ emit consoleUpdated();
}
void MainWindow::vDebugPrintf(const char *fmt, va_list ap)
QString mPendingConsoleMessage;
bool mHasPendingConsoleMessage;
+signals:
+ void consoleUpdated();
+
};
#endif // MAINWINDOW_H