1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
4 <head><title>Dennco - test1</title>
5 <link rel="stylesheet" type="text/css" href="dstyle.css" />
9 <h1>Outputs for Arduino motor shield</h1>
11 <a define="cell" name="M1controlValueController"><a parameter="cellcode" href="#ControlValueController"> </a>
12 <a parameter="connection" href="4_z.xhtml#m1" receptor="controlValue"></a>
13 <a parameter="connection" href="../ui/4_uiz.xhtml#m1controlValue" receptor="controlValue"></a>
17 <a define="cellcode" name="ControlValueController" type="B">
18 <pre parameter="script">
25 this.prevRawPosition = 0;
26 this.prevSamplingTime = 0;
31 var controlValue = this.cell.receptors.controlValue;
32 var samplingTime = this.cell.receptors.samplingTime;
33 var currentRawPosition = this.cell.receptors.currentRawPosition;
34 var offset = this.cell.receptors.offset;
35 var uiInitialized = this.cell.receptors.uiInitialized;
37 if (uiInitialized != 1)
39 print("waiting for the initialization of UI..");
43 if (samplingTime != this.prevSamplingTime && controlValue != 0 && Math.abs(currentRawPosition - this.prevRawPosition) <= 1 && Math.abs(controlValue) < offset)
47 controlValue += offset;
51 controlValue -= offset;
54 this.prevRawPosition = currentRawPosition;
55 this.prevSamplingTime = samplingTime
61 else if (controlValue < -1)
65 controlValue = Math.floor(controlValue * 255);
67 var safetyBreak = this.cell.receptors.safetyBreak;
69 if (controlValue <= 0 && safetyBreak >= 0)
71 this.cell.axonValue = controlValue;
73 else if (controlValue > 0 && safetyBreak <= 0)
75 this.cell.axonValue = controlValue;
79 this.cell.axonValue = 0;