Voraussetzung
-
Die TIA Portal Openness-Anwendung ist mit dem TIA Portal verbunden.
Siehe Verbindung zum TIA Portal herstellen -
Ein Projekt ist geöffnet.
Siehe Öffnen eines Projekts
Anwendung
Sie können mit der TIA Portal Openness-Anwendung sowohl in den primären PLC als auch in den Backup-PLC eines R/H-Systems laden. Sie können sowohl Hardware- als auch Softwarekomponenten des Systems laden. (Weitere Informationen finden Sie unter Hardware- und Softwarekomponenten ins PLC-Gerät laden)
Programmcode: RHDownloadProvider abrufen
Über RHDownloadProvider service können Sie aus einem Gerät in ein R/H-System laden.
Ändern Sie folgenden Programmcode, um RHDownloadProvider abzurufen:
|
... Device device = project.Devices.Find("S7-1500R/H-System_1"); RHDownloadProvider rhDownloadProvider = device.GetService<RHDownloadProvider>(); ... |
|
Hinweis Auf den Dienst DownloadProvider wird nicht im Zusammenhang mit CPUs zugegriffen, die zum R/H-System gehören. |
Programmcode: IConfiguration abrufen
RHDownloadProvider stellt das Objekt ConnectionConfiguration über die Eigenschaft Configuration zur Verfügung, mit deren Hilfe die Verbindung zum Gerät konfiguriert wird. Für Informationen über IsSecureCommunication siehe Unterstützung der sicheren S7-Kommunikation TLS
Ändern Sie folgenden Programmcode, um das Objekt IConfiguration über ConnectionConfiguration an RHDownloadProvider abzurufen:
|
... RHDownloadProvider rhDownloadProvider = device.GetService<RHDownloadProvider>(); ConnectionConfiguration connectionConfiguration = rhDownloadProvider.Configuration; ConfigurationMode mode = connectionConfiguration.Modes.Find("PN/IE"); ConfigurationPcInterface pcInterface = mode.PcInterfaces.Find("Broadcom NetXtreme Gigabit Ethernet", 1); IConfiguration targetConfiguration = pcInterface.TargetInterfaces.Find("1 X1"); ... |
|
Hinweis R/H Systeme bestehen aus zwei PLCs. Es wird nur ein Verbindungskonfigurationsobjekt bereitgestellt, das zum Laden sowohl in primäre PLCs als auch in Backup-PLCs verwendet werden kann. |
Programmcode: In primäre CPU und Backup-CPU laden
Ändern Sie folgenden Programmcode, um durch Aufrufen von RHDownloadProvider.DownloadToPrimary in den primären PLC zu laden:
|
DownloadResult DownloadToPrimary(configuration, preDownloadConfigurationDelegate, postDownloadConfigurationDelegate, downloadOptions); |
Ändern Sie folgenden Programmcode, um durch Aufrufen von RHDownloadProvider.DownloadToBackup in den Backup-PLC zu laden:
|
DownloadResult DownloadToBackup(configuration, preDownloadConfigurationDelegate, postDownloadConfigurationDelegate, downloadOptions); |
Parameter der Methode RHDownloadProvider
Sowohl RHDownloadProvider.DownloadToPrimary als auch RHDownloadProvider.DownloadToBackup akzeptieren dieselben Parameter und geben ebenfalls ein DownloadResult zurück. Weitere Informationen zu den Details von IConfiguration, DownloadConfigurationDelegate, DownloadOptions und DownloadResult finden Sie unter Hardware- und Softwarekomponenten ins PLC-Gerät laden
|
Parametername |
Typ |
Beschreibung |
|---|---|---|
|
configuration |
Siemens.Engineering.Connection.IConfiguration |
Konfiguration der Verbindung mit einem Gerät. |
|
onlineAddress |
Siemens.Engineering.Connection.ConfigurationAddress |
Optionaler Parameter für das Laden in eine geänderte IP-Adresse |
|
preDownloadConfigurationDelegate |
Siemens.Engineering.Download.DownloadConfigurationDelegate |
Delegate, der aufgerufen wird, um die Konfiguration vor dem Laden zu prüfen |
|
postDownloadConfigurationDelegate |
Siemens.Engineering.Download.DownloadConfigurationDelegate |
Delegate, der aufgerufen wird, um die Konfiguration nach dem Laden zu prüfen |
|
downloadOptions |
Siemens.Engineering.Download.DownloadOptions |
Download-Optionen |
Sie haben je nach Zustand des R/H-Systems die Möglichkeit, über DownloadConfigurations für den Ladevorgang einen Stopp des Systems anzufordern. Deshalb werden zusätzlich zu der Konfiguration, die unter Hardware- und Softwarekomponenten ins PLC-Gerät laden beschrieben ist, auch die folgenden Datentypen zur Unterstützung von RHDownload hinzugefügt.
|
Konfiguration |
Datentyp |
Aktion |
Beschreibung |
|---|---|---|---|
|
DownloadSelectionConfiguration |
StopHSystem |
Set CurrentSelection:StopHSystemSelections. Verfügbare Enumerationswerte:
|
Die Module werden gestoppt, um das Laden in ein Gerät zu ermöglichen. |
|
StopHSystemOrModule |
Set CurrentSelection:StopHSystemOrModuleSelections. Verfügbare Enumerationswerte:
|
Die Module werden gestoppt, um das Laden in ein Gerät zu ermöglichen. |
|
|
StartBackupModules |
Set CurrentSelection:StartBackupModulesSelections. Verfügbare Enumerationswerte:
|
Module nach dem Laden ins Gerät starten. |
|
|
SwitchBackupToPrimary |
Set CurrentSelection:SwitchBackupToPrimarySelections. Verfügbare Enumerationswerte:
|
Module nach dem Laden ins Gerät starten. |
Programmcode: Ladekonfiguration in Rückrufen handhaben
Ändern Sie folgenden Programmcode in Aufrufe von DownloadToPrimary und DownloadToBackup während der Behandlung von Konfigurationen in Rückrufen:
|
static void Main(string[] args) { ... Project project = tiaPortal.Projects[0]; Device device = project.Devices.Find("S7-1500R/H-System_1"); RHDownloadProvider rhDownloadProvider = device.GetService<RHDownloadProvider>(); ConnectionConfiguration connectionConfiguration = rhDownloadProvider.Configuration; ConfigurationMode mode = connectionConfiguration.Modes.Find("PN/IE"); ConfigurationPcInterface pcInterface = mode.PcInterfaces.Find("Broadcom NetXtreme Gigabit Ethernet", 1); IConfiguration targetConfiguration = pcInterface.TargetInterfaces.Find("1 X1"); // Download to primary DownloadResult primaryDownloadResult = rhDownloadProvider.DownloadToPrimary(targetConfiguration, PreConfigureDownloadCallback, PostConfigureDownloadCallback, DownloadOptions.Hardware | DownloadOptions.Software); WriteDownloadResults(primaryDownloadResult); // Download to backup DownloadResult backupDownloadResult = rhDownloadProvider.DownloadToBackup(targetConfiguration, PreConfigureDownloadCallback, PostConfigureDownloadCallback, DownloadOptions.Hardware | DownloadOptions.Software); WriteDownloadResults(backupDownloadResult); ... } private static void PreConfigureDownloadCallback(DownloadConfiguration downloadConfiguration) { StopHSystem stopHSystem = downloadConfiguration as StopHSystem; if (stopHSystem != null) { stopHSystem.CurrentSelection = StopHSystemSelections.StopHSystem; } OverwriteTargetLanguages overwriteTargetLanguages = downloadConfiguration as OverwriteTargetLanguages; if (overwriteTargetLanguages != null) { overwriteTargetLanguages.Checked = true; } AlarmTextLibrariesDownload alarmTextLibraries = downloadConfiguration as AlarmTextLibrariesDownload; if (alarmTextLibraries != null) { alarmTextLibraries.CurrentSelection = AlarmTextLibrariesDownloadSelections.ConsistentDownload; return; } CheckBeforeDownload checkBeforeDownload = downloadConfiguration as CheckBeforeDownload; if (checkBeforeDownload != null) { checkBeforeDownload.Checked = true; return; } ConsistentBlocksDownload consistentBlocksDownload = downloadConfiguration as ConsistentBlocksDownload; if (consistentBlocksDownload != null) { consistentBlocksDownload.CurrentSelection = ConsistentBlocksDownloadSelections.ConsistentDownload; return; } OverwriteSystemData overwriteSystenData = downloadConfiguration as OverwriteSystemData; if (overwriteSystenData != null) { overwriteSystenData.CurrentSelection = OverwriteSystemDataSelections.Overwrite; return; } } private static void PostConfigureDownloadCallback(DownloadConfiguration downloadConfiguration) { StartModules startModules = downloadConfiguration as StartModules; if (startModules != null) { startModules.CurrentSelection = StartModulesSelections.StartModule; return; } } private static void WriteDownloadResults(DownloadResult result) { Console.WriteLine("State:" + result.State); Console.WriteLine("Warning Count:" + result.WarningCount); Console.WriteLine("Error Count:" + result.ErrorCount); RecursivelyWriteMessages(result.Messages); } private static void RecursivelyWriteMessages(DownloadResultMessageComposition messages, string indent = "") { indent += "\t"; foreach (DownloadResultMessage message in messages) { Console.WriteLine(indent + "DateTime: " + message.DateTime); Console.WriteLine(indent + "State: " + message.State); Console.WriteLine(indent + "Message: " + message.Message); RecursivelyWriteMessages(message.Messages, indent); } } |