mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-25 03:44:52 +00:00
automowerconnect.js: new Frontend helper
git-svn-id: https://svn.fhem.de/fhem/trunk@27115 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ee2b5ff47c
commit
3b62c977ae
@ -1,5 +1,8 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- new: 74_AutomowerConnect: Control Automower + Host
|
||||
- new: 75_AutomowerConnectDevice: Control Automower Client
|
||||
- new: automowerconnect.js: Frontend helper
|
||||
- change: 93_Log2Syslog: Adapt to change Logging in fhem.pl, Forum:#131790
|
||||
- change: 93_DbLog: Syntaxcheck of DbLogValueFn attribute, Forum:#131777
|
||||
- change: 72_FRITZBOX: our Deklaration nach my (package global)
|
||||
|
1762
fhem/FHEM/74_AutomowerConnect.pm
Normal file
1762
fhem/FHEM/74_AutomowerConnect.pm
Normal file
File diff suppressed because it is too large
Load Diff
1463
fhem/FHEM/75_AutomowerConnectDevice.pm
Normal file
1463
fhem/FHEM/75_AutomowerConnectDevice.pm
Normal file
File diff suppressed because it is too large
Load Diff
@ -404,6 +404,7 @@ FHEM/73_NUKIBridge.pm CoolTux Sonstige Systeme
|
||||
FHEM/73_PRESENCE.pm JoWiemann Unterstützende Dienste
|
||||
FHEM/73_WaterCalculator Sailor Unterstützende Dienste https://forum.fhem.de/index.php/topic,58579.0.html
|
||||
FHEM/74_AMADDevice.pm CoolTux Sonstige Systeme
|
||||
FHEM/74_AutomowerConnect.pm Ellert Sonstige Systeme https://forum.fhem.de/index.php/topic,131661.0.html
|
||||
FHEM/74_GardenaSmartDevice.pm CoolTux Sonstige Systeme
|
||||
FHEM/74_HOMBOT.pm CoolTux sonstige Systeme
|
||||
FHEM/74_HusqvarnaAutomower.pm krannich Sonstige Systeme
|
||||
@ -416,6 +417,7 @@ FHEM/74_UnifiClient.pm wuehler Automatisierung
|
||||
FHEM/74_UnifiProtect.pm justme1968 Sonstiges
|
||||
FHEM/74_UnifiVideo.pm justme1968 Sonstiges
|
||||
FHEM/74_XiaomiBTLESens CoolTux Sonstige Systeme
|
||||
FHEM/75_AutomowerConnectDevice.pm Ellert Sonstige Systeme https://forum.fhem.de/index.php/topic,131661.0.html
|
||||
FHEM/75_MSG.pm loredo Automatisierung
|
||||
FHEM/75_msgConfig.pm loredo Automatisierung
|
||||
FHEM/76_msgDialog.pm orphan/Beta-User Frontends/Sprachsteuerung https://forum.fhem.de/index.php/topic,125710.0.html
|
||||
@ -503,7 +505,7 @@ FHEM/98_CustomReadings.pm HCS Unterstützende Dienste
|
||||
FHEM/98_dewpoint.pm hotbso Automatisierung
|
||||
FHEM/98_DLNARenderer.pm dominikkarall Multimedia
|
||||
FHEM/98_DOIF.pm damian-s Automatisierung/DOIF
|
||||
FHEM/98_DOIFtools.pm Ellert Automatisierung/DOIF
|
||||
FHEM/98_DOIFtools.pm Ellert Automatisierung/DOIF https://forum.fhem.de/index.php/topic,63938.0.html
|
||||
FHEM/98_Dooya.pm Jarnsen/ralf9/darkmission Sonstige Systeme
|
||||
FHEM/98_dummy.pm rudolfkoenig Automatisierung
|
||||
FHEM/98_DSBMobile KernSani Codeschnipsel https://forum.fhem.de/index.php/topic,107104.0.html
|
||||
@ -667,6 +669,7 @@ contrib/Widgets/DateTimePicker* Matscher Frontends
|
||||
contrib/Wzut/* Wzut MAX
|
||||
contrib/YAF/* MarcP Frontends
|
||||
|
||||
www/pgm2/automowerconnect.js Ellert Frontends
|
||||
www/codemirror/* rapster Frontends
|
||||
www/frontend/* johannnes Frontends
|
||||
www/gplot/* rudolfkoenig Frontends/SVG/Plots/logProxy
|
||||
|
218
fhem/www/pgm2/automowerconnect.js
Normal file
218
fhem/www/pgm2/automowerconnect.js
Normal file
@ -0,0 +1,218 @@
|
||||
|
||||
FW_version["automowerconnect.js"] = "$Id$";
|
||||
|
||||
function AutomowerConnectLimits( ctx, pos, format ) {
|
||||
// log("array length: "+pos.length);
|
||||
if ( pos.length > 3 ) {
|
||||
// draw limits
|
||||
ctx.beginPath();
|
||||
|
||||
if ( format == 0 ) {
|
||||
ctx.lineWidth=1;
|
||||
ctx.strokeStyle = '#ff8000';
|
||||
ctx.setLineDash([]);
|
||||
}
|
||||
if ( format == 1 ) {
|
||||
ctx.lineWidth=1;
|
||||
ctx.strokeStyle = '#33cc33';
|
||||
ctx.setLineDash([]);
|
||||
}
|
||||
|
||||
ctx.moveTo(parseInt(pos[0]),parseInt(pos[1]));
|
||||
for (var i=2;i < pos.length - 1; i+=2 ) {
|
||||
ctx.lineTo(parseInt(pos[i]),parseInt(pos[i+1]));
|
||||
}
|
||||
ctx.lineTo(parseInt(pos[0]),parseInt(pos[1]));
|
||||
ctx.stroke();
|
||||
|
||||
// limits connector
|
||||
if ( format == 1 ) {
|
||||
for (var i=0;i < pos.length - 1; i+=2 ) {
|
||||
ctx.beginPath();
|
||||
ctx.setLineDash([]);
|
||||
ctx.lineWidth=1;
|
||||
ctx.strokeStyle = '#33cc33';
|
||||
ctx.fillStyle= 'white';
|
||||
ctx.moveTo(parseInt(pos[i]),parseInt(pos[i+1]));
|
||||
ctx.arc(parseInt(pos[i]), parseInt(pos[i+1]), 2, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function AutomowerConnectScale( ctx, picx, picy, scalx ) {
|
||||
// draw scale
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth=2;
|
||||
ctx.setLineDash([]);
|
||||
const l = 10;
|
||||
const scam = picx / scalx;
|
||||
ctx.moveTo(picx-l*scam-30, picy-30);
|
||||
ctx.lineTo(picx-l*scam-30,picy-20);
|
||||
ctx.lineTo(picx-30,picy-20);
|
||||
ctx.moveTo(picx-30, picy-30);
|
||||
ctx.lineTo(picx-30,picy-20);
|
||||
ctx.moveTo(picx-(l/2)*scam-30, picy-26);
|
||||
ctx.lineTo(picx-(l/2)*scam-30, picy-20);
|
||||
ctx.strokeStyle = '#ff8000';
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = 1;
|
||||
for (var i=1;i<l;i++){
|
||||
ctx.moveTo(picx-i*scam-30, picy-24);
|
||||
ctx.lineTo(picx-i*scam-30, picy-20);
|
||||
}
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.font = "16px Arial";
|
||||
ctx.fillStyle = "#ff8000";
|
||||
ctx.textAlign = "center";
|
||||
ctx.fillText( l+" Meter", picx-(l/2)*scam-30, picy-37 );
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
function AutomowerConnectChargingStation( ctx, csx, csy, csrel ) {
|
||||
if (parseInt(csx) > 0 && parseInt(csy) > 0) {
|
||||
// draw chargingstation
|
||||
ctx.beginPath();
|
||||
ctx.setLineDash([]);
|
||||
ctx.lineWidth=3;
|
||||
ctx.strokeStyle = '#ffffff';
|
||||
ctx.fillStyle= '#3d3d3d';
|
||||
if (csrel == 'right') ctx.arc(parseInt(csx)+13, parseInt(csy), 13, 0, 2 * Math.PI, false);
|
||||
if (csrel == 'bottom') ctx.arc(parseInt(csx), parseInt(csy)+13, 13, 0, 2 * Math.PI, false);
|
||||
if (csrel == 'left') ctx.arc(parseInt(csx)-13, parseInt(csy), 13, 0, 2 * Math.PI, false);
|
||||
if (csrel == 'top') ctx.arc(parseInt(csx), parseInt(csy)-13, 13, 0, 2 * Math.PI, false);
|
||||
if (csrel == 'center') ctx.arc(parseInt(csx), parseInt(csy), 13, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
|
||||
ctx.font = "16px Arial";
|
||||
ctx.fillStyle = "#f15422";
|
||||
ctx.textAlign = "center";
|
||||
if (csrel == 'right') ctx.fillText("CS", parseInt(csx)+13, parseInt(csy)+6);
|
||||
if (csrel == 'bottom') ctx.fillText("CS", parseInt(csx), parseInt(csy)+6+13);
|
||||
if (csrel == 'left') ctx.fillText("CS", parseInt(csx)-13, parseInt(csy)+6);
|
||||
if (csrel == 'top') ctx.fillText("CS", parseInt(csx), parseInt(csy)+6-13);
|
||||
if (csrel == 'center') ctx.fillText("CS", parseInt(csx), parseInt(csy)+6);
|
||||
|
||||
// draw mark
|
||||
ctx.beginPath();
|
||||
ctx.setLineDash([]);
|
||||
ctx.lineWidth=1;
|
||||
ctx.strokeStyle = '#f15422';
|
||||
ctx.fillStyle= '#3d3d3d';
|
||||
ctx.arc( parseInt(csx), parseInt(csy), 2, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
|
||||
function AutomowerConnectChargingStationPath ( ctx, pos ) {
|
||||
// draw path
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth=1;
|
||||
ctx.setLineDash([6, 2]);
|
||||
ctx.strokeStyle = '#999999';
|
||||
ctx.moveTo(parseInt(pos[0]),parseInt(pos[1]));
|
||||
for (var i=2;i<pos.length-1;i+=2){
|
||||
ctx.lineTo(parseInt(pos[i]),parseInt(pos[i+1]));
|
||||
}
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
//AutomowerConnectUpdateDetail (<devicename>, <type> <background-image path>, <imagesize x>, <imagesize y>, <relative positio of CS marker>,scalx <path array>, <property limits array>, <property limits array>)
|
||||
function AutomowerConnectUpdateDetail (dev, type, imgsrc, picx, picy, csx, csy, csrel, scalx, pos, lixy, plixy, posc) {
|
||||
// log('pos.length '+pos.length+' lixy.length '+lixy.length+', scalx '+scalx );
|
||||
// log('loop: Start '+ type+' '+dev );
|
||||
if (FW_urlParams.detail == dev || 1) {
|
||||
// if (FW_urlParams.detail == dev) {
|
||||
const canvas = document.getElementById(type+'_'+dev+'_canvas');
|
||||
if (canvas) {
|
||||
// log('loop: canvas true '+ type+' '+dev );
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// draw limits
|
||||
if ( lixy.length > 0 ) AutomowerConnectLimits( ctx, lixy, 0 );
|
||||
if ( plixy.length > 0 ) AutomowerConnectLimits( ctx, plixy, 1 );
|
||||
// draw scale
|
||||
AutomowerConnectScale( ctx, picx, picy, scalx );
|
||||
// draw charging station path
|
||||
AutomowerConnectChargingStationPath ( ctx, posc );
|
||||
|
||||
if ( pos.length > 4 ) {
|
||||
// draw path
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth=1;
|
||||
ctx.setLineDash([6, 2]);
|
||||
ctx.strokeStyle = '#ff0000';
|
||||
ctx.moveTo(parseInt(pos[2]),parseInt(pos[3]));
|
||||
for (var i=4;i<pos.length-1;i+=2){
|
||||
ctx.lineTo(parseInt(pos[i]),parseInt(pos[i+1]));
|
||||
}
|
||||
ctx.stroke();
|
||||
|
||||
// draw start
|
||||
ctx.beginPath();
|
||||
ctx.setLineDash([]);
|
||||
ctx.lineWidth=3;
|
||||
ctx.strokeStyle = 'white';
|
||||
ctx.fillStyle= 'black';
|
||||
ctx.arc(parseInt(pos[pos.length-2]), parseInt(pos[pos.length-1]), 4, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
|
||||
// draw mower
|
||||
ctx.beginPath();
|
||||
ctx.setLineDash([]);
|
||||
ctx.lineWidth=3;
|
||||
ctx.strokeStyle = '#ffffff';
|
||||
ctx.fillStyle= '#3d3d3d';
|
||||
ctx.arc(parseInt(pos[0]), parseInt(pos[1]-13), 13, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
|
||||
ctx.font = "20px Arial";
|
||||
ctx.fillStyle = "#f15422";
|
||||
ctx.textAlign = "center";
|
||||
ctx.fillText("M", parseInt(pos[0]), parseInt(pos[1]-7));
|
||||
// draw mark
|
||||
ctx.beginPath();
|
||||
ctx.setLineDash([]);
|
||||
ctx.lineWidth=1;
|
||||
ctx.strokeStyle = '#f15422';
|
||||
ctx.fillStyle= '#3d3d3d';
|
||||
ctx.arc(parseInt(pos[0]), parseInt(pos[1]), 2, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
//draw last line
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth=1;
|
||||
ctx.setLineDash([6, 2]);
|
||||
ctx.moveTo(parseInt(pos[0]),parseInt(pos[1]));
|
||||
ctx.lineTo(parseInt(pos[2]),parseInt(pos[3]));
|
||||
ctx.strokeStyle = '#ff0000';
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
// draw charging station
|
||||
AutomowerConnectChargingStation( ctx, csx, csy, csrel );
|
||||
// }
|
||||
// img.src = imgsrc;
|
||||
} else {
|
||||
setTimeout(()=>{
|
||||
// log('loop: canvas false '+ type+' '+dev );
|
||||
AutomowerConnectUpdateDetail (dev, type, imgsrc, picx, picy, csx, csy, csrel, scalx, pos, lixy, plixy);
|
||||
}, 100);
|
||||
}
|
||||
} else {
|
||||
setTimeout(()=>{
|
||||
// log('loop: detail false '+ type+' '+dev );
|
||||
AutomowerConnectUpdateDetail (dev, type, imgsrc, picx, picy, csx, csy, csrel, scalx, pos, lixy, plixy);
|
||||
}, 100);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user