コード例 #1
0
        /*copy from http://openavrusb.com/index.php/hid-device-class
         * only use it to fetch all tinyfan devices
         * failed when use it to send HID report(fallback to hidtool.dll)
         */
        public USBInterface.HIDInterface.interfaceDetails[] getDevicesDetails()
        {
            List <USBInterface.HIDInterface.interfaceDetails> result = new List <USBInterface.HIDInterface.interfaceDetails>();

            USBInterface.HIDInterface.interfaceDetails[] devices = USBInterface.HIDInterface.getConnectedDevices();
            for (int i = 0; i < devices.Length; i++)
            {
                USBInterface.HIDInterface.interfaceDetails device = devices[i];
                //report.AppendLine("USB device " + device.manufacturer + ", it's sn is:" + device.serialNumber);
                if (device.VID == 5824 && device.PID == 1503)
                {
                    result.Add(device);
                }
            }
            return(result.ToArray());
        }
コード例 #2
0
 public TinyFanGroup(ISettings settings)
 {
     // TODO: Complete member initialization
     this.settings = settings;
     USBInterface.HIDInterface.interfaceDetails[] allDevices = this.getDevicesDetails();
     if (allDevices.Length == 0)
     {
         report.Append("Didn't find TinyFan USB device.");
         return;
     }
     for (int i = 0; i < allDevices.Length; i++)
     {
         USBInterface.HIDInterface.interfaceDetails deviceInfos = allDevices[i];
         report.AppendLine("Find one device. It's path is:" + deviceInfos.devicePath);
         TinyFan tinyFan = new TinyFan("tinyfan", settings, deviceInfos);
         this.hardware.Add(tinyFan);
     }
 }
コード例 #3
0
ファイル: TinyFan.cs プロジェクト: zhoushanbao1994/tinyFan
        public TinyFan(string name, ISettings settings, USBInterface.HIDInterface.interfaceDetails deviceInfo)
            : base("TinyFan", new Identifier("TinyFan", deviceInfo.serialNumber), settings)
        {
            this.deviceInfo = deviceInfo;
            int fanCount = 4;

            fans     = new Sensor[fanCount];
            controls = new Sensor[fanCount];
            byte[] tach = this.getTach();
            for (int i = 0; i < fanCount; i++)
            {
                int    device = 33 + i;
                string n      = "Fan" + (i + 1);
                fans[i] = new Sensor(n, device, SensorType.Fan, this, settings);
                //fans[i].Value = tach[i] * 60 / 2;
                ActivateSensor(fans[i]);
                controls[i] = new Sensor(n, device, SensorType.TinyFanControl, this, settings);
                Control c = new Control(controls[i], settings, 0, 100);
                c.ControlModeChanged += (cc) => //copy from SuperIOHardware.cs
                {
                    Console.WriteLine("fan mode changed.");
                };
                c.SoftwareControlValueChanged += (cc) =>
                {
                    this.setTach();
                };
                c.FanModeChanged += (cc) =>
                {
                    this.setFanPinMode();
                };
                c.FanFollowChanged += (cc) =>
                {
                    this.setTach(); //when close "fan follow", I have to invoke this since Update() will not invoke setTach at this case.
                };
                controls[i].Control = c;
                ActivateSensor(controls[i]);
                controls[i].Value = controls[i].Control.SoftwareValue;
            }
            //init device, since now device is passive and didn't save setting itself
            this.setFanPinMode();
            this.setTach();
        }
コード例 #4
0
ファイル: TinyFan.cs プロジェクト: fkpwolf/tinyFan
 public TinyFan(string name, ISettings settings, USBInterface.HIDInterface.interfaceDetails deviceInfo)
     : base("TinyFan", new Identifier("TinyFan", deviceInfo.serialNumber), settings)
 {
     this.deviceInfo = deviceInfo;
     int fanCount = 4;
     fans = new Sensor[fanCount];
     controls = new Sensor[fanCount];
     byte[] tach = this.getTach();
     for (int i = 0; i < fanCount; i++)
     {
         int device = 33 + i;
         string n = "Fan" + (i + 1);
         fans[i] = new Sensor(n, device, SensorType.Fan, this, settings);
         //fans[i].Value = tach[i] * 60 / 2;
         ActivateSensor(fans[i]);
         controls[i] = new Sensor(n, device, SensorType.TinyFanControl, this, settings);
         Control c = new Control(controls[i], settings, 0, 100);
         c.ControlModeChanged += (cc) => //copy from SuperIOHardware.cs
         {
             Console.WriteLine("fan mode changed.");
         };
         c.SoftwareControlValueChanged += (cc) =>
         {
             this.setTach();
         };
         c.FanModeChanged += (cc) =>
         {
             this.setFanPinMode();
         };
         c.FanFollowChanged += (cc) =>
         {
             this.setTach(); //when close "fan follow", I have to invoke this since Update() will not invoke setTach at this case.
         };
         controls[i].Control = c;
         ActivateSensor(controls[i]);
         controls[i].Value = controls[i].Control.SoftwareValue;
     }
     //init device, since now device is passive and didn't save setting itself
     this.setFanPinMode();
     this.setTach();
 }