TIA Safety Administration

Export the Safety Administration settings of fail-safe PLCs to YAML.

plccheck tia export safety writes the settings of the Safety Administration editor to <out>/<PLC>/safety-administration.yml, one file per fail-safe PLC. TIA keeps these settings in the Safety Administration editor and in generated blocks such as FOB_RTG1, which have no source to export, so this file is the version of them you can commit and diff.

plccheck tia export safety "My project" --out exported
plccheck tia export safety Demo.ap21 --out exported --plc CCS

The export needs TIA Portal with STEP 7 Safety and always reads through TIA Openness. It only reads the project. A PLC without a fail-safe program gets no file, and an old file for it is removed. --delete-stale on a software export leaves the file alone.

Format

# AUTO-GENERATED by plccheck from TIA Portal.
# Do not edit this file; it will be overwritten by the next export.
schema_version: 1
plc: "CCS"
offline_program_password_set: false
offline_serial_number: "S C-S1A11DGK2024"
settings:
  safety_system_version: "V2.8"
  safety_mode_can_be_disabled: false
  f_change_history: false
  f_io_dbs_without_prefix: false
  consistent_upload_from_f_cpu: false
  f_communication_id_tag: false
  block_numbers:
    management_mode: "FSystemManaged"
    db_from: 30000
    db_to: 59999
    fb_from: 32767
    fb_to: 65535
    fc_from: 32767
    fc_to: 65535
runtime_groups:
  - name: "F-runtime group 1"
    f_ob: "FOB_RTG1"
    f_ob_event_class: "Cyclic interrupt"
    f_ob_number: 123
    f_ob_cycle_time: 100000
    f_ob_phase_shift: 0
    f_ob_priority: 12
    main_safety_block: "Main_Safety_RTG1"
    main_safety_instance_db: "Main_Safety_RTG1_DB"
    warn_cycle_time: 110000
    maximum_cycle_time: 120000
    info_db: "RTG1SysInfo"
    pre_processing: "pre_safety"
    post_processing: null
signatures:
  - type: "CollectiveOfflineSignature"
    value: 222638020
unavailable: []
unmapped: []

Runtime groups are sorted by name and signatures by type. There is no timestamp, so two exports of an unchanged project are identical. The signatures change when the safety program is compiled. After a change to the safety settings TIA V21 returns 0 for the collective and software signature until the next compile.

Values are written the way Openness returns them. Times are plain numbers and signatures are decimal. An unset block reference such as post_processing is null.

Where the values come from

Each key is one attribute of the public Siemens.Engineering.Safety API. SafetyAdministration is a service of the CPU device item.

Key Openness object Attribute
offline_program_password_set SafetyAdministration IsSafetyOfflineProgramPasswordSet
offline_serial_number SafetyAdministration OfflineSerialNumber
settings.safety_system_version SafetyAdministration.Settings SafetySystemVersion
settings.safety_mode_can_be_disabled SafetyAdministration.Settings SafetyModeCanBeDisabled
settings.f_change_history SafetyAdministration.Settings ActivationOfFChangeHistory
settings.f_io_dbs_without_prefix SafetyAdministration.Settings CreateDriverInstanceDataBlocksWithoutPrefix
settings.consistent_upload_from_f_cpu SafetyAdministration.Settings EnableConsistentUploadFromFCpu
settings.f_communication_id_tag SafetyAdministration.Settings EnableFCommunicationIdTag
settings.block_numbers.management_mode Settings.AssignmentOfBlockNumbers ManagementMode
settings.block_numbers.db_from, db_to Settings.AssignmentOfBlockNumbers FromDB, ToDB
settings.block_numbers.fb_from, fb_to Settings.AssignmentOfBlockNumbers FromFB, ToFB
settings.block_numbers.fc_from, fc_to Settings.AssignmentOfBlockNumbers FromFC, ToFC
runtime_groups[].name SafetyAdministration.RuntimeGroups[] Name
runtime_groups[].f_ob SafetyAdministration.RuntimeGroups[] FOBName
runtime_groups[].f_ob_event_class SafetyAdministration.RuntimeGroups[] FOBEventClass
runtime_groups[].f_ob_number SafetyAdministration.RuntimeGroups[] FOBNumber
runtime_groups[].f_ob_cycle_time SafetyAdministration.RuntimeGroups[] FOBCycleTime
runtime_groups[].f_ob_phase_shift SafetyAdministration.RuntimeGroups[] FOBPhaseShift
runtime_groups[].f_ob_priority SafetyAdministration.RuntimeGroups[] FOBPriority
runtime_groups[].main_safety_block SafetyAdministration.RuntimeGroups[] MainSafetyBlockName
runtime_groups[].main_safety_instance_db SafetyAdministration.RuntimeGroups[] MainSafetyBlockIDbName
runtime_groups[].warn_cycle_time SafetyAdministration.RuntimeGroups[] WarnCycleTime
runtime_groups[].maximum_cycle_time SafetyAdministration.RuntimeGroups[] MaximumCycleTime
runtime_groups[].info_db SafetyAdministration.RuntimeGroups[] InfoDbName
runtime_groups[].pre_processing SafetyAdministration.RuntimeGroups[] PreProcessingName
runtime_groups[].post_processing SafetyAdministration.RuntimeGroups[] PostProcessingName
signatures[].type, value SafetyAdministration.ProgramSignatures.Signatures[] Type, Value

Runtime groups in plccheck compile

The F-OB of a runtime group is generated by TIA and has no source, so nothing in the exported sources calls the main safety block. compile, run and test read runtime_groups from this file in the PLC root and call, for each group, the preprocessing FC, the main safety block with its instance DB and the postprocessing FC. A block that is named here but missing from the sources fails the build.

Each group runs once per scan, before the entry OB. The F-OB's own cycle time, phase shift and priority are not modelled, and neither are the cycle time monitoring, the runtime group information DB, F-I/O passivation or the F-signatures. Without this file the build warns that the PLC has F-blocks and no runtime group.

Attributes that differ between versions

The export asks each object for its attribute list instead of assuming one. A key from the table that this TIA version does not have, or that fails to read, is left out and listed under unavailable with the Openness object, attribute and reason. An attribute TIA reports that has no key yet is listed under unmapped with its value, so nothing is dropped silently.

If the settings of one PLC cannot be read at all, the other PLCs are still written and the command exits with code 1. Without STEP 7 Safety the command also exits with code 1 and leaves existing files unchanged.

What is not exported

  • Passwords. Openness can only set, check and revoke the safety program password, and the export never reads one. offline_program_password_set only says whether a password exists.
  • The safety settings of TIA Portal itself (Siemens.Engineering.Safety.GlobalSettings on TiaPortal, for example the user name for the F-change history). They belong to the installation, not the project.
  • Whether a global F-I/O status block is generated. Openness only has a method that creates the block, no attribute to read.

A direct .zap21/.ap21 reader for this file does not exist yet, so TIA Portal is required.