Light.Switching.1/1/16 Spiserom Lampe i vindu switching Virtuel EIS 1 'Switching' (1 Bit) Low
Heating/Cooling.Actual.3/1/1 Stue heating current temperature Uncertain (2 Byte) Low
Scaling.Dimming.1/1/38 Trapperom Lampett vegg Dimming EIS 6 'Scaling' (1 Byte) Low
Spiserom_Lampe_i_vindu_switching_Virtuel: FbDPT_Bool;
Stue_heating_current_temperature: FbDPT_Value_Temp;
Trapperom_Lampett_vegg_Dimming: FbDPT_Scaling;
Spiserom_Lampe_i_vindu_switching_Virtuel: BOOL;
Stue_heating_current_temperature: REAL;
Trapperom_Lampett_vegg_Dimming: REAL;
#!/bin/bash
OLD="xyz"
NEW="abc"
DPATH="/home/caesar/knx/opc/*.esf"
BPATH="/home/caesar/knx/codesys"
TFILE="/tmp/out.tmp.$$"
[ ! -d $BPATH ] && mkdir -p $BPATH || :
for f in $DPATH
do
if [ -f $f -a -r $f ]; then
/bin/cp -f $f $BPATH
sed "s/$OLD/$NEW/g" "$f" > $TFILE && mv $TFILE "$f"
else
echo "Error: Cannot read $f"
fi
done
/bin/rm $TFILE
#!/usr/bin/python
import os
max_lines_per_file = 250
found_no_type = 'FoundNoAppropriateType'
def getName(name):
resultingName = ''
if name[0].isdigit():
resultingName = '_'
for i in name:
if i.isalnum():
resultingName += i
else:
resultingName += '_'
return resultingName
def getNormalName(n, t):
if '(1 Bit)' in t:
return n + '1B'
return n + '1R'
class OutputFile(object):
def __init__(self, filename):
self.basename = filename[0:filename.rfind('.')]
self.filecounter = 1
self.linecounter = 1
self.outfile = self.getOutFile()
def getOutFileName(self):
return '%s.ou%d' % (self.basename, self.filecounter)
def getOutFile(self):
return open(self.getOutFileName(), 'w')
def getNormalType(self, t):
if '(1 Bit)' in t:
return 'BOOL'
if '(1 Byte)' in t or '(2 Byte)' in t:
return 'REAL'
return found_no_type
def getSpecialType(self, n, t):
if '(1 Bit)' in t:
return 'FbDPT_Bool'
if '(2 Byte)' in t:
return 'FbDPT_Value_Temp'
if '(1 Byte)' in t:
return 'FbDPT_Scaling'
print '%s:%d: No matching type found for %s' % (self.getOutFileName(), (self.linecounter*2)-1, n)
return found_no_type
def write(self, n, t):
if self.linecounter > max_lines_per_file:
self.filecounter += 1
self.linecounter = 1
self.outfile.close()
self.outfile = self.getOutFile()
self.outfile.write('%s: %s;\n' % (n, self.getSpecialType(n, t)))
self.outfile.write('%s: %s;\n' % (getNormalName(n, t), self.getNormalType(t)))
self.linecounter += 1
def close(self):
self.outfile.close()
class UniqueFilenameChecker(object):
def __init__(self):
self.varnames = {}
def check(self, name):
if name in self.varnames.keys():
return self.makeunique(name)
self.varnames[name] = True
return name
def makeunique(self, name):
newid = 1
newname = '%s_%d' % (name, newid)
while newname in self.varnames.keys():
newid += 1
newname = '%s_%d' % (name, newid)
self.varnames[newname] = True
return newname
def translateFile(filename):
outfile = OutputFile(filename)
for line in open(filename).readlines():
splitted = line.split('\t')
if len(splitted) < 4:
continue
name = uniqueFilename.check(getName(splitted[1]))
outfile.write(name, splitted[2])
outfile.close()
def getAllFiles():
return [ x for x in os.listdir('.') if x.endswith('.esf') ]
uniqueFilename = UniqueFilenameChecker()
for f in getAllFiles():
translateFile(f)
TranslateEsf.py
Dette er et Python script som tar *.esf fil exportert fra ETS (exporter til OPC) og konverterer den slik at informasjonen kan
limes inn i CodeSys.
Scriptet krever python-2.x.x.
Installer python-2.x.x på maskinen. Legg python i PATH.
Når script skal kjøres legges *.esf fila og script i samme mappe.
Dobbelt klikk på <TranslateEsf.py>
Filen leser *.esf fila.
Fjerner overflødig tekst og legger sammen linjer.
Fjerner ÆØÅ og restatter disse _.
Legger på REAL OG BOOL
Hvis det er mer en 500 elementer deles dette på flere filer
Output fil er *.ou*
Eks:
IJ BYGG
IJ BYGG
Kjeller.Varme/Kjøl.0/0/1 Rom 013 Comfort Mode EIS 1 'Switching' (1 Bit) Low
Kjeller.Varme/Kjøl.0/0/2 Rom 013 Standby Mode EIS 1 'Switching' (1 Bit) Low
Kjeller.Varme/Kjøl.0/0/3 Rom 013 Temp Value Uncertain (2 Byte) Low
Kjeller.Varme/Kjøl.0/0/4 Rom 013 Set Temp Uncertain (2 Byte) Low
Kjeller.Varme/Kjøl.0/0/5 Rom 013 Ønsket Temp Uncertain (2 Byte) Low
Rom_013_Comfort_Mode: FbDPT_Bool;
Rom_013_Comfort_Mode1B: BOOL;
Rom_013_Standby_Mode: FbDPT_Bool;
Rom_013_Standby_Mode1B: BOOL;
Rom_013_Temp_Value: FbDPT_Value_Temp;
Rom_013_Temp_Value1R: REAL;
Rom_013_Set_Temp: FbDPT_Value_Temp;
Rom_013_Set_Temp1R: REAL;
Rom_013__nsket_Temp: FbDPT_Value_Temp;
Rom_013__nsket_Temp1R: REAL;
Scriptet er laget av:
Ivar Mossin
Espen Bø
Registrerte brukere: Google [Bot]