EcoStruxure Machine Expert Version 1.1 unterstützt nicht die Controller M258, LMC058 und LMC078.

Skripts ausführen

Überblick

Sie können Skript-Dateien (filename.py), die eine Sequenz an Skript-Befehlen enthalten, auf der EcoStruxure Machine Expert Benutzeroberfläche ausführen.

Für weitere Informationen zum Ausführen von Skripts auf der EcoStruxure Machine Expert Benutzeroberfläche, beziehen Sie sich bitte auf das Kapitel Skriptbefehle.

Batchdateien

Häufig benutzte Befehle

Befehl

Beschreibung

-    REM  oder ::

Diese Zeile ist ein Kommentar und wird ignoriert werden.

cd

Wechselt zu einem anderen Verzeichnis.

echo off

Diese Befehle werden nicht angezeigt.

Um zu verhindern, dass einzelne Befehle angezeigt werden, fügen Sie das Zeichen @ vor dem Befehl ein.

echo

Zeigt eine Zeichenfolge oder eine Variable auf der Programmierkonsole an.

set

Deklariert eine Variable und weist der Variablen einen Wert zu.

>

Schreibt die Ausgabe in eine Datei. Wenn die Datei bereits existiert, wird sie überschrieben.

>>

Fügt die Ausgabe einer Datei hinzu. Wenn die Datei noch nicht existiert, wird sie erstellt.

Anwendungsbeispiel:

@echo off
REM Go to the directory where EcoStruxure Machine Expert is installed
cd "<Replace this with the path to the LogicBuilder.exe, for example, C:\Program Files (x86)\Schneider Electric\SoMachine Software\>"
REM Run LogicBuilder.exe with no graphical user interface and the full path to the script
LogicBuilder.exe --noui --runscript="<Replace this with the full file path where the script is stored, for example, D:\MyScripts\TestScript.py>"
pause

C# Konsolenanwendung

Wenn Sie ein Skript in einer C#-Anwendung ausführen, dann können Sie das Skript dynamisch bearbeiten, bevor das Skript von der Maschine ausgeführt wird. Außerdem können Sie auch einige vorangegangene Schritte in der C#-Anwendung durchführen

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ExecuteScriptExample
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                ProcessStartInfo psi = new ProcessStartInfo();
                
                // Specify the name and the arguments you want to pass
                psi.FileName = @"<Replace this with the path to the LogicBuilderShell.exe, for example, C:\Program Files (x86)\Schneider Electric\SoMachine Software\LogicBuilderShell.exe";
                psi.Arguments = "\ "<Replace this with the full file path where the script is stored, for example, D:\MyScripts\TestScript.py\"";
                // Create new process and set the starting information
                Process p = new Process();
                p.StartInfo = psi;
                // Set this so that you can tell when the process has completed
                p.EnableRaisingEvents = true;
                p.Start();
                // Wait until the process has completed
                while (!p.HasExited)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            Console.ReadKey();
        }
    }
}