using System; using System.Collections.Generic; using System.Text; namespace csRepeat { public abstract class DPDevice { public enum InterfaceTypes { ethernet, rs232, usb } //public InterfaceTypes InterfaceType { get; set; } private InterfaceTypes _InterfaceType; public InterfaceTypes InterfaceType { get { return _InterfaceType; } set { _InterfaceType = value; } } //public DeviceTypes DeviceType { get; set; } private DeviceTypes _DeviceType; public DeviceTypes DeviceType { get { return _DeviceType; } set { _DeviceType = value; } } public Version FirmwareVersion; public Version FpgaVersion; //public string SerialNumber { get; set; } private string _SerialNumber; public string SerialNumber { get { return _SerialNumber; } set { _SerialNumber = value; } } public DPDevice(InterfaceTypes interfaceType, DeviceTypes deviceType, Version firmwareVersion, Version fpgaVersion, string serialNumber) { this.InterfaceType = interfaceType; this.DeviceType = deviceType; this.FirmwareVersion = firmwareVersion; this.FpgaVersion = fpgaVersion; this.SerialNumber = serialNumber; // default to Normal state FpgaState = FpgaStates.Normal; // see if we saw an encryption failure if (fpgaVersion.Equals(FpgaEncryptionFailureVersion)) { FpgaState = FpgaStates.EncryptionFailure; } } /// /// Possible fpga states /// public enum FpgaStates { /// /// Normal fpga state /// Normal, /// /// Fpga reports an encryption failure /// EncryptionFailure, /// /// Fpga image is unprogrammed /// Unprogrammed } /// /// 14.14 is fpga encryption failure /// public static readonly Version FpgaEncryptionFailureVersion = new Version(14, 14); /// /// Fpga states, defaults to 'Normal' /// private FpgaStates _FpgaState; public FpgaStates FpgaState { get { return _FpgaState; } internal set { _FpgaState = value; } } public delegate void UploadProgressUpdateDelegate(long currentByteOffset, long totalBytes); public delegate bool HasFirmwareLoadBeenCancelledDelegate(); public HasFirmwareLoadBeenCancelledDelegate HasFirmwareLoadBeenCancelled; public static List PerformDeviceDetection() { List devices = new List(); List fw6UsbDevices = FW6.DPDeviceUsb.DetectDevices(); List fw6SerialDevices = FW6.DPDeviceSerialFW6.DetectDevices(); List fw6EthernetDevices = FW6.DPDeviceEthernet.DetectDevices(); if (fw6EthernetDevices != null) { foreach (DPDevice a in fw6EthernetDevices) { devices.Add(a); } } if (fw6SerialDevices != null) { foreach (DPDevice a in fw6SerialDevices) { devices.Add(a); } } if (fw6UsbDevices != null) { foreach (DPDevice a in fw6UsbDevices) { devices.Add(a); } } return devices; } public override string ToString() { return String.Format("Amptek {0} - S/N {1} - uC Ver {2} FPGA Ver {3} - {4}", DeviceType, SerialNumber, DisplayVersion.VersionString(this, FirmwareVersion, false), DisplayVersion.VersionString(this, FpgaVersion, true), InterfaceType); } } }