' Description: Export of labels in WAGO Script format ' Modules: 0x00001e7f (valid for all modules exept for E³.logic) ' ' Description_01: Labeling systems\WAGO Script ' Description_44: Labeling systems\WAGO Script ' Description_49: Beschriftungssysteme\WAGO Script ' Description_33: Systèmes d'étiquetage\WAGO Script ' Description_34: Sistemas etiquetación\WAGO Script ' Description_39: Sistemi di siglatura\WAGO Script ' Description_55: Systemas de Etiquetamento\WAGO Script ' Description_07: ??????? ?????????? ????????/???\WAGO Script ' Description_86: ????\WAGO Script ' Description_90: Labeling systems\WAGO Script ' ImagePath: .\AddOn Icons\WAGO_Script.bmp ' ' Changes: ' 03.07.2002 CIM-Team Initial Version ' 19.08.2004 CIM-Team Added control of internal/external execution ' 11.08.2005 CIM-Team added chinese and rus translation ' 16.05.2006 CT[1s] Änderung laut Hr.Tiedemann, Ausgabe des Labels nur ' BMK ohne Minuszeichen ' - EOH - '... ' Connect to application and declare object variables to call methods later set File = CreateObject("Scripting.FileSystemObject")' Connect to application Set App = ConnectToE3 set Job = App.CreateJobObject set Dev = Job.CreateDeviceObject set Pin = Job.CreatePinObject set WshShell = CreateObject("WScript.Shell") message = """" & App.GetInstallationPath & "scripts\message.vbs" & """" if Job.GetId = 0 then WshShell.run message & " No_Project" wscript.quit end if nAlls = Job.GetAllDeviceCount ' get device count if nAlls = 1 then WshShell.run message & " No_Components" wscript.quit end if ' ***************************************************************************************** ' * * ' * Originalzeilen auskommentiert um spezielle Suffix "*.stu" für XXXXX zu generieren. * ' * 05.09.06, by XXXXXXXXXXXXXXXXXXX * ' * * ' * DirectoryName = Job.GetPath * ' * * ' * * ' * FName1 = DirectoryName & Job.GetName & "_wago_terminals.dat" * ' * FName2 = DirectoryName & Job.GetName & "_wago_devices.dat" * ' * * ' ***************************************************************************************** DirectoryName = "C:\_Etiketten\" FName1 = DirectoryName & Job.GetName & "_wago_terminals.stu" FName2 = DirectoryName & Job.GetName & "_wago_devices.stu" File.CreateTextFile FName1 'Create terminal file Set WirFile1 = File.GetFile(FName1) Set FileId1 = WirFile1.OpenAsTextStream(2, -2) File.CreateTextFile FName2 'Create device file Set WirFile2 = File.GetFile(FName2) Set FileId2 = WirFile2.OpenAsTextStream(2, -2) 'FileId1.WriteLine "# All pin numbers of terminals (Created by E³.series 2003 from CIM-Team) " 'FileId1.WriteLine "#---------------------------------------------------------------------------------" 'FileId1.WriteLine "# Assignment Location Designation Pin " 'FileId1.WriteLine "# 1-20 22-41 43-62 64-79 " 'FileId1.WriteLine "#---------------------------------------------------------------------------------" 'FileId2.WriteLine "# All device designations (Created by E³.series 2003 from CIM-Team) " 'FileId2.WriteLine "#---------------------------------------------------------------------------------" 'FileId2.WriteLine "# empty empty empty Designation " 'FileId2.WriteLine "# 1-20 22-41 43-62 64-79 " 'FileId2.WriteLine "#---------------------------------------------------------------------------------" ReDim DevIds(nAlls), DevTab(nAlls), DevFlag(nAlls) Job.GetAllDeviceIds Ids ' get all device ids for i = 1 to nAlls DevIds(i) = Ids(i) Dev.SetId DevIds(i) if Dev.IsWireGroup = 1 or Dev.IsCable = 1 then DevFlag(i) = 0 elseif Dev.IsTerminal = 1 then DevFlag(i) = 1 else DevFlag(i) = 2 end if DevTab(i) = Shift_Text_Left("",21) & Shift_Text_Left("",21) & Shift_Text_Left(Mid(Dev.GetName,2),21) '[1s] ' DevTab(i) = Shift_Text_Left(Dev.GetAssignment,21) & Shift_Text_Left(Dev.GetLocation,21) & Shift_Text_Left(Dev.GetName,21) Next sorted = 1 ' sort according to while sorted = 1 ' - device designation sorted = 0 for n = 1 to nAlls-1 if DevTab(n) > DevTab(n+1) then sorted = 1 zDevName = DevTab(n) zDevId = DevIds(n) zDevFlag = DevFlag(n) DevTab(n) = DevTab(n+1) DevIds(n) = DevIds(n+1) DevFlag(n) = DevFlag(n+1) DevTab(n+1) = zDevName DevIds(n+1) = zDevId DevFlag(n+1) = zDevFlag end if next wend for n = 1 to nAlls Dev.SetId DevIds(n) if DevFlag(n) = 1 then ' Terminal OldPinName = "" nPins = Dev.GetPinCount Dev.GetPinIds PinIds for p = 1 to nPins Pin.SetId PinIds(p) PinName = GetInternalDevice & Pin.GetName if OldPinName <> PinName then FileId1.WriteLine(DevTab(n) & Shift_Text_Left(PinName,16)) OldPinName = PinName end if next elseif DevFlag(n) = 2 then ' Normal Device FileId2.WriteLine(SPACE(63) & Shift_Text_Left(replace(DevTab(n), " ", ""),16)) end if next 'FileId1.WriteLine "#---------------------------------------------------------------------------------" 'FileId2.WriteLine "#---------------------------------------------------------------------------------" FileId1.Close ' close files FileId2.Close WshShell.run message & " Files_Created", 7, true App.PutInfo 0, " " & FName1 & vbCrLf & _ " " & FName2 set app = nothing wscript.quit ' ---------------------------------------------------------------------------------------------- function Shift_Text_Left (Text, TotalLength) TextLength = len(Text) if TextLength < TotalLength then Shift_Text_Left = Text & SPACE(TotalLength-TextLength) else Shift_Text_Left = left(Text,TotalLength) end if end function ' ---------------------------------------------------------------------------------------------- function GetInternalDevice text = Pin.GetAttributeValue(".CONNECTOR_NAME") if text <> "" then text = text & "." GetInternalDevice = text end function ' ---------------------------------------------------------------------------------------------- ' check for several E3 processes and if process is running internally or externally function ConnectToE3 if InStr(WScript.FullName, "E³") then set ConnectToE3 = WScript ' internal else strComputer = "." set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colItems = objWMIService.ExecQuery("Select * from Win32_Process",,48) ProcessCnt = 0 for each objItem in colItems if InStr(objItem.Caption, "E3.series") then ProcessCnt = ProcessCnt + 1 next set objWMIService = Nothing set colItems = Nothing if ProcessCnt > 1 then MsgBox "More than one E3-Application running. Script can't run as external program." & vbCrLf &_ "Please close the other E3-Applications.", 48 WScript.Quit else set ConnectToE3 = CreateObject ("CT.Application") ' external end if end if end function ' ----------------------------------------------------------------------------------------------