Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
markuspinter committed Feb 12, 2020
2 parents 1f92c72 + c0560ed commit 58c0c5d
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 56 deletions.
Binary file modified .DS_Store
Binary file not shown.
15 changes: 11 additions & 4 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,17 @@ <h3 id="versionLabel">ECUI - Version <span id="version">1.0.0</span></h3>
</div>

</div>
<div class="form-control-lg custom-control custom-checkbox digitalOut-div row control-row">
<input type="checkbox" class="custom-control-input ckbx manual-obj" id="igniter"
onclick="onIgniterCheck(this);">
<label class="custom-control-label ckbx-label" for="igniter">Igniter</label>
<div class="row control-row">
<div class="form-control-lg custom-control custom-checkbox digitalOut-div">
<input type="checkbox" class="custom-control-input ckbx manual-obj digitalOut" id="igniter"
onclick="onDigitalCheck(this);" disabled>
<label class="custom-control-label ckbx-label" for="igniter">Igniter</label>
</div>
<div class="form-control-lg custom-control custom-checkbox digitalOut-div">
<input type="checkbox" class="custom-control-input ckbx manual-obj digitalOut" id="solenoidPress;solenoidDepress"
onclick="onDigitalCheck(this);" disabled>
<label class="custom-control-label ckbx-label" for="solenoidPress;solenoidDepress">Solenoid Pressure</label>
</div>
</div>

<button class="btn btn-secondary cal-btn manual-obj" id="saftlButton" disabled>Saftl</button>
Expand Down
34 changes: 31 additions & 3 deletions client/js/ClientSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ function sendDigitalOut(doId, doValue)
socket.emit('digital-outs-set', [jsonDigitalOut]);
}

function sendDigitalOutArr(doIds, doValue)
{
let jsonDigitalOut = [];
let jsonDigitalOutObj = {};

for (let doIdsInd in doIds)
{
jsonDigitalOutObj = {};
jsonDigitalOutObj.id = doIds[doIdsInd];
jsonDigitalOutObj.value = doValue;

jsonDigitalOut.push(jsonDigitalOutObj);
}
socket.emit('digital-outs-set', jsonDigitalOut);
}

function sendServo(servoId, servoValue)
{
let jsonServo = {};
Expand Down Expand Up @@ -149,19 +165,23 @@ function onServosLoad(jsonServosData)
}
}

function onIgniterCheck(checkbox)
function onDigitalCheck(checkbox)
{
let id = $(checkbox).attr('id');

let ids = id.split(";");
console.log(ids);

if (checkbox.checked)
{
sendDigitalOut(id, true);
sendDigitalOutArr(ids, true);
}
else
{
sendDigitalOut(id, false);
sendDigitalOutArr(ids, false);
}


}

function onServoEnable(checkbox) {
Expand Down Expand Up @@ -201,6 +221,14 @@ function onServoEnable(checkbox) {
$(this).prop('disabled', true);
});

$('.digitalOut').each(function () {
if ($(this).prop("checked") === true)
{
$(this).prop('checked', false);
$(this).click();
}
});

socket.emit('servos-disable');
}
}
Expand Down
74 changes: 51 additions & 23 deletions client/js/SequenceChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,23 @@ class SequenceChart

//if indicator then strokecolor must be defined
//TODO: allow only when live tracking is not running
addSeries(seriesName, yValueName, isIndicator=false, strokeColor=undefined)
addSeries(seriesName, yValueName, interpolation="none", isIndicator=false, strokeColor=undefined)
{
// Create series
var series = this.chart.series.push(new am4charts.LineSeries());
var series;
if (interpolation === "none")
{
series = this.chart.series.push(new am4charts.StepLineSeries());
}
else if (interpolation === "linear")
{
series = this.chart.series.push(new am4charts.LineSeries());
}
else
{
series = this.chart.series.push(new am4charts.StepLineSeries());
}


series.name = seriesName;
series.dataFields.valueY = yValueName;
Expand Down Expand Up @@ -185,7 +198,8 @@ class SequenceChart

let currSeries = this.chart.series.getIndex(i);
let yValueName = currSeries.dataFields.valueY;
console.log(this.addSeries(currSeries.name + " live", yValueName + " live", true, currSeries.stroke));
console.log("name: " + currSeries.name + " interp: " + this.getInterpolationFromName(currSeries.name));
console.log(this.addSeries(currSeries.name + " live", yValueName + " live", this.getInterpolationFromName(currSeries.name), true, currSeries.stroke));

let time = this.chart.data[0].time;

Expand Down Expand Up @@ -235,6 +249,33 @@ class SequenceChart

if (currInt.next !== undefined)
{

//todo: make it prettier
let currLiveSeries = this.chart.series.getIndex(parseInt(serInd) + this.liveIntervalList.length);
if (time === currInt.next.x)
{
this.addSingleData(currLiveSeries, time, currInt.next.y);
//console.log({"time": time, "y": currInt.next.y});
}
else
{
//todo: make better solution
let y;
if (currLiveSeries.constructor.name === "e") //constructor name of Line Series
{
let scale = (currInt.next.y - currInt.prev.y) / (currInt.next.x - currInt.prev.x);
y = scale * (time-currInt.prev.x) + currInt.prev.y;

//console.log("time: " + time + " scale: " + scale + " y: " + y);
this.addSingleData(currLiveSeries, time, y);
}
else
{
y = currInt.prev.y;
}
this.addSingleData(currLiveSeries, time, y);
}

let yValueName = this.chart.series.getIndex(serInd).dataFields.valueY;
if (time >= currInt.next.x) {
//fetch next time with point from series
Expand All @@ -253,25 +294,6 @@ class SequenceChart
}
currInt.next = newNextInt;
}
if (currInt.next !== undefined) {

//todo: make it prettier
let currLiveSeries = this.chart.series.getIndex(parseInt(serInd) + this.liveIntervalList.length);
if (time === currInt.next.x)
{
this.addSingleData(currLiveSeries, time, currInt.next.y);
//console.log({"time": time, "y": currInt.next.y});
}
else
{
let scale = (currInt.next.y - currInt.prev.y) / (currInt.next.x - currInt.prev.x);
let y = scale * (time-currInt.prev.x) + currInt.prev.y;

//console.log("time: " + time + " scale: " + scale + " y: " + y);
this.addSingleData(currLiveSeries, time, y);
}

}
}

}
Expand All @@ -295,6 +317,7 @@ class SequenceChart

loadSequenceChart(jsonSeq)
{
this.globals = jsonSeq.globals;
let startTime = jsonSeq.globals.startTime;
let endTime = jsonSeq.globals.endTime;

Expand Down Expand Up @@ -347,7 +370,7 @@ class SequenceChart
{
if (!(cmd in serObj))
{
let newSer = this.addSeries(cmd, cmd);
let newSer = this.addSeries(cmd, cmd, jsonSeq.globals.interpolation[cmd]);
serObj[cmd] = newSer;
}
this.addSingleData(serObj[cmd], time, action[cmd]);
Expand All @@ -356,6 +379,11 @@ class SequenceChart
}
}
}

getInterpolationFromName(name)
{
return this.globals.interpolation[name];
}
}


Expand Down
2 changes: 1 addition & 1 deletion client/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.1.0
File renamed without changes.
File renamed without changes.
36 changes: 11 additions & 25 deletions sequence/Sequence.json → sequence/SequenceTemp.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
"globals": {
"startTime": -12,
"endTime": 7,
"interval": 0.01
"interval": 0.01,
"interpolation": {
"igniter": "none",
"fuel": "linear",
"oxidizer": "linear"
},
"ranges": [
"chamberPressure"
]
},
"data": [
{
Expand All @@ -21,36 +29,18 @@
},
{
"fuel": 0,
"igniter": 0,
"oxidizer": 0,
"timestamp": -1.1
},
{
"fuel": 0,
"igniter": 0,
"oxidizer": 0,
"timestamp": -1.0
},
{
"fuel": 0,
"igniter": 0,
"oxidizer": 0,
"timestamp": 0.0
},
{
{
"igniter": 100,
"timestamp": 0.1
},
{
"fuel": 50,
"igniter": 100,
"oxidizer": 50,
"timestamp": 0.5
},
{
"igniter": 100,
"timestamp": 0.9
},
{
"fuel": 100,
"igniter": 100,
Expand All @@ -69,13 +59,9 @@
},
"timestamp": 1.1
},
{
"igniter": 100,
"timestamp": 2.5
},
{
"igniter": 0,
"timestamp": 2.6
"timestamp": 2.5
},
{
"fuel": 100,
Expand Down

0 comments on commit 58c0c5d

Please sign in to comment.