コード例 #1
0
        public MetricAnalogOutput(NidaqSingleton.Device device, NidaqSingleton.Channel channel, Graph g)
            : base("AO " + channel.Path, g, UniquenessBy(channel))
        {
            _portIn = new NodeSystemLib2.FormatData1D.InputPortData1D(this, "In");
            Channel = channel;
            Device  = device;

            Session = NidaqSingleton.Instance.AddToSession(this);
        }
コード例 #2
0
        public MetricDigitalInput(NidaqSingleton.Device device, NidaqSingleton.Channel channel, Graph g)
            : base("DI " + channel.Path, g, UniquenessBy(channel))
        {
            _portOut = new NodeSystemLib2.FormatData1D.OutputPortData1D(this, "Out");
            Channel  = channel;
            Device   = device;

            lineNum = int.Parse(Channel.Path.Split('/').Last().Last().ToString());

            // only add to session after the initialization is done
            Session = NidaqSingleton.Instance.AddToSession(this);

            _portOut.Samplerate = Session.GetTask <NidaqSessionDigitalIn>(Device).ClockRate;
        }
コード例 #3
0
        public SettingsDigitalOut(NidaqSingleton.Device dev, string clockPath, int bufferLength, int prebufferLength)
        {
            InitializeComponent();
            numericUpDownBufferLength.Value    = bufferLength;
            numericUpDownPreBufferLength.Value = prebufferLength;
            comboBoxClockSource.Text           = clockPath;

            var terms  = new StringBuilder(10000);
            var result = NidaQmxHelper.DAQmxGetDevTerminals(dev.Name, terms, terms.Capacity - 1);

            if (result >= 0)
            {
                comboBoxClockSource.Items.AddRange(terms.ToString().Split(','));
            }
        }
コード例 #4
0
        public SettingsDigitalIn(NidaqSingleton.Device dev, NidaqSessionDigitalIn.ClockSource clockSrc, string clockPath, int clockRate)
        {
            InitializeComponent();
            comboBoxClock.DataSource   = Enum.GetValues(typeof(NidaqSessionDigitalIn.ClockSource));
            comboBoxClock.SelectedItem = clockSrc;
            comboBoxClockSource.Text   = clockPath;
            textBoxClockRate.Text      = clockRate.ToString();

            var terms  = new StringBuilder(10000);
            var result = NidaQmxHelper.DAQmxGetDevTerminals(dev.Name, terms, terms.Capacity - 1);

            if (result >= 0)
            {
                comboBoxClockSource.Items.AddRange(terms.ToString().Split(','));
            }
        }
コード例 #5
0
        public MetricAnalogInput(NidaqSingleton.Device device, NidaqSingleton.Channel channel, Graph g)
            : base("AI " + channel.Path, g, UniquenessBy(channel))
        {
            _portOut = new NodeSystemLib2.FormatData1D.OutputPortData1D(this, "Out");
            Channel  = channel;
            Device   = device;

            // only add to session after the initialization is done
            Session = NidaqSingleton.Instance.AddToSession(this);

            _attrVMax        = new AttributeValueDouble(this, "Vmax");
            _attrVMin        = new AttributeValueDouble(this, "Vmin");
            _attrTerminalCfg = new AttributeValueEnum <NidaQmxHelper.TerminalCfg>(this, "TerminalConfig");

            _attrVMax.SetRuntimeReadonly();
            _attrVMin.SetRuntimeReadonly();
            _attrTerminalCfg.SetRuntimeReadonly();
        }
コード例 #6
0
ファイル: NidaqSession.cs プロジェクト: muba24/flumin-master
        public void AnalogWrite(NidaqSingleton.Device dev, int channelNumber, double[] data, int offset, int samples)
        {
            var task = GetTask <NidaqSessionAnalogOut>(dev);

            if (task == null)
            {
                System.Diagnostics.Debug.WriteLine("Nidaq: Can't query task from session. Result null");
                SessionGraph.AsyncEmergencyStop(null);
                return;
            }

            try {
                int written = task.Write(channelNumber, data, offset, samples);
                if (written != samples)
                {
                    System.Diagnostics.Debug.WriteLine("Didn't write " + (samples - written));
                }
            } catch (NationalInstruments.DAQmx.DaqException e) {
                System.Diagnostics.Debug.WriteLine("Nidaq: Error while writing: " + e.Message);
                SessionGraph.AsyncEmergencyStop(null);
            }
        }
コード例 #7
0
 public NidaqSessionAnalogIn(NidaqSingleton.Device dev, NidaqSession parent)
 {
     Parent = parent;
     Device = dev;
 }
コード例 #8
0
 public NidaqSessionDigitalIn(NidaqSingleton.Device device, NidaqSession parent)
 {
     Parent = parent;
     Device = device;
 }
コード例 #9
0
 public NidaqSessionDigitalOut(NidaqSingleton.Device dev, NidaqSession parent)
 {
     Parent = parent;
     Device = dev;
 }
コード例 #10
0
 public MetricDigitalInput(NidaqSingleton.Device device, NidaqSingleton.Channel channel, Graph g, XmlNode node) : this(device, channel, g)
 {
 }
コード例 #11
0
 public MetricAnalogInput(NidaqSingleton.Device device, NidaqSingleton.Channel channel, Graph g, XmlNode node) : this(device, channel, g)
 {
     _attrVMax.Deserialize(node.Attributes.GetNamedItem(_attrVMax.Name)?.Value ?? "10");
     _attrVMin.Deserialize(node.Attributes.GetNamedItem(_attrVMin.Name)?.Value ?? "-10");
     _attrTerminalCfg.Deserialize(node.Attributes.GetNamedItem(_attrTerminalCfg.Name)?.Value ?? NidaQmxHelper.TerminalCfg.RSE.ToString());
 }
コード例 #12
0
ファイル: NidaqSession.cs プロジェクト: muba24/flumin-master
 public T GetTask <T>(NidaqSingleton.Device dev) where T : INidaqSessionTask
 {
     return((T)_tasks.FirstOrDefault(task => task is T && task.Device == dev));
 }
コード例 #13
0
 public MetricAnalogOutput(NidaqSingleton.Device device, NidaqSingleton.Channel channel, Graph g, XmlNode node) : this(device, channel, g)
 {
     VMax = double.Parse(node.Attributes.GetNamedItem("vmax")?.Value ?? "10", System.Globalization.CultureInfo.InvariantCulture);
     VMin = double.Parse(node.Attributes.GetNamedItem("vmin")?.Value ?? "-10", System.Globalization.CultureInfo.InvariantCulture);
 }