1 /* 2 * libiio - Library for interfacing industrial I/O (IIO) devices 3 * 4 * Copyright (C) 2015 Analog Devices, Inc. 5 * Author: Paul Cercueil <paul.cercueil@analog.com> 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * */ 18 19 using System; 20 using System.Collections.Generic; 21 using System.Linq; 22 using System.Runtime.InteropServices; 23 using System.Text; 24 using System.Threading.Tasks; 25 26 namespace iio 27 { 28 /// <summary><see cref="iio.Trigger"/> class: 29 /// Contains the representation of an IIO device that can act as a trigger.</summary> 30 public class Trigger : Device 31 { Trigger(Context ctx, IntPtr ptr)32 internal Trigger(Context ctx, IntPtr ptr) : base(ctx, ptr) { } 33 34 /// <summary>Configure a new frequency for this trigger.</summary> 35 /// <exception cref="System.Exception">The new frequency could not be set.</exception> set_rate(ulong rate)36 public void set_rate(ulong rate) 37 { 38 foreach (Attr each in attrs) 39 if (each.name.Equals("frequency")) 40 { 41 each.write((long) rate); 42 return; 43 } 44 throw new Exception("Trigger has no frequency?"); 45 } 46 47 /// <summary>Get the currently configured frequency of this trigger.</summary> 48 /// <exception cref="System.Exception">The configured frequency could not be obtained.</exception> get_rate()49 public ulong get_rate() 50 { 51 foreach (Attr each in attrs) 52 if (each.name.Equals("frequency")) 53 return (ulong) each.read_long(); 54 throw new Exception("Trigger has no frequency?"); 55 } 56 set_trigger(Trigger trig)57 public new void set_trigger(Trigger trig) 58 { 59 throw new InvalidComObjectException("Device is already a trigger"); 60 } 61 get_trigger()62 public new Trigger get_trigger() 63 { 64 throw new InvalidComObjectException("Device is already a trigger"); 65 } 66 } 67 } 68