Пример #1
0
        public WMR100Station(Cumulus cumulus) : base(cumulus)
        {
            cumulus.Manufacturer = cumulus.OREGONUSB;
            devicelist           = DeviceList.Local;
            station = devicelist.GetHidDeviceOrNull(Vendorid, Productid);

            if (station != null)
            {
                cumulus.LogMessage(DateTime.Now.ToLongTimeString() + " WMR100 station found");

                if (station.TryOpen(out stream))
                {
                    cumulus.LogMessage(DateTime.Now.ToLongTimeString() + " Stream opened");
                }

                PacketBuffer = new byte[PacketBufferBound];

                WMR200ExtraTempValues = new double[11];
                WMR200ExtraHumValues  = new double[11];
                WMR200ChannelPresent  = new bool[11];
                WMR200ExtraDPValues   = new double[11];
            }
            else
            {
                cumulus.LogMessage(DateTime.Now.ToLongTimeString() + " WMR100 station not found!");
                Console.WriteLine("WMR100 station not found!");
            }
        }
Пример #2
0
        public HidDevice ConnectDevice(int vendorId, int productId)
        {
            DeviceList devices   = DeviceList.Local;
            HidDevice  hidDevice = devices.GetHidDeviceOrNull(vendorID: vendorId, productID: productId);

            if (hidDevice == null)
            {
                throw new Exception("Device " + vendorId + ":" + productId + " not found");
            }
            return(hidDevice);
        }
Пример #3
0
        public HidDevice connectDevice(int vendorId, int productId)
        {
            DeviceList devices = DeviceList.Local;

            devices.Changed += (sender, e) => Console.WriteLine(value: "Device list changed.");

            HidDevice hidDevice = devices.GetHidDeviceOrNull(vendorID: vendorId, productID: productId);

            if (hidDevice == null)
            {
                throw new Exception(message: "Device not found");
            }
            Console.WriteLine(vendorId + ":" + productId + " connected");
            return(hidDevice);
        }
Пример #4
0
        internal FOStation(Cumulus cumulus) : base(cumulus)
        {
            cumulus.Manufacturer = cumulus.EW;
            var data = new byte[32];

            tmrDataRead = new Timer();

            calculaterainrate = true;

            hasSolar = cumulus.StationType == StationTypes.FineOffsetSolar;

            if (hasSolar)
            {
                FOentrysize       = 0x14;
                FOMaxAddr         = 0xFFEC;
                maxHistoryEntries = 3264;
            }
            else
            {
                FOentrysize       = 0x10;
                FOMaxAddr         = 0xFFF0;
                maxHistoryEntries = 4080;
            }

            devicelist = DeviceList.Local;

            int VID = (cumulus.VendorID < 0 ? defaultVID : cumulus.VendorID);
            int PID = (cumulus.ProductID < 0 ? defaultPID : cumulus.ProductID);

            cumulus.LogMessage("Looking for Fine Offset station, VendorID=0x" + VID.ToString("X4") + " ProductID=0x" + PID.ToString("X4"));
            Console.WriteLine("Looking for Fine Offset station, VendorID=0x" + VID.ToString("X4") + " ProductID=0x" + PID.ToString("X4"));

            hidDevice = devicelist.GetHidDeviceOrNull(vendorID: VID, productID: PID);

            if (hidDevice != null)
            {
                cumulus.LogMessage("Fine Offset station found");
                Console.WriteLine("Fine Offset station found");

                if (hidDevice.TryOpen(out stream))
                {
                    cumulus.LogMessage("Stream opened");
                    Console.WriteLine("Connected to station");
                    // Get the block of data containing the abs and rel pressures
                    cumulus.LogMessage("Reading pressure offset");
                    ReadAddress(0x20, data);
                    double relpressure = ((data[1] * 256) + data[0]) / 10.0f;
                    double abspressure = ((data[3] * 256) + data[2]) / 10.0f;
                    pressureOffset = relpressure - abspressure;
                    cumulus.LogMessage("Rel pressure = " + relpressure);
                    cumulus.LogMessage("Abs pressure = " + abspressure);
                    cumulus.LogMessage("Offset       = " + pressureOffset);

                    // Read the data from the logger
                    startReadingHistoryData();
                }
                else
                {
                    cumulus.LogMessage("Stream open failed");
                    Console.WriteLine("Unable to connect to station");
                }
            }
            else
            {
                cumulus.LogMessage("Fine Offset station not found");
                Console.WriteLine("Fine Offset station not found");
            }
        }