Restart-TwinCAT

SYNOPSIS

Restarts or Resets a specified TwinCAT System.

SYNTAX

NetId (Default)

Restart-TwinCAT [[-NetId] <AmsNetId[]>] [-Quiet] [-Force] [-StateOnly] [-Timeout <Int32>] [-NoReinit] [-NoWait]
 [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-Command <TwinCATRestartCommand>] [-ThrowError]
 [-WhatIf] [-Confirm] [<CommonParameters>]

Route

Restart-TwinCAT [-InputObject] <IRoute[]> [-Quiet] [-Force] [-StateOnly] [-Timeout <Int32>] [-NoReinit]
 [-NoWait] [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-Command <TwinCATRestartCommand>] [-ThrowError]
 [-WhatIf] [-Confirm] [<CommonParameters>]

AddressStr

Restart-TwinCAT [-Address] <String[]> [-Quiet] [-Force] [-StateOnly] [-Timeout <Int32>] [-NoReinit] [-NoWait]
 [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-Command <TwinCATRestartCommand>] [-ThrowError]
 [-WhatIf] [-Confirm] [<CommonParameters>]

Session

Restart-TwinCAT -Session <ISession[]> [-Quiet] [-Force] [-StateOnly] [-Timeout <Int32>] [-NoReinit] [-NoWait]
 [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-Command <TwinCATRestartCommand>] [-ThrowError]
 [-WhatIf] [-Confirm] [<CommonParameters>]

SessionId

Restart-TwinCAT -SessionId <Int32[]> [-Quiet] [-Force] [-StateOnly] [-Timeout <Int32>] [-NoReinit] [-NoWait]
 [-WaitTimeout <Int32>] [-PollingRate <Int32>] [-Command <TwinCATRestartCommand>] [-ThrowError]
 [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

This Cmdlet Restarts or Resets the specified TwinCAT System dependant of its command parameter. The TwinCAT system will end up in ADS State 'Run' or 'Config'.

EXAMPLES

Example 1

PS> Restart-TwinCAT -command Restart -force

Ok Target     NetId             Port  ErrorCode Requested Original Reached Latency (ms)
-- ------     -----             ----  --------- --------- -------- ------- ------------
X  CX_1111    192.168.0.2.1.1  10000  Succeeded Reset     Run      Run     2853

Restarts the local TwinCAT System. The 'X' in the 'Ok' Column indicates the success.

Example 2

PS> Restart-TwinCAT -command Restart -force

WARNING: 192.168.0.2.1.1:10 ERR | 18:26:28:108 |'TCOM Server' (10): Device 1 (EtherCAT) (Adapter): Failed to connect to network adapter!
WARNING: 192.168.0.2.1.1:10 WRN | 18:26:28:108 |'TCOM Server' (10): PREOP to SAFEOP of 'Device 1 (EtherCAT) (Adapter)' (0x03010011) failed - 'request is aborted' 0x9811071F
WARNING: 192.168.0.2.1.1:10000 ERR | 18:26:28:117 |'TwinCAT System' (10000): Sending ams command >> Init12\IO: Set State TComObj SAFEOP: Set Objects (4) to SAFEOP >> AdsError: 1823 (0x71f, ADS ERROR: device aborted the action) << failed!

Ok Target     NetId             Port  ErrorCode Requested Original Reached Latency (ms)
-- ------     -----             ----  --------- --------- -------- ------- ------------
   CX_1111    192.168.0.2.1.1  10000  Succeeded Reset     Config   Config  3427

Calls a Reset to the local SystemService that fails!. Error log messages will be logged out.

Example 3

PS> Restart-TwinCAT -command Restart -force | select-object -ExpandProperty LogMessages

WARNING: 192.168.0.2.1.1:10 ERR | 18:20:45:969 |'TCOM Server' (10): Device 1 (EtherCAT) (Adapter): Failed to connect to network adapter!
WARNING: 192.168.0.2.1.1:10 WRN | 18:20:45:969 |'TCOM Server' (10): PREOP to SAFEOP of 'Device 1 (EtherCAT) (Adapter)' (0x03010011) failed - 'request is aborted' 0x9811071F
WARNING: 192.168.0.2.1.1:10000 ERR | 18:20:45:979 |'TwinCAT System' (10000): Sending ams command >> Init12\IO: Set State TComObj SAFEOP: Set Objects (4) to SAFEOP >> AdsError: 1823 (0x71f, ADS ERROR: device aborted the action) << failed!

Type    TimeStamp    DeviceName     Port  Message
----    ---------    ----------     ----  -------
Message 18:20:44.874 TwinCAT System 10000 TwinCAT System Restart initiated from AmsNetId: 192.168.0.2.1.1 port 34564.
Message 18:20:44.879 TwinCAT System 10000 Saving configuration of COM server TcVnService !
Message 18:20:44.880 TwinCAT System 10000 Saving configuration of COM server TcEventLogger !
Message 18:20:44.970 TwinCAT System 10000 Shutting down COM Server TcVnService !
Message 18:20:44.971 TwinCAT System 10000 Shutting down COM Server TcEventLogger !
Message 18:20:45.745 TwinCAT System 10000 Loading configuration of COM server TcVnService !
Message 18:20:45.747 TwinCAT System 10000 Loading configuration of COM server TcEventLogger !
Message 18:20:45.748 TwinCAT System 10000 Initializing COM Server TcVnService !
Message 18:20:45.773 TwinCAT System 10000 Initializing COM Server TcEventLogger !
Message 18:20:45.783 TwinCAT System 10000 TcIoEth Server started: TcIoEth.
Message 18:20:45.791 TwinCAT System 10000 TcRtsObjects Server started: TcRtsObjects.
Message 18:20:45.798 TwinCAT System 10000 TcIoECat Server started: TcIoECat.
Message 18:20:45.805 TwinCAT System 10000 TcIo Server started: TcIo.
Message 18:20:45.814 TwinCAT System 10000 TcPlc30 Server started: TcPlc30.
Message 18:20:45.821 TwinCAT System 10000 TcRTime Server started: TcRTime.
Message 18:20:45.927 License Server 30    license validation status is Valid(3)
Error   18:20:45.969 TCOM Server    10    Device 1 (EtherCAT) (Adapter): Failed to connect to network adapter!
Warning 18:20:45.969 TCOM Server    10    PREOP to SAFEOP of 'Device 1 (EtherCAT) (Adapter)' (0x03010011) failed - 'request is aborted' 0x9811071F
Error   18:20:45.979 TwinCAT System 10000 Sending ams command >> Init12\IO: Set State TComObj SAFEOP: Set Objects (4) to SAFEOP >> AdsError: 1823 (0x71f, ADS ERROR: device aborted the action) << failed!
Message 18:20:47.879 TwinCAT System 10000 Loading configuration of COM server TcVnService
Message 18:20:47.881 TwinCAT System 10000 Loading configuration of COM server TcEventLogger
Message 18:20:47.882 TwinCAT System 10000 Initializing COM Server TcVnService
Message 18:20:47.910 TwinCAT System 10000 Initializing COM Server TcEventLogger
Message 18:20:47.922 TwinCAT System 10000 TCIO Server started: TCIO.
Message 18:20:47.931 TwinCAT System 10000 TCRTIME Server started: TCRTIME.
Message 18:20:47.939 TwinCAT System 10000 TCRTSOBJECTS Server started: TCRTSOBJECTS.
Message 18:20:47.948 TwinCAT System 10000 TCIOETH Server started: TCIOETH.
Message 18:20:47.956 TwinCAT System 10000 TCIOECAT Server started: TCIOECAT.
Message 18:20:47.963 TwinCAT System 10000 TCIODRIVERS Server started: TCIODRIVERS.
Message 18:20:48.078 TwinCAT System 10000 Starting COM Server TcVnService
Message 18:20:48.078 TwinCAT System 10000 Starting COM Server TcEventLogger

Tries to restart the local TwinCAT system and write the log messages to the output. This Command fails.

PARAMETERS

-NetId

The NetId address where to set the state (Local system by default). Multiple values are allowed. Tab completion: Completes AmsNetId values from currently reachable routes on the local TwinCAT system. The net id.

Type: AmsNetId[]
Parameter Sets: NetId
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-InputObject

Target route(s), where to set the state. Multiple values are allowed. Tab completion: Completes route names from currently reachable ADS systems on the local TwinCAT system. The input object.

Type: IRoute[]
Parameter Sets: Route
Aliases: Destination, Route

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Address

The address of the system where to set the state. This can be the RouteName, NetId, the HostName or the IPAddress. Wildcards and multiple values are permitted. Tab completion: Completes route names from currently reachable ADS systems on the local TwinCAT system. The address.

Type: String[]
Parameter Sets: AddressStr
Aliases: Name

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: True

-Session

The ADS Session to use for the Cmdlet. Multiple sessions are allowed. The address.

Type: ISession[]
Parameter Sets: Session
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-SessionId

Specifies the Session (with unique ID) to use for the Cmdlet (multiple values are allowed) Tab completion: Completes IDs of active TwinCAT sessions (created with New-TcSession). The Session ID.

Type: Int32[]
Parameter Sets: SessionId
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Quiet

Sets the Quiet mode of the command. The Cmdlet then returns a $true or $false but not the actual states of the targets. The return value will be $true if all operations succeed and it will be $false if at least one have failed. The quiet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Force

Forces the command (no confirmation, Resets the FailFastHandler) The quiet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-StateOnly

This Cmdlet return only the AdsState instead of full information. The quiet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Timeout

The communication ADS timeout in milliseconds. A value <= 0 sets the Default (5000 ms). The ADS communication timeout in milliseconds.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: -1
Accept pipeline input: False
Accept wildcard characters: False

-NoReinit

Skips the WriteControl command if the target system is already in the requested state. When set, the Cmdlet returns immediately without reinitializing an already-matching state. When set, the target state is checked first; if it already matches the requested state, no WriteControl is sent.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-NoWait

The -NoWait parameter skips the waiting for the target end state. If set, the Cmdlet returns immediatly after sending the WriteControl request, without waiting for the state change. When set, the Cmdlet does not wait for the target to reach the requested state.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-WaitTimeout

The wait timout for the state change in ms. This Cmdlet waits for the target state changes which is limited by this WaitTimeout. A value <= 0 sets the Default (45000 ms). This parameter is only used if -NoWait is not set. The wait timeout in milliseconds.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: -1
Accept pipeline input: False
Accept wildcard characters: False

-PollingRate

The Wait polling rate in Milliseconds. A value <= 0 sets the Default polling rate (200 ms for local systems, 1000ms for remote systems). This parameter is only used, if -NoWait is not set. The Polling rate in millisenconds.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: -1
Accept pipeline input: False
Accept wildcard characters: False

-Command

The timeout to wait for restart. A value of 0 disables the timeout. A value <= 0 sets the Default (5000 ms). The ADS communication timeout in milliseconds.

Possible values: Restart, Reset, Reconfig, Config

Type: TwinCATRestartCommand
Parameter Sets: (All)
Aliases:
Accepted values: Restart, Reset, Reconfig, Config

Required: False
Position: Named
Default value: Restart
Accept pipeline input: False
Accept wildcard characters: False

-ThrowError

Throws an error, if the target system(s) not reaching the expected state. True activates the Error generation.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

TwinCAT.IRoute[]

TwinCAT.ISession[]

OUTPUTS

NOTES