Skip to content

Commit 0cf36be

Browse files
committed
Rework for compatibility to Sabo
1 parent b0da610 commit 0cf36be

8 files changed

Lines changed: 114 additions & 52 deletions

File tree

src/LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Licenses
2+
3+
This project uses some submodules from different authors:
4+
5+
Copyright for the module "jquery" are held by "jQuery Foundation, Inc. and other contributors" and are provided under the MIT license.
6+
Copyright for the module "inflate" are held by "Gildas Lormeau, 2013" and are provided under the BSD license.
7+
Copyright for the module "zip" are held by "Gildas Lormeau, 2013" and are provided under the BSD license.
8+
Copyright for the module "sprintf" are held by "Jakob Westhoff, 2010" and are provided under the MIT license.
9+
10+
The project WebVisu is provided under the MIT license as follows:
11+
12+
Copyright (c) 2013-2018 Frank Benkert (opensource@frank-benkert.de)
13+
14+
Permission is hereby granted, free of charge, to any person obtaining a copy
15+
of this software and associated documentation files (the "Software"), to deal
16+
in the Software without restriction, including without limitation the rights
17+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18+
copies of the Software, and to permit persons to whom the Software is
19+
furnished to do so, subject to the following conditions:
20+
21+
The above copyright notice and this permission notice shall be included in all
22+
copies or substantial portions of the Software.
23+
24+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30+
SOFTWARE.

src/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ PPOBJ = codesys.oo.js drawing.oo.js utils.oo.js WebVisuDev.oo.html
99
# steelseries
1010
SSSRC = steelseries-min.js
1111

12-
# steelseries.js codesys_ss.js drawing_ss.js
13-
1412
TARGET1 = ../release/WebVisu.html
1513
TARGET2 = ../release/WebVisuPlus.html
1614
TARGET3 = ../release/WebVisuPlusConfig.html
1715

1816
PPFLAGS =
1917

18+
HTMLTITLE := "WebVisu (!svnversion!)"
19+
2020
.PHONY: clean
2121

2222
all: $(TARGET1)
2323

2424
$(TARGET1): PPFLAGS =
2525
$(TARGET1): $(SRC) $(PPOBJ) release.pl
26-
perl release.pl WebVisuDev.oo.html > $(TARGET1)
26+
perl release.pl WebVisuDev.oo.html "$(HTMLTITLE)" > $(TARGET1)
2727

2828
$(TARGET2): PPFLAGS = -DUSE_STEELSERIES=1
2929
$(TARGET2): $(SRC) $(PPOBJ) $(SSSRC) release.pl
30-
perl release.pl WebVisuDev.oo.html > $(TARGET2)
30+
perl release.pl WebVisuDev.oo.html "$(HTMLTITLE)" > $(TARGET2)
3131

3232
$(TARGET3): PPFLAGS =
3333
$(TARGET3): $(SRC) $(PPOBJ) release.pl

src/WebVisuDev.pp.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
<head>
44
<meta charset="utf-8" />
55
<title>WebVisu (development)</title>
6+
<!--
7+
WebVisu
8+
Revision: !svnversion!
9+
https://sourceforge.net/projects/webvisu/
10+
-->
11+
612
<script src="jquery-2.0.3.min.js"></script>
713
<script src="jquery-ajax-blob-arraybuffer.js"></script>
814
<script src="zip.js"></script>

src/codesys.pp.js

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,21 @@ const POST_FORMAT_SOAP = 1
3939
var postFormat = POST_FORMAT_STANDARD;
4040

4141
/**
42-
Diese variable steuert ob Dateinamen (vor dem Laden vom Server) in
43-
Kleinbuchstaben umgewandelt werden sollen.
42+
Diese variable steuert ob Dateinamen (vor dem Laden vom Server) bezüglich
43+
Groß- und Kleinschreibung umgewandelt werden.
4444
45-
Hintergrund ist, dass einige Steuerungen Case-Sensitive sind; die User jedoch
46-
frei in der Eingabe. Es scheint so, als ob auf diesen Steuerungen die Dateien
47-
beim Hochladen in Kleinschreibung umgewandelt werden; die Namen in den Visu-
48-
Files bleiben jedoch CamelCase.
45+
Einige Steuerungen sind Case-Sensitive, andere nicht.
46+
Das Authoring-Tool scheint die Dateinamen jedoch nicht so zu vergeben wie es
47+
die jeweilige Steuerung erwartet.
48+
49+
Als Standardeinstellung wird jetzt FC_TOLOWER verwendet, was die meisten der
50+
Case-Sensitive Steuerungen erschlagen sollte und bei Case-Insensitive keine
51+
Rolle spielt.
4952
*/
50-
var filenamesLowercase = false;
53+
const FC_ORIGINAL = 0;
54+
const FC_TOLOWER = 1;
55+
const FC_TOUPPER = 2;
56+
var filenameCase = FC_TOLOWER;
5157

5258
var PendingMouseUpObjects = [];
5359

@@ -57,6 +63,25 @@ var parsedGroups = [];
5763
var inputFieldActive = false;
5864

5965

66+
function getFileName(fileName) {
67+
if(filenameCase==FC_TOLOWER) {
68+
return fileName.toLowerCase();
69+
} else if(filenameCase==FC_TOUPPER) {
70+
return fileName.toUpperCase();
71+
}
72+
return fileName;
73+
}
74+
75+
function getVisuFileName(visuName) {
76+
var fileName = plcDir + "/" + visuName;
77+
if (visuCompressed == 1) {
78+
fileName += "_xml.zip";
79+
} else {
80+
fileName += ".xml";
81+
}
82+
return getFileName(fileName);
83+
}
84+
6085
// constructor
6186
function expression(operation, count, value) {
6287
this.operation = operation;
@@ -86,6 +111,8 @@ function load_ini_success(content) {
86111
var $myMedia = $(this);
87112

88113
visuCompressed = $myMedia.find('compression').text() == "true" ? 1 : 0;
114+
// Option "Rahmen"->"Online automatisch anpassen"
115+
visuBestFit = $myMedia.find('best-fit').text() == "true" ? true : false;
89116

90117
extract_var_addr($myMedia);
91118
});
@@ -485,12 +512,16 @@ function load_visu_success(content) {
485512
// optional kann der Hintergrund auch aus einem Bitmap-File bestehen
486513
var bitmap = $myMedia.find('bitmap').text();
487514
if (bitmap.length) {
515+
// der Filename enthält evtl. Pfadangaben
516+
var bitmapFields = bitmap.split('\\');
517+
bitmap = bitmapFields[bitmapFields.length - 1];
488518
registerBitmap(
489519
0, 0, visuSizeX, visuSizeY,
490520
bitmap,
491521
'false', '0,0,0', '0,0,0',
492522
'false', '0,0,0', '0,0,0',
493-
0
523+
0,
524+
[]
494525
);
495526
}
496527

@@ -505,9 +536,9 @@ function load_visu_success(content) {
505536
* Die Datei auf unserer Steuerung heist: "dynamictexts_xml.zip" (alles klein?).
506537
*/
507538
dynTextFile = dynTextFile.replace(new RegExp('^.*[\\\\\\/]'), '');
508-
dynTextFile = dynTextFile.toLowerCase();
509539
if (visuCompressed == 1) {
510540
dynTextFile = dynTextFile.replace('.xml', '_xml.zip');
541+
dynTextFile = dynTextFile.replace('.XML', '_XML.ZIP');
511542
}
512543
visuUseDynamicText = true;
513544
} else {
@@ -520,7 +551,7 @@ function load_visu_success(content) {
520551
});
521552

522553
if (visuUseDynamicText) {
523-
load_dyntextfile(plcDir + "/" + dynTextFile);
554+
load_dyntextfile(getFileName(plcDir + "/" + dynTextFile));
524555
}
525556

526557
// Das einmalige Aufrufen der Update-Funktion startet den zyklischen Ablauf

src/drawing.pp.js

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var currentVisuLoaded = "";
2626
var visuCompressed = 0;
2727
var visuUseDynamicText = false;
2828
var visuDynTextDefaultLanguage = 'english';
29+
var visuBestFit = false;
2930

3031
// globale variablen
3132
var updateInterval = 500;
@@ -130,16 +131,7 @@ function switchToVisu(visu) {
130131
load_ini(plcDir + "/visu_ini.xml");
131132

132133
// neue Visu laden
133-
if (filenamesLowercase == true) {
134-
visu = visu.toLowerCase();
135-
}
136-
137-
var filename = plcDir + "/" + visu;
138-
if (visuCompressed == 1) {
139-
filename += "_xml.zip";
140-
} else {
141-
filename += ".xml";
142-
}
134+
var filename = getVisuFileName(visu);
143135
load_visu(filename);
144136
}
145137

@@ -260,12 +252,7 @@ function newButton(
260252
this.img = null;
261253
if (bitmapFilename.length) {
262254
this.img = new Image();
263-
264-
if (filenamesLowercase == true) {
265-
bitmapFilename = bitmapFilename.toLowerCase();
266-
}
267-
268-
this.img.src = plcDir + '/' + bitmapFilename;
255+
this.img.src = getFileName(plcDir + '/' + bitmapFilename);
269256
}
270257
}
271258

@@ -335,12 +322,7 @@ function newBitmap(
335322
this.h = parseInt(h);
336323
this.fileName = fileName;
337324
this.img = new Image();
338-
339-
if (filenamesLowercase == true) {
340-
fileName = fileName.toLowerCase();
341-
}
342-
343-
this.img.src = plcDir + '/' + fileName;
325+
this.img.src = getFileName(plcDir + '/' + fileName);
344326

345327
this.hasInsideColor = hasInsideColor;
346328
this.fillStyle = fillStyle;

src/release.pl

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@
22

33
use strict;
44

5-
my $ver = `svnversion .`;
6-
chomp($ver);
7-
my @verFields = split(/\:/, $ver);
8-
if( scalar(@verFields) == 2 ) { $ver = $verFields[1]; }
5+
# Kommandozeilen-Argumente
6+
my $g_sHtmlFileName = $ARGV[0] || die "no HTML Filename given";
7+
my $g_sHtmlTitle = $ARGV[1] || undef;
98

10-
open( INPUT, $ARGV[0] ) || die "can't open $ARGV[0]: $!";
9+
# SVN-Version des aktuellen Verzeichnisses ermitteln
10+
my $g_sSvnVersion = `svnversion .`;
11+
chomp($g_sSvnVersion);
12+
my @verFields = split(/\:/, $g_sSvnVersion);
13+
if( scalar(@verFields) == 2 ) { $g_sSvnVersion = $verFields[1]; }
14+
15+
16+
open( INPUT, $g_sHtmlFileName ) || die "can't open $g_sHtmlFileName: $!";
1117
while( <INPUT> ) {
1218
my $line = $_;
13-
$line =~ s/\(development\)/\(r$ver\)/;
19+
# Falls wir den HTML-Titel ersetzen sollen
20+
if( $g_sHtmlTitle ) {
21+
$line =~ s/<title>.*<\/title>/<title>$g_sHtmlTitle<\/title>/;
22+
}
23+
# Andere Wildcards...
24+
$line =~ s/\!svnversion\!/$g_sSvnVersion/;
1425
if( $line =~ /<script\ssrc="([^\"]+)"><\/script>/) {
1526
my $file = $1;
1627
# replace "preprocessed" filenames

src/release.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
# svn ci -m "..."
44

55
make clean
6-
make ../release/WebVisu.html
6+
make "$@" ../release/WebVisu.html
77

88
make clean
9-
make ../release/WebVisuPlus.html
9+
make "$@" ../release/WebVisuPlus.html
1010

1111
make clean
12-
make ../release/WebVisuPlusConfig.html
12+
make "$@" ../release/WebVisuPlusConfig.html
1313

1414
make clean
1515

src/utils.pp.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ function fileExists(url) {
8181
function determineVisuLocation() {
8282
// finden wir mal heraus wo unsere Visu liegt
8383
Log('determine visu location - searching visu_ini.xml');
84-
if (fileExists('/PLC/visu_ini.xml')) {
84+
if (fileExists('/plc/visu_ini.xml')) {
8585
// scheint eine Wago zu sein
86-
Log('found in /PLC');
87-
plcDir = "/PLC";
86+
Log('found in /plc');
87+
plcDir = "/plc";
8888
postUrl = '/plc/webvisu.htm';
8989
postFormat = POST_FORMAT_STANDARD;
9090
} else if (fileExists('/webvisu/visu_ini.xml')) {
@@ -93,14 +93,16 @@ function determineVisuLocation() {
9393
plcDir = "/webvisu";
9494
postUrl = '/webvisu/webvisu.htm';
9595
postFormat = POST_FORMAT_STANDARD;
96-
// es handelt sich um eine CaseSensitive Linux-Steuerung
97-
filenamesLowercase = true;
9896
} else if (fileExists('/visu_ini.xml')) {
99-
// könnte eine Beck sein
97+
// könnte eine Beck oder Sabo sein
10098
Log('found in /');
10199
plcDir = "";
102100
postUrl = '/webvisu.htm';
103101
postFormat = POST_FORMAT_STANDARD;
102+
if (fileExists('/WebVisu5.cfg')) {
103+
// ist eine Sabo mit Webserver ab V2180730
104+
Log('Detected Sabo PLC');
105+
}
104106
} else if (fileExists('/TcWebVisu/visu_ini.xml')) {
105107
// müsste ein TwinCat (Beckhoff) sein
106108
Log('found in /TcWebVisu');
@@ -116,7 +118,7 @@ function doPerfTest() {
116118
perfTestStart = new Date().getTime();
117119
for (a = 0; a < 10000; a++) {
118120
text = "dies ist ein | | kleiner |<|Test|>| um RegExp | | gegen |<|normalen|>| String-Replace zu vergleichen";
119-
// wegen des PreProcessors k�nnen wir leider keine /-Syntax f�r die RegEx nehmen
121+
// wegen des PreProcessors können wir leider keine /-Syntax für die RegEx nehmen
120122
text = text.replace(new RegExp('\\| \\|', 'g'), ' ');
121123
text = text.replace(new RegExp('\\|>\\|', 'g'), '>');
122124
text = text.replace(new RegExp('\\|<\\|', 'g'), '<');

0 commit comments

Comments
 (0)