예제 #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
        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;
 }
 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
 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);
 }