# -*- coding: cp1252 -*-
'''
Created on 21.11.2011
@author: sth2mt
'''
import Serializer as XmlSerializer
import FertigungsTest.Tstfnc.Software as Software
import FertigungsTest.Tstfnc.LIC as LIC
import FertigungsTest.Tstfnc.Startschalter as Startschalter
import FertigungsTest.Tstfnc.R_L_Schalter as R_L_Schalter
import FertigungsTest.Tstfnc.Bedienelemente as Bedienelemente
import FertigungsTest.Tstfnc.Pixel as Pixel
import FertigungsTest.Tstfnc.Motor as Motor
import FertigungsTest.Tstfnc.Lautsprecher as Lautsprecher
import FertigungsTest.Tstfnc.Schraubstellenleuchte as LED
import FertigungsTest.Tstfnc.Scanner as Scanner
import FertigungsTest.Hardware.Typschild as Typschild
#import FertigungsTest.Tstfnc.Allgemein as Allgemein
# dir
# Tstfunc
# exit
Index = {"tag":0,"id":1,"name":2,"type":3,"unit":4,"info":5,"wert":6,"function":7,"param":8,"liste":9}
class XML_PruefString(XmlSerializer.Serializer):
'''
classdocs
'''
def __init__(self,mode):
'''
Constructor
'''
XmlSerializer.Serializer.__init__(self)
self.xml_Dummy = self.VerketteXML("TagAAAA", "BBBB", "CCCC", "DDDD", "EEEE", "Die Argumente id,name,type,unit,info sind optional und koennen wegfallen","ABC....1234567890", None, None, None)
#self.xml_WertMoment1 = self.VerketteXML("Wert", "1", "Moment", "float", "Nm", "Beispiel uebergabe Wert fuer Gemessenes Moment","13.063", None, None, None)
#self.xml_Bewertung = self.VerketteXML("Wert", "2", "Bewertung", "string", None, "Bewertung der Prueffunktion MotTst","OK", None, None, None)
#self.xml_ErrorCode = self.VerketteXML("Wert", "3", "Errorcode", "int", None, "Errocode der Prueffunktion MotTst","0", None, None, None)
#self.xml_Beschreibung = self.VerketteXML("Wert", "4", "Beschreibung", "string", None, "Beschreibung des Rueckgabewertes der Prueffunktion MotTst","Der Motortest verlief ohne Fehler", None, None, None)
#self.xml_Rueckgabewert = self.VerketteXML("Rueckgabewert", None, "MotTst", None, None, "Beispiel Rueckgabwert nach Ende der Prueffunktion MotTst",None, None, None, [self.xml_WertMoment1,self.xml_Bewertung,self.xml_Beschreibung])
self.xml_stop = self.VerketteXML("Command", "7", "stop", None, None, "Pruefschritt beenden", "stop",None,None, None)
self.xml_exit = self.VerketteXML("Command", "6", "exit", None, None, "Programm beenden", "exit",None,None, None)
self.xml_PrintActionText = self.VerketteXML("PrintActionText", None, None, "string", None, "Text zur Anzeige am Pruefstand im Action-Fenster", "Pruefprogramm Akkuschrauber wird initialisiert...",None,None, None)
self.xml_PrintMainText = self.VerketteXML("PrintMainText", None, None, "string", None, "Text zur Anzeige am Pruefstand im Main-Fenster", "Pruefprogramm Akkuschrauber",None,None, None)
self.xml_ForschrittsanzeigeZustand = self.VerketteXML("Wert", "1", "Enable", "bool", None, "Enable/Disable Fortschrittsanzeige ""0/1""", "1",None,None, None)
self.xml_ForschrittsanzeigeWert = self.VerketteXML("Wert", "2", "Prozent", "int", "prozent", "Fortschrittsanzeige in Prozent 0..100", "18",None,None, None)
self.xml_Forschrittsanzeige = self.VerketteXML("PrintProgressBar", None, None, "string", None, "Zustand Fortschrittsanzeige am Pruefstand anzeigen", None,None,None, [self.xml_ForschrittsanzeigeZustand,self.xml_ForschrittsanzeigeWert])
self.xml_dir = self.VerketteXML("Command", "1", "dir", None, None, "Liste aller Kommandos ohne Prueffunktionen", "dir",None, None, None)
self.xml_MacAdress = self.VerketteXML("Command","2", "GetMacAdress", None, None, "Gibt String MacAdresse zurueck#100","GetMAC", None, None, None)
self.xml_Flashen = self.VerketteXML("Command", "3","WriteFlash", None, None, "Kernel,Rootfs,LT-FW und Typschild schreiben#200#Fehler Software/Typschild flashen","WrFlash", Software, mode, None)
self.xml_PwrDwn = self.VerketteXML("Command", "5", "PowerDown", None, None, "Schickt Akkuschrauber in Powerdown#300#Fehler bei Powerdown","PwrDwn", None, None, None)
self.xml_Testfunctions = self.VerketteXML("Command", "4", "Testfunctions", None, None, "Gibt Liste Prueffunktionen zurueck","Tstfunc", self.BuildPruefCommands, None, None)
self.xml_Lic = self.VerketteXML("Command", "10", "LicTest", None, None, "LitiumIntegratedCapacitor pruefen#2000#Fehler LIC (Lithium Ionen Kondensator)","LicTst", LIC, None, None)
self.xml_Switch = self.VerketteXML("Command", "1", "StartSwitchTest", None, None, "Test Startschalter#500#Fehler Startschalter", "ToolSwitchTst", Startschalter, None, None)
self.xml_SwitchRL = self.VerketteXML("Command", "2", "ProgramSelectorTest", None, None, "Rechts/Links Schalter pruefen#600#Fehler Rechts/Links-Schalter", "DirSwitchTst", R_L_Schalter, None, None)
self.xml_Bedienelemente = self.VerketteXML("Command", "3", "FunctionKeysTest", None, None, "Bedienelemente pruefen#700#Fehler Bedienelemente Display","CntrlBtnTst", Bedienelemente, None, None)
self.xml_Sound = self.VerketteXML("Command", "5", "LoudSpeakerTest", None, None, "Lautsprecher pruefen#800#Fehler Lautsprecher","LdSpkTst", Lautsprecher, None, None)
self.xml_Led = self.VerketteXML("Command", "6", "LEDsTest", None, None, "Schraubstellenleuchte und Farb-LED's pruefen#900#Fehler LED's","LedTst", LED, None, None)
self.xml_Auto = self.VerketteXML("Command", "7", "AutoTest", None, None, "Vollautomatischer Test verschiedener Komponenten#1000#Fehler Autotest","AutoTst", self.Dummy, None, None)
self.xml_Pixel = self.VerketteXML("Command", "4", "DisplayTest", None, None, "Display auf Pixelfehler pruefen#1100#Fehler Display (Pixel)","PxlTst", Pixel, None, None)
self.xml_Scanner = self.VerketteXML("Command", "8", "BarcodeScannerTest", None, None, "Barcodescanner pruefen#1200#Fehler Barcodescanner","ScnTst", Scanner , None, None)
self.xml_Antrieb = self.VerketteXML("Command", "6", "SpeedMeasurementTest", None, None, "Antriebskette pruefen#1300#Fehler Motortest","MotTst", Motor, None, None)
self.xml_TypRd = self.VerketteXML("Command", "11", "TypePlateRead", None, None, "BRC Typschild lesen#3000#Fehler BRC Typschild lesen","TypPltRd", Typschild, None, None)
self.xml_TypWr = self.VerketteXML("Command", "12", "TypePlateWrite", None, None, "BRC Typschild schreiben#3500#Fehler BRC Typschild schreiben","TypPltWr", Typschild, None, None)
self.xml_Commands = self.VerketteXML("Commands", None, None, None, None, "Liste aller Kommandos ohne Prueffunktionen", None,dir, None, [self.xml_dir,self.xml_MacAdress,self.xml_Flashen,self.xml_Testfunctions,\
self.xml_PwrDwn,self.xml_exit,self.xml_TypRd,self.xml_TypWr])
self.xml_PruefCommands = self.VerketteXML("Commands", None, "Tstfunc", None, None, "Liste Prueffunktionen", None, dir, None, [self.xml_Switch,self.xml_SwitchRL,self.xml_Bedienelemente,self.xml_Pixel,self.xml_Sound,self.xml_Led,self.xml_Antrieb,self.xml_Scanner,self.xml_Lic])
self.xml_WebPruefCommands = self.VerketteXML("Commands", None, "Tstfunc", None, None, "Liste Browser Prueffunktionen", None, dir, None, [self.xml_Switch,self.xml_SwitchRL,self.xml_Bedienelemente,self.xml_Pixel,self.xml_Sound,self.xml_Led,self.xml_Antrieb])
self.xml_WebPruefCommandsWithScanner = self.VerketteXML("Commands", None, "Tstfunc", None, None, "Liste Browser Prueffunktionen", None, dir, None, [self.xml_Switch,self.xml_SwitchRL,self.xml_Bedienelemente,self.xml_Pixel,self.xml_Sound,self.xml_Led,self.xml_Antrieb,self.xml_Scanner])
#self.xml_PruefCommands = self.VerketteXML("Commands", None, "Tstfunc", None, None, "Liste Prueffunktionen", None, dir, None, [self.xml_Switch,self.xml_SwitchRL,self.xml_Bedienelemente,self.xml_Pixel,self.xml_Sound,self.xml_Antrieb,self.xml_Lic])
def __del__(self):
'''
Destructor
'''
pass
def Dummy(self):
pass
def BuildDummy(self):
return self.BuildTag(self.xml_Dummy)
pass
def BuildCommands(self):
return self.BuildTag(self.xml_Commands)
pass
def BuildPruefCommands(self):
return self.BuildTag(self.xml_PruefCommands)
def BuildWebPruefCommands(self):
# BarCode Scanner in Typschild
O_Typschild = Typschild.Treiber()
sInhalt = O_Typschild.ReadBrcStatParFromEeprom()
h_Typschild_Typ=O_Typschild.getStatValue(sInhalt, "Komponententyp")
del(O_Typschild)
if (h_Typschild_Typ & 0x02) == 0x02:
# Barcode Scanner Typ -> Barcodescanner Test anbieten
return self.BuildTag(self.xml_WebPruefCommandsWithScanner)
else:
# kein Barcodescanner Typ
return self.BuildTag(self.xml_WebPruefCommands)
pass
def BuildPrintMainText(self,sText):
xml_PrintMainText = self.VerketteXML("PrintMainText", None, None, "string", None, "Text zur Anzeige am Pruefstand im Main-Fenster",sText,self.Dummy,None, None)
return self.BuildTag(xml_PrintMainText)
pass
def BuildPrintActionText(self,sText):
xml_PrintActionText = self.VerketteXML("PrintActionText", None, None, "string", None, "Text zur Anzeige am Pruefstand im Action-Fenster", sText,self.Dummy,None, None)
return self.BuildTag(xml_PrintActionText)
pass
def BuildProgressbar(self,iProzent,bOn=True):
if iProzent < 0 :
iProzent = 0
if iProzent > 100 :
iProzent = 100
xml_ForschrittsanzeigeZustand = self.VerketteXML("Wert", "1", "Enable", "bool", None, "Enable/Disable Fortschrittsanzeige ""0/1""", ("True" if bOn else "False"),self.Dummy,None, None)
xml_ForschrittsanzeigeWert = self.VerketteXML("Wert", "2", "Prozent", "int", "prozent", "Fortschrittsanzeige in Prozent 0..100", "%u"%iProzent,self.Dummy,None, None)
xml_Forschrittsanzeige = self.VerketteXML("PrintProgressBar", None, "ProgressBar", None, None, "Zustand Fortschrittsanzeige am Pruefstand anzeigen", None,self.Dummy,None, [xml_ForschrittsanzeigeZustand,xml_ForschrittsanzeigeWert])
return self.BuildTag(xml_Forschrittsanzeige)
pass
def BuildWert(self,str_id,str_name,str_type,str_unit,str_info,str_wert):
xml_Wert = self.VerketteXML("Wert", str_id, str_name, str_type, str_unit, str_info, str_wert, None, None, None)
return self.BuildTag(xml_Wert)
pass
def BuildRueckgabewert(self,s_Name,s_Info,xml_Wert,iErrorCode,sBeschreibung):
xml_ErrorCode = self.VerketteXML("Wert", None, "Errorcode", "int", None, None,"%d"%iErrorCode, None, None, None)
if xml_Wert:
if sBeschreibung :
xml_Beschreibung = self.VerketteXML("Wert", "3", "Beschreibung", "string", None, "Beschreibung des Rueckgabewertes",sBeschreibung, None, None, None)
xml_Rueckgabewert = self.VerketteXML("Rueckgabewert", None, s_Name, None, None, s_Info,None, None, None, [xml_ErrorCode,xml_Wert,xml_Beschreibung])
else :
xml_Rueckgabewert = self.VerketteXML("Rueckgabewert", None, s_Name, None, None, s_Info,None, None, None, [xml_ErrorCode,xml_Wert])
elif sBeschreibung :
xml_Beschreibung = self.VerketteXML("Wert", "2", "Beschreibung", "string", None, "Beschreibung des Rueckgabewertes",sBeschreibung, None, None, None)
xml_Rueckgabewert = self.VerketteXML("Rueckgabewert", None, s_Name, None, None, s_Info,None, None, None, [xml_ErrorCode,xml_Beschreibung])
else :
xml_Rueckgabewert = self.VerketteXML("Rueckgabewert", None, s_Name, None, None, s_Info,None, None, None, [xml_ErrorCode])
return self.BuildTag(xml_Rueckgabewert)
pass
def BuildTimeout(self,iTimeout,sFunction=None):
xml_TimeoutWert = self.VerketteXML("Wert", None, "Timeout", "int", "s", "Timeout [1..9999] in s , [-1] = Funktion abgebrochen mit Fehler", "%d"% iTimeout,self.Dummy,None, None)
xml_Timeout = self.VerketteXML("Timeout", None, sFunction, None, None, "Timeout der aufgerufenen Funktion %s"%sFunction, None,None,None, [xml_TimeoutWert])
return self.BuildTag(xml_Timeout)
pass
pass