Last summer I ran OpenPlotter 0.8.0 mainly as a server/multiplexer for the incomming data. Allthough this works like a charm, I am plannng to add more functionality. And with that search, I started with the installation of the new version 0.9.0 on my RPI3.
Further, I came across the webAPP page that Digital Yacht implement on their IKomunicate box. The below link shows an zip file with in it the main-html file, a css-file and a settings file.
I was a bit confident. I placed these files in my apache2 webserver folder, and nothing happened. The page does open when go to this ip-adress from my laptop or tablet, but there is no data polling. Somehow the SignalK server is not called propperly.
The first part of the file "iKommunicate-API-Kindle".html" is listed below.
Inhere you'll see that it refers to some ip-adresses, but i am not sure what to type where!?
var ipServer;
var flagStreamClosed=false;
var displayMode=0,speedUnitsMode=0,depthUnitsMode=0;
var currentBoxes=0;
var guiDrawed=false;
var currentPath,currentPath2,currentPath3;
var variableNumber=0;
var interval=1000;
var flagFirstBox=true,flagWindAngle=true;
var i;
// Start the request of data to the server
function startRequestDataServer() {
var urlServer;
var jsonParsed;
var value,value2,value3,value4;
if(ipServer.length==0||ipServer=="192.168.1.64"||ipServer=="192.168.30.221"||ipServer=="192.168.30.219")
urlServer = "http://demo.signalk.org/signalk/v1/api/vessels/self/";
// urlServer = "http://217.137.78.199:3000/signalk/v1/api/vessels/self/";
else
urlServer = "http://"+ipServer+"/signalk/v1/api/vessels/self/";
Ah, thanks for pointing me in the right direction.
Modified the file with the ip-adresses you mentioned.
Created the folders /examples/ik/in the folder /home/pi/.config/signalk-server-node/
Copied the files (also the modified one) into this created folder.
When going to 10.10.10.1:3000/examples/ki/Settings.html, it could get "settings.html. I then copied the files into /home/pi/.config/signalk-server-node/bower_components/ik. And when I go to 10.10.10.1:3000/ik/iKommunicate-API-Kindle.html, it show the webpage as in the ikommunicate example.
The only thing is that it shows the signalk demo information. and not my information from my only generated signalk.
(2016-12-23, 12:08 AM)Vic Wrote: Ah, thanks for pointing me in the right direction.
Modified the file with the ip-adresses you mentioned.
Created the folders /examples/ik/in the folder /home/pi/.config/signalk-server-node/
Copied the files (also the modified one) into this created folder.
When going to 10.10.10.1:3000/examples/ki/Settings.html, it could get "settings.html. I then copied the files into /home/pi/.config/signalk-server-node/bower_components/ik. And when I go to 10.10.10.1:3000/ik/iKommunicate-API-Kindle.html, it show the webpage as in the ikommunicate example.
The only thing is that it shows the signalk demo information. and not my information from my only generated signalk.
(2016-12-23, 12:08 AM)Vic Wrote: Ah, thanks for pointing me in the right direction.
Modified the file with the ip-adresses you mentioned.
Created the folders /examples/ik/in the folder /home/pi/.config/signalk-server-node/
Copied the files (also the modified one) into this created folder.
When going to 10.10.10.1:3000/examples/ki/Settings.html, it could get "settings.html. I then copied the files into /home/pi/.config/signalk-server-node/bower_components/ik. And when I go to 10.10.10.1:3000/ik/iKommunicate-API-Kindle.html, it show the webpage as in the ikommunicate example.
The only thing is that it shows the signalk demo information. and not my information from my only generated signalk.
var ipServer;
var flagStreamClosed=false;
var displayMode=0,speedUnitsMode=0,depthUnitsMode=0;
var currentBoxes=0;
var guiDrawed=false;
var currentPath,currentPath2,currentPath3;
var variableNumber=0;
var interval=1000;
var flagFirstBox=true,flagWindAngle=true;
var i;
// Start the request of data to the server
function startRequestDataServer() {
var urlServer;
var jsonParsed;
var value,value2,value3,value4;
ipServer="10.10.10.1:3000";
if(ipServer.length==0||ipServer!="10.10.10.1:3000")
urlServer = "http://demo.signalk.org/signalk/v1/api/vessels/self/";
else
urlServer = "http://"+ipServer+"/signalk/v1/api/vessels/self/";
setInterval(function() {
// If the user close the stream (flagStreamClosed==true), do anything
if(flagStreamClosed)
return;
if(!guiDrawed)
drawGUI();
var xhttp = new XMLHttpRequest();
if(positionPriority[0]==-1) {
xhttp.open("GET", urlServer, true);
}
else {
switch(currentBoxes) {
case 0: // Depth
case 1: // Speed
case 2: // Course (Heading)
case 3: // Wind
xhttp.open("GET", urlServer+currentPath+"/", true);
break;
case 4: // Depth and Speed
case 5: // Course (Heading) and Wind
case 6: // All
xhttp.open("GET", urlServer, true);
break;
}
}
xhttp.send();
// The next function is executed when the data arrives from the server
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
if(positionPriority[0]==-1) {
getPriorities(JSON.parse(xhttp.responseText.replace(/,"value":{}/g,"")));
getPath(currentBoxes);
return;
}
if(positionPriority[currentBoxes]!=9) {
switch(currentBoxes) {
case 0: // Depth
case 1: // Speed
case 2: // Course (Heading)
value = JSON.parse(xhttp.responseText.replace(/,"value":{}/g,"")).value;
if(depthUnitsMode==1&¤tBoxes==0)
value *= 3.2808;
else if(currentBoxes==1)
value *= 1.94384;
else if(currentBoxes==2)
value *= 57.296;
if(currentBoxes!=2)
value = value.toFixed(1);
else {
value = Math.round(value);
value = format3Digits(1,value);
}
displayValue(value,null,null,null,null);
break;
case 3:
if(flagWindAngle) {
value = JSON.parse(xhttp.responseText.replace(/,"value":{}/g,"")).value;
value *= 57.296;
value = Math.round(value);
value = format3Digits(2,value);
xhttp.open("GET", urlServer+currentPath2+"/", true);
xhttp.send();
flagWindAngle = false;
}
else {
value2 = JSON.parse(xhttp.responseText.replace(/,"value":{}/g,"")).value;
if(speedUnitsMode==0)
value2 *= 1.94384;
value2 = Math.round(value2);
displayValue(value,value2,null,null,null);
flagWindAngle = true;
}
break;
case 4: // Depth and Speed
jsonParsed = JSON.parse(xhttp.responseText.replace(/,"value":{}/g,""));
value = jsonParsed["environment"]["depth"][KEYS_4BOXES[0][positionPriority[0]]].value;
if(depthUnitsMode==1)
value *= 3.2808;
value = value.toFixed(1);
value2 = jsonParsed["navigation"][KEYS_4BOXES[1][positionPriority[1]]].value;
value2 *= 1.94384;
value2 = value2.toFixed(1);
displayValue(value,value2,null,null,null);
break;
case 5: // Course (Heading) and Wind
jsonParsed = JSON.parse(xhttp.responseText.replace(/,"value":{}/g,""));
value1 = jsonParsed["navigation"][KEYS_4BOXES[2][positionPriority[2]]].value;
value1 *= 57.296;
value1 = Math.round(value1);
value1 = format3Digits(1,value1);
value2 = jsonParsed["environment"]["wind"][KEYS_4BOXES[3][positionPriority[3]]].value;
value2 *= 57.296;
value2 = Math.round(value2);
value2 = format3Digits(2,value2);
value3 = jsonParsed["environment"]["wind"][KEYS_4BOXES[4][positionPriority[4]]].value;
if(speedUnitsMode==0)
value3 *= 1.94384;
value3 = Math.round(value3);
displayValue(value,value2,value3,null,null);
break;
case 6: // All
jsonParsed = JSON.parse(xhttp.responseText.replace(/,"value":{}/g,""));
value = jsonParsed["environment"]["depth"][KEYS_4BOXES[0][positionPriority[0]]].value;
if(depthUnitsMode==1)
value *= 3.2808;
value = value.toFixed(1);
value2 = jsonParsed["navigation"][KEYS_4BOXES[1][positionPriority[1]]].value;
value2 *= 1.94384;
value2 = value2.toFixed(1);
value3 = jsonParsed["navigation"][KEYS_4BOXES[2][positionPriority[2]]].value;
value3 *= 57.296;
value3 = Math.round(value3);
value3 = format3Digits(1,value3);
value4 = jsonParsed["environment"]["wind"][KEYS_4BOXES[3][positionPriority[3]]].value;
value4 *= 57.296;
value4 = Math.round(value4);
value4 = format3Digits(2,value4);
value5 = jsonParsed["environment"]["wind"][KEYS_4BOXES[4][positionPriority[4]]].value;
if(speedUnitsMode==0)
value5 *= 1.94384;
value5 = Math.round(value5);
displayValue(value,value2,value3,value4,value5);
break;
}
}
else {
document.getElementById('display11').innerHTML =
"<Font Style='Font-Size:500%;'><B>"+LABEL_VARIABLES[currentBoxes][0]+"</B><BR><BR></Font>"+
"<span Style='Font-Size:700%;'><B>Unavailable</span></B><BR><BR><BR><BR><BR><BR>"+
"<Font Style='Font-Size:500%;'><B>"+LABEL_UNITS[currentBoxes][0]+"</B></Font>";
}
}
else {
}
};
}, interval);
}
// This function is executed when the user press the button "Close/Open the stream", activating or deactivating
// the flag "flagStreamClosed". This flag is checked in the function "getVariablesAvailable". If false, the program
// request data from the server. If it is true, doesnt ask for data
function openCloseStream() {
if (document.getElementById("buttonOpenCloseStream").innerHTML.trim()=="Close Stream") {
document.getElementById("buttonOpenCloseStream").innerHTML = "Open Stream";
flagStreamClosed = true;
}
else {
document.getElementById("buttonOpenCloseStream").innerHTML = "Close Stream";
flagStreamClosed = false;
}
return false;
}
document.onclick = function(event) {
if(event.offsetX>document.body.offsetWidth/2) {
switch(currentBoxes) {
case 0:
case 1:
case 2:
currentBoxes++;
break;
case 3:
break;
case 4: // 12
currentBoxes++;
break;
case 5: // 34
break;
case 6: // 1234
break;
}
}
else {
switch(currentBoxes) {
case 0:
break;
case 1:
case 2:
case 3:
currentBoxes--;
break;
case 4:
break;
case 5:
currentBoxes--;
break;
case 6:
break;
}
}
getPath(1,null);
}
// This function save, in the local space area, the value of the IP the user wrote in the field "IP" of the
// WEB page, so he/she doesnt need to write again it every time the page is accessed
function saveNewIP(event) {
// The new IP is saved when the user press Enter (code key 13)
if(event.keyCode===13) {
if($('#ipServerInput').val().length!=0)
localStorage.setItem('ipServer',$('#ipServerInput').val());
else
localStorage.removeItem("ipServer");
}
return false;
}
// This function save, in the local space area, the value of the IP the user wrote in the field "IP" of the
// WEB page, so he/she doesnt need to write again it every time the page is accessed
function getSettings() {
if(localStorage.getItem("speedUnitsModeSetting"))
speedUnitsMode = localStorage.getItem("speedUnitsModeSetting");
if(localStorage.getItem("depthUnitsModeSetting"))
depthUnitsMode = localStorage.getItem("depthUnitsModeSetting");
if(localStorage.getItem("displayModeSetting"))
displayMode = localStorage.getItem("displayModeSetting");
if(localStorage.getItem("nightViewMode")) {
if(localStorage.getItem("nightViewMode")==1) {
document.body.classList.add("bodyNightView");
document.getElementById("buttonSettings").style.backgroundImage = "url('OptionsImageWhite.png')";
}
else {
document.body.classList.remove("bodyNightView");
document.getElementById("buttonSettings").style.backgroundImage = "url('OptionsImage.png')";
}
}
guiDrawed = false;
}
function format3Digits(typeCall,value) {
switch(typeCall) {
case 1:
var valueString = value+"";
if((value>0&&valueString.length>=3)||(value<0&&valueString.length>3))
return valueString;
if(value>=0) {
while(valueString.length<3)
valueString = "0"+valueString;
value = valueString;
}
else {
value = -value;
valueString = value+"";
while(valueString.length<3)
valueString = "0"+valueString;
valueString = "-"+valueString;
}
return valueString;
case 2:
if(value>180)
value = value - 360;
var valueString = value+"";
if((value>0&&valueString.length>=3)||(value<0&&valueString.length>3)) {
if(value>=100&&value<180)
valueString = value+"-";
return valueString;
}
if(value>=0&&value<100) {
while(valueString.length<3)
valueString = "0"+valueString;
if(value!=0)
valueString += "-";
}
else if(value>=-99&&value<=-1){
value = -value;
valueString = value+"";
while(valueString.length<3)
valueString = "0"+valueString;
valueString = "-"+valueString;
}
return valueString;
}
}
</Script>
</HEAD>
HowTo:
extract Kindle_App_Example.zip into /home/pi/.config/signalk-server-node/public/examples
To simulate values:
Start OpenPlotter GUI
Tools>SignalK Simulator
start
activate/check all Sliders (in diagnostic SignalK you should see 8 lines OPsimulation)
(2017-12-05, 11:14 PM)e-sailing Wrote: HowTo:
extract Kindle_App_Example.zip into /home/pi/.config/signalk-server-node/public/examples
To simulate values:
Start OpenPlotter GUI
Tools>SignalK Simulator
start
activate/check all Sliders (in diagnostic SignalK you should see 8 lines OPsimulation)
I was just messing with this today on the boat, which doesn't have a connection to the Internet. I'm only getting a white screen, with no instruments, even when I use the SignalK simulator.
I noticed in the script the line "urlServer = "http://demo.signalk.org/signalk/v1/api/vessels/self/";", which clearly points to signalk.org. Could this cause a problem if OP isn't connected? I looked at it and it appears to be a set of definitions. Would it help to move that page to the local server and point to it there?
(2017-12-23, 11:15 PM)abarrow Wrote: I was just messing with this today on the boat, which doesn't have a connection to the Internet. I'm only getting a white screen, with no instruments, even when I use the SignalK simulator.
I noticed in the script the line "urlServer = "http://demo.signalk.org/signalk/v1/api/vessels/self/";", which clearly points to signalk.org. Could this cause a problem if OP isn't connected? I looked at it and it appears to be a set of definitions. Would it help to move that page to the local server and point to it there?
I think that address is only for when it didn't find some signalk locally
Op 0.16.0
Rpi3
Gps USB
Imu MPU 9250
Pressure BMP180
Temperature HTU21D
Humidity HTU21D
Ais reciver 820t2 & sdr