Setting/Resetting Virtual Signals
This example provides information on setting and resetting digital Virtual Signals and how to set the value of an analog Virtual Signal.
Use this procedure to set and reset Virtual Signals:
Create a digital signal.
Set the signal to 1.
Reset the signal to 0.
Create an analog signal.
Set the signal to 156.
Solution
Create a digital signal.
// Create a digital signal. station.IOSignals.Add(new IOSignal("MySignal", IOSignalType.DigitalInput));
Set the signal to 1.
// Set the signal to 1. station.IOSignals["MySignal"].Value = 1;
Reset the signal to 0.
// Reset the signal to 0. station.IOSignals["MySignal"].Value = 0;
Create an analog signal.
// Create an analog signal. station.IOSignals.Add(new IOSignal("AnalogSignal", IOSignalType.AnalogInput));
Set the signal to 156.
// Set the signal to 156. // NOTE: You need to use two decimals, since it only accept a double as a value. station.IOSignals["AnalogSignal"].Value = (double)156;
Example
This example provides information on setting and resetting digital Virtual Signals.
private static void VirtualSignals()
{
Project.UndoContext.BeginUndoStep("VirtualSignals");
try
{
Station station = Project.ActiveProject as Station;
// Create a digital signal.
station.IOSignals.Add(new IOSignal("MySignal", IOSignalType.DigitalInput));
// Set the signal to 1.
station.IOSignals["MySignal"].Value = 1;
// Reset the signal to 0.
station.IOSignals["MySignal"].Value = 0;
// Create an analog signal.
station.IOSignals.Add(new IOSignal("AnalogSignal", IOSignalType.AnalogInput));
// Set the signal to 156.
// NOTE: You need to use two decimals, since it only accept a double as a value.
station.IOSignals["AnalogSignal"].Value = (double)156;
}
catch
{
Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
throw;
}
finally
{
Project.UndoContext.EndUndoStep();
}
}
Required Namespaces
ABB.
ABB.