Developing lightweight computation at the DSG edge

Commit 0afd4f65 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[demo] Update a few data structures to have demo ready


Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 29a98e83
<div id="assign"></div>
<script src="./svg.min.js"></script>
<script src="/tmp/monitor-dump/last.json"></script>
<script src="/tmp/monitor-dump/view.json"></script>
<script>
setTimeout(function(){
window.location.reload(true);
}, 2000);
}, 3000);
// data={"devices":["35578","35580","41236","52800","53410","55625","58266","66287","67954","69514","74780","74943","75036","75038","75651","92844"],"monitors":["1","2","3","444"],"assignations":[{"device":"35578","monitors":["2"]},{"device":"35580","monitors":["1"]},{"device":"41236","monitors":["1"]},{"device":"52800","monitors":["1","2"]},{"device":"53410","monitors":["2"]},{"device":"55625","monitors":["1","2"]},{"device":"58266","monitors":["2"]},{"device":"66287","monitors":null},{"device":"67954","monitors":["1","2"]},{"device":"69514","monitors":["1","2"]},{"device":"74780","monitors":["1"]},{"device":"74943","monitors":["1","2"]},{"device":"75036","monitors":["1","2"]},{"device":"75038","monitors":null},{"device":"75651","monitors":["2"]},{"device":"92844","monitors":["1"]}]}
//
......@@ -97,12 +97,12 @@ if (data.monitors !== null ) {
}
}
if (data.assignations !== null) {
for (i = 0; i < data.assignations.length; i++) {
if (data.assignations[i].monitors !== null) {
for (j = 0; j < data.assignations[i].monitors.length; j++) {
var devPos = posItemInArray(data.assignations[i].device, data.devices)
var monPos = posItemInArray(data.assignations[i].monitors[j], data.monitors)
if (data.assignations.deviceToMonitors !== null) {
for (i = 0; i < data.assignations.deviceToMonitors.length; i++) {
if (data.assignations.deviceToMonitors[i].monitors !== null) {
for (j = 0; j < data.assignations.deviceToMonitors[i].monitors.length; j++) {
var devPos = posItemInArray(data.assignations.deviceToMonitors[i].device, data.devices)
var monPos = posItemInArray(data.assignations.deviceToMonitors[i].monitors[j], data.monitors)
var line = drawing.line(rwidth, rdist/2+devPos*rdist, monX, (dheight/Math.max(1,data.monitors.length+1))*monPos+rdist*monPos/2+rdist/2 ).stroke({ width: 1.5 })
assignsLines.push(line)
}
......
......@@ -248,15 +248,18 @@ func startGlobalAssignTimer() {
dataToExport.Stats.AvgDevsPerMon = float32(dataToExport.Stats.Assignations) / float32(len(dataToExport.Monitors))
lastOutFile, _ := os.Create(outDir + "last.json")
viewOutFile, _ := os.Create(outDir + "view.json")
timeOutFile, _ := os.Create(outDir + dateTime + ".json")
defer lastOutFile.Close()
defer viewOutFile.Close()
defer timeOutFile.Close()
jnodes, _ := json.Marshal(dataToExport)
//fmt.Println(string(jnode))
//outFile.WriteString(string(jnodes))
lastOutFile.WriteString(string(jnodes))
viewOutFile.WriteString("data=" + string(jnodes))
timeOutFile.WriteString(fmt.Sprintf("data = %s", string(jnodes)))
lastOutFile.Close()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment