Table of Contents

Class CylinderModule

Namespace
Loehnert.Lisrt.IO
Assembly
Loehnert.Lisrt.IO.dll

Represents a (pneumatic) cylinder.

public class CylinderModule : InitializableCompositeModule, ICompositeModule, ILisrtModule, IInitializable, INotifyPropertyChangedEx, INotifyPropertyChanged, IHasDeviceLabel, IHasServiceView
Inheritance
PropertyChangedBase
CylinderModule
Implements
INotifyPropertyChangedEx
Inherited Members
PropertyChangedBase.Refresh()
PropertyChangedBase.IsNotifying
PropertyChangedBase.PropertyChanged

Examples

This example shows how to lock the movements of a cylinder:

_cylinder1 = new CylinderModule(
    "Cylinder1",
    _cylinder1GoToBasePosition,    // Digital output for valve
    _cylinder1GoToWorkPosition,    // Digital output for valve
    _cylinder1IsInBasePosition,    // Digital input for limit switch
    _cylinder1IsInWorkPosition);   // Digital input for limit switch
_cylinder2 = new CylinderModule(
    "Cylinder2",
    _cylinder2GoToBasePosition,    // Digital output for valve
    _cylinder2GoToWorkPosition,    // Digital output for valve
    _cylinder2IsInBasePosition,    // Digital input for limit switch
    _cylinder2IsInWorkPosition);   // Digital input for limit switch

// Configure locking for got to base position
_cylinder2.CanGoToBasePositionCriteria = (_) =>
{
    if (_cylinder1.IsInBasePosition)
    {
        return (false, "Cylinder 1 must be in base position");
    }
    else
    {
        return (true, string.Empty);
    }
};

Remarks

You can use this class for cylinders with monostable or bistable valves. Using the limit switches is optional. If no limit switches are defined, the timeouts (GoToBasePositionTimeoutInMilliseconds or GoToWorkPositionTimeoutInMilliseconds are used.

Constructors

CylinderModule(string, IDigitalOutput, IDigitalOutput, IDigitalInput, IDigitalInput, IDigitalInput)

Initializes a new instance of the CylinderModule class.

public CylinderModule(string name, IDigitalOutput gotoBasePosition, IDigitalOutput gotoWorkPosition, IDigitalInput isInBasePosition, IDigitalInput isInWorkPosition, IDigitalInput airIsEnabled = null)

Parameters

name string

Name of the module.

gotoBasePosition IDigitalOutput

Output for that enables base position.

gotoWorkPosition IDigitalOutput

Output for that enables work position.

isInBasePosition IDigitalInput

Optional input (limit switch) that indicates whether cylinder is in base position. This input must implement the INotifyPropertyChanged interface.

isInWorkPosition IDigitalInput

Optional input (limit switch) that indicates whether cylinder is in work position. This input must implement the INotifyPropertyChanged interface.

airIsEnabled IDigitalInput

Optional input that indicates whether air is enabled. This input must implement the INotifyPropertyChanged interface.

Remarks

If you have a mono stable vale, use only gotoBasePosition or gotoWorkPosition. Using the limit switches (isInBasePosition or isInWorkPosition) is optional.

When the airIsEnabled input is switched off, the valves are switched off. After the air is switched on, the valves of the current position are switched on again.

Exceptions

ArgumentNullException

Thrown when gotoBasePosition and gotoWorkPosition is null.

ArgumentException

Thrown isInBasePosition is not null and does not implement INotifyPropertyChanged
-or- isInWorkPosition is not null and does not implement INotifyPropertyChanged
-or- airIsEnabled is not null and does not implement INotifyPropertyChanged.

Properties

CanGoToBasePosition

Gets a value indicating whether the cylinder can go to base position.

public bool CanGoToBasePosition { get; }

Property Value

bool

Is always true if CanGoToBasePositionCriteria is null. Is false if the air is disabled.

CanGoToBasePositionCriteria

Gets or sets a function that indicates whether the cylinder can be moved to base position.

public virtual Func<CylinderModule, (bool CanGoToBasePosition, string Reason)> CanGoToBasePositionCriteria { get; set; }

Property Value

Func<CylinderModule, (bool CanGoToBasePosition, string Reason)>

The function returns a value which indicates whether the cylinder can moved to base position and a description of the reason why it can't be moved.

CanGoToWorkPosition

Gets a value indicating whether the cylinder can go to work position.

public bool CanGoToWorkPosition { get; }

Property Value

bool

Is always true if CanGoToWorkPositionCriteria is null. Is false if the air is disabled.

CanGoToWorkPositionCriteria

Gets or sets a function that indicates whether the cylinder can be moved to work position.

public virtual Func<CylinderModule, (bool CanGoToWorkPosition, string Reason)> CanGoToWorkPositionCriteria { get; set; }

Property Value

Func<CylinderModule, (bool CanGoToBasePosition, string Reason)>

The function returns a value which indicates whether the cylinder can moved to work position and a description of the reason why it can't be moved.

DeviceLabel

Gets or sets the device label.

[Configuration("")]
public string DeviceLabel { get; set; }

Property Value

string

GoToBasePositionTimeoutInMilliseconds

Gets or sets the timeout in milliseconds for moving to base position.

[Configuration(5000, Unit = "ms", Description = "Timeout for going to base position.")]
public int GoToBasePositionTimeoutInMilliseconds { get; set; }

Property Value

int

The default value is 5000ms.

GoToWorkPositionTimeoutInMilliseconds

Gets or sets the timeout in milliseconds for moving to work position.

[Configuration(5000, Unit = "ms", Description = "Timeout for going to work position.")]
public int GoToWorkPositionTimeoutInMilliseconds { get; set; }

Property Value

int

The default value is 5000ms.

Icon

Gets the icon.

public override Uri Icon { get; }

Property Value

Uri

InstanceID

Gets or sets the instance ID.

public int InstanceID { get; set; }

Property Value

int

IsInBasePosition

Gets a value indicating whether the cylinder is in base position.

public virtual bool IsInBasePosition { get; }

Property Value

bool

IsInWorkPosition

Gets a value indicating whether the cylinder is in work position.

public virtual bool IsInWorkPosition { get; }

Property Value

bool

Methods

CreateServiceViewModel(CylinderModule)

Creates the service view model.

protected virtual IDocument CreateServiceViewModel(CylinderModule cylinder)

Parameters

cylinder CylinderModule

Cylinder for the view model.

Returns

IDocument

A new service view model.

GoToBasePosition()

Moves the cylinder to base position.

public virtual void GoToBasePosition()

Exceptions

InvalidOperationException

Thrown when the air is disabled
-or- the cylinder cannot move to base position, because of the CanGoToBasePositionCriteria.

NotInitializedException

Thrown when the cylinder is not initialized.

TimeoutException

Thrown when the cylinder does not reach the position in the expected time (see GoToBasePositionTimeoutInMilliseconds.

GoToWorkPosition()

Moves the cylinder to work position.

public virtual void GoToWorkPosition()

Exceptions

InvalidOperationException

Thrown when the air is disabled
-or- the cylinder cannot move to work position, because of the CanGoToWorkPositionCriteria.

NotInitializedException

Thrown when the cylinder is not initialized.

TimeoutException

Thrown when the cylinder does not reach the position in the expected time (see GoToWorkPositionTimeoutInMilliseconds.

Initialize()

Initializes the module.

public override void Initialize()

Remarks

The valves of the current position are switched on.

ShowServiceView()

Shows the service window.

public virtual void ShowServiceView()