本文整理汇总了C#中Controller.AddDevice方法的典型用法代码示例。如果您正苦于以下问题:C# Controller.AddDevice方法的具体用法?C# Controller.AddDevice怎么用?C# Controller.AddDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller.AddDevice方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExternalDeviceBase
protected ExternalDeviceBase(string name, string manufacturer, Controller c)
{
this.Name = name;
this.Manufacturer = manufacturer;
this.Streams = new Dictionary<string, IDAQStream>();
Configuration = new Dictionary<string, object>();
if (c != null)
{
Controller = c;
Controller.AddDevice(this);
}
}
示例2: PreventsDuplicateExternalDeviceNames
public void PreventsDuplicateExternalDeviceNames()
{
Controller c = new Controller();
const string UNUSED_NAME = "UNUSED";
var dev1 = new UnitConvertingExternalDevice(UNUSED_NAME, UNUSED_DEVICE_MANUFACTURER, UNUSED_BACKGROUND);
var dev2 = new UnitConvertingExternalDevice(UNUSED_NAME, UNUSED_DEVICE_MANUFACTURER, UNUSED_BACKGROUND);
c.AddDevice(dev1).AddDevice(dev2);
}
示例3: CreatePipeline
public void CreatePipeline()
{
// Based on the "Minimal Rig.pdf" in the docs folder
Converters.Clear();
// We need an IClock
IClock clock = new FakeClock();
// We need a controller ...
Controller con = new Controller();
Converters.Register("units", "units",
// just an identity conversion for now, to pass Validate()
(IMeasurement m) => m);
Converters.Register("V", "units",
// just an identity conversion for now, to pass Validate()
(IMeasurement m) => m);
con.Clock = clock;
// Three ExternalDevices
CoalescingDevice amp = new CoalescingDevice("Amp", UNUSED_DEVICE_MANUFACTURER, con, UNUSED_BACKGROUND)
{
MeasurementConversionTarget = "units"
};
var LED = new UnitConvertingExternalDevice("LED", UNUSED_DEVICE_MANUFACTURER, UNUSED_BACKGROUND)
{
MeasurementConversionTarget = "units"
};
var temp = new UnitConvertingExternalDevice("Temp", UNUSED_DEVICE_MANUFACTURER, UNUSED_BACKGROUND)
{
MeasurementConversionTarget = "units"
};
amp.Clock = clock;
LED.Clock = clock;
temp.Clock = clock;
con.AddDevice(LED).AddDevice(temp);
// There should be no difference whether we use the
// ExternalDevice constructor to wire up the Controller
// to the ExternalDevice, or the explicit Add() call
Assert.IsNotNull(amp.Controller);
Assert.IsNotNull(LED.Controller);
Assert.IsNotNull(temp.Controller);
Assert.IsTrue(amp.Controller == con);
Assert.IsTrue(LED.Controller == con);
Assert.IsTrue(temp.Controller == con);
// Five DAQStreams
DAQInputStream in0 = new DAQInputStream("In-0"); in0.Clock = clock;
DAQInputStream in1 = new DAQInputStream("In-1"); in1.Clock = clock;
DAQInputStream in2 = new DAQInputStream("In-2"); in2.Clock = clock;
DAQOutputStream out0 = new DAQOutputStream("Out-0"); out0.Clock = clock;
DAQOutputStream out1 = new DAQOutputStream("Out-1"); out1.Clock = clock;
in0.MeasurementConversionTarget = "units";
in1.MeasurementConversionTarget = "units";
in2.MeasurementConversionTarget = "units";
out0.MeasurementConversionTarget = "units";
out1.MeasurementConversionTarget = "units";
//amp.Coalesce = CoalescingDevice.OneItemCoalesce;
amp.Configuration["CoalesceProc"] = "Symphony.Core.CoalescingDevice.OneItemCoalesce";
LED.BindStream(out0);
amp.BindStream(out1).BindStream(in0).BindStream(in1);
amp.Connect(in0, in1);
temp.BindStream(in2);
Assert.IsTrue(LED.Streams.Count == 1);
Assert.IsTrue(amp.Streams.Count == 3);
Assert.IsTrue(temp.Streams.Count == 1);
Assert.IsTrue(in0.Devices.Contains(amp));
Assert.IsTrue(in1.Devices.Contains(amp));
Assert.IsTrue(in2.Devices.Contains(temp));
Assert.IsTrue(out0.Device == LED);
Assert.IsTrue(out1.Device == amp);
// One DAQController
IDAQController dc =
new SimpleDAQController(new IDAQStream[] { in0, in1, in2, out0, out1 });
con.DAQController = dc;
// DAQController-to-streams
Assert.IsTrue(dc.InputStreams.Contains(in0));
Assert.IsTrue(dc.InputStreams.Contains(in1));
Assert.IsTrue(dc.InputStreams.Contains(in2));
Assert.IsTrue(dc.OutputStreams.Contains(out0));
Assert.IsTrue(dc.OutputStreams.Contains(out0));
// Validate and report the validation results
Maybe<string> conVal = con.Validate();
Assert.IsTrue(conVal, conVal.Item2);
Assert.IsTrue(amp.Coalesce == CoalescingDevice.OneItemCoalesce);
}
示例4: GetDeivceReturnsDevice
public void GetDeivceReturnsDevice()
{
Controller c = new Controller();
const string DEVICE_NAME = "DEVICE";
var dev1 = new UnitConvertingExternalDevice(DEVICE_NAME, UNUSED_DEVICE_MANUFACTURER, UNUSED_BACKGROUND);
c.AddDevice(dev1);
Assert.AreEqual(dev1, c.GetDevice(DEVICE_NAME));
}