public void TestSetFiltered()
 {
     using (AnalogTrigger at = new AnalogTrigger(2))
     {
         at.Filtered = true;
         Assert.AreEqual("filtered", GetData(at.Index)["trig_type"]);
     }
 }
 public void TestAnalogTriggerInitFree([Range(0, 7)]int pin)
 {
     int index = 0;
     using (AnalogTrigger trigger = new AnalogTrigger(pin))
     {
         index = trigger.Index;
         Assert.IsTrue(GetData(index)["initialized"]);
         Assert.AreEqual(pin, GetData(index)["pin"]);
     }
     Assert.IsFalse(GetData(index)["initialized"]);
 }
Exemplo n.º 3
0
        private static dynamic getTriggerValue(AnalogTrigger trigger)
        {
            var ain = halData["analog_in"][GetAnalogPort(trigger.analogPortPointer).port.pin];
            var atr = halData["analog_trigger"][trigger.index];
            var trigType = atr["trig_type"];
            if (trigType == null)
            {
                return ain["voltage"];
            }
            if (trigType == "averaged")
            {
                return ain["voltage"];
            }
            if (trigType == "filtered")
            {
                return ain["voltage"];
            }
            throw new ArgumentOutOfRangeException(nameof(trigger), "Analog Trigger must be either filtered, averaged or null.");

        }
Exemplo n.º 4
0
        public static IntPtr initializeAnalogTrigger(IntPtr port_pointer, ref uint index, ref int status)
        {
            status = 0;

            for (int i = 0; i < halData["analog_trigger"].Count; i++)
            {
                var cnt = halData["analog_trigger"][i];
                if (cnt["initialized"] == false)
                {
                	IntPtr aPt = initializeAnalogInputPort(port_pointer, ref status);
                    cnt["initialized"] = true;
					cnt["pin"] = GetHalPort(port_pointer).pin;
                    AnalogTrigger trig = new AnalogTrigger()
                    {
                        analogPortPointer = aPt,
                        index = i,
                    };
                    IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(trig));
                    Marshal.StructureToPtr(trig, ptr, true);
                    cnt["pointer"] = ptr.ToInt64();
                    return ptr;
                }
            }
            status = NO_AVAILABLE_RESOURCES;
            return IntPtr.Zero;
        }