Beispiel #1
0
        private double GetBT1FromCRL_G(Xd100e xd100eDevice)
        {
            double r = 0d;

            /*
             * foreach (IDevice device in xd100eDevice.Station.Devices)
             * {
             *  if (device is IBT1Provider)
             *  {
             *      IBT1Provider bt1Pro = device as IBT1Provider;
             *      if (bt1Pro.BT1DataDT != DateTime.MinValue)
             *      {
             *          r = bt1Pro.BT1;
             *      }
             *  }
             * }
             */
            // 1. get heat kind device collection
            // 2. get device collection with place != unknown
            // 3. if device count > 1, select first device
            // 4. get device.bt1
            DeviceCollection heatDevices = xd100eDevice.Station.Devices.GetDevices(KIND);

            RemoveUnknownPlaceDevice(heatDevices);

            bool hasData = heatDevices.HasData(HasDataOption.All);

            if (hasData)
            {
                r = Calc(heatDevices, "BT", CalcType.Avg);
            }
            return(r);
        }
Beispiel #2
0
        /// <summary>
        /// get crl-g gt1 property
        /// </summary>
        /// <param name="xd100eDevice"></param>
        /// <returns></returns>
        private double GetGT1FromCRL_G(Xd100e xd100eDevice)
        {
            double           r           = 0d;
            DeviceCollection heatDevices = xd100eDevice.Station.Devices.GetDevices(KIND);

            RemoveUnknownPlaceDevice(heatDevices);

            bool hasData = heatDevices.HasData(HasDataOption.All);

            if (hasData)
            {
                r = Calc(heatDevices, "GT", CalcType.Avg);
            }
            return(r);
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="deviceSource"></param>
        /// <returns></returns>
        public override IDevice OnCreate(IDeviceSource deviceSource)
        {
            SimpleDeviceSource s = (SimpleDeviceSource)deviceSource;
            Xd100e             d = new Xd100e();

            d.Address      = s.Address;
            d.Name         = s.DeviceName;
            d.DeviceSource = deviceSource;
            d.DeviceType   = this.Dpu.DeviceType;
            d.Dpu          = this.Dpu;
            d.Guid         = s.Guid;
            d.StationGuid  = s.StationGuid;

            return(d);
        }
Beispiel #4
0
        /// <summary>
        /// get crl-g gt1 property
        /// </summary>
        /// <param name="xd100eDevice"></param>
        /// <returns></returns>
        private double GetGT1FromCRL_G(Xd100e xd100eDevice)
        {
            double r = 0d;
            DeviceCollection heatDevices = xd100eDevice.Station.Devices.GetDevices(KIND);
            RemoveUnknownPlaceDevice(heatDevices);

            bool hasData = heatDevices.HasData(HasDataOption.All);
            if (hasData)
            {
                r = Calc(heatDevices, "GT", CalcType.Avg);
            }
            return r;
        }
Beispiel #5
0
        private double GetBT1FromCRL_G(Xd100e xd100eDevice)
        {
            double r = 0d;
            /*
            foreach (IDevice device in xd100eDevice.Station.Devices)
            {
                if (device is IBT1Provider)
                {
                    IBT1Provider bt1Pro = device as IBT1Provider;
                    if (bt1Pro.BT1DataDT != DateTime.MinValue)
                    {
                        r = bt1Pro.BT1;
                    }
                }
            }
            */
            // 1. get heat kind device collection
            // 2. get device collection with place != unknown
            // 3. if device count > 1, select first device
            // 4. get device.bt1
            DeviceCollection heatDevices = xd100eDevice.Station.Devices.GetDevices(KIND);
            RemoveUnknownPlaceDevice(heatDevices);

            bool hasData = heatDevices.HasData(HasDataOption.All);
            if (hasData)
            {
                r = Calc(heatDevices, "BT", CalcType.Avg);
            }
            return r;
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="task"></param>
        /// <param name="parseResult"></param>
        public override void OnProcess(ITask task, IParseResult pr)
        {
            if (pr.IsSuccess)
            {
                //Xd100eData data = Xd100eData.GetCachedData();

                Xd100e     xd100eDevice = (Xd100e)task.Device;
                Xd100eData data         = xd100eDevice.GetCachedData();

                Console.WriteLine("ori xd100e id: " + GuidHelper.ConvertToInt32(xd100eDevice.Guid));

                string opera = task.Opera.Name;

                if (StringHelper.Equal(opera, READ_REAL))
                {
                    for (int i = Xd100eData.BeginChannelNO; i <= Xd100eData.EndChannelNO; i++)
                    {
                        int    no          = i;
                        string channelName = GetChannelName(no);

                        float val = Convert.ToSingle(pr.Results[channelName]);
                        val /= 100f;

                        data.SetChannelDataAI(no, val);
                        data.IsSetAI = true;
                    }
                }

                else if (StringHelper.Equal(opera, READ_REAL_DI))
                {
                    //XD100EData data = xd100eDevice.XD100EData;
                    for (int i = Xd100eData.BeginChannelNO; i <= Xd100eData.EndChannelNO; i++)
                    {
                        int    no          = i;
                        string channelName = GetChannelName(no);
                        byte   value       = Convert.ToByte(pr.Results[channelName]);
                        data.SetChannelDataDI(no, value > 0);
                        data.IsSetDI = true;
                    }
                }

                //
                //
                if (data.IsComplete())
                {
                    double ir = 0d, sr = 0d;
                    //bool hasRecuritFluxDevice;
                    string recuritEx = string.Empty;

                    //bool success = GetFluxValues(xd100eDevice, FluxPlace.RecruitSide, out hasRecuritFluxDevice,
                    //    out ir, out sr, out recuritEx);

                    // get kind == fluxdevice device collection
                    //
                    DeviceCollection rDevices = xd100eDevice.Station.Devices.GetDevices(KIND_FLUX_DEVICE);
                    rDevices = Filter(rDevices, FluxPlace.RecruitSide);
                    bool hasRecuritFluxDevice = rDevices.Count > 0;
                    bool hasRecuritFluxData   = rDevices.HasData(HasDataOption.All);
                    if (hasRecuritFluxData)
                    {
                        ir        = Calc(rDevices, "InstantFlux", CalcType.Sum);
                        sr        = Calc(rDevices, "Sum", CalcType.Sum);
                        recuritEx = GetRecuritEx(rDevices);
                    }

                    // get recruite device collection
                    // get recruite data
                    //
                    // get kind == heatdevcie device collection
                    // check has data
                    // [x] get place == first ?
                    // get device gt bt

                    double if1 = 0d, sf1 = 0d, gt1 = 0d, bt1 = 0d, ih1 = 0d, sh1 = 0d;
                    //bool hasFirstFluxDevice;
                    //string firstEx;
                    //bool success2 = GetFluxValues(xd100eDevice, FluxPlace.FirstSide, out hasFirstFluxDevice,
                    //    out if1, out sf1, out firstEx);

                    DeviceCollection hs = xd100eDevice.Station.Devices.GetDevices(KIND);
                    hs = Filter(hs, FluxPlace.FirstSide);

                    bool hasFirstFluxDevice = hs.Count > 0;
                    bool hasFirstFluxData   = hs.HasData(HasDataOption.All);
                    if (hasFirstFluxData)
                    {
                        if1 = Calc(hs, "InstantFlux", CalcType.Sum);
                        sf1 = Calc(hs, "Sum", CalcType.Sum);
                        gt1 = Calc(hs, "GT", CalcType.Avg);
                        bt1 = Calc(hs, "BT", CalcType.Avg);
                        ih1 = Calc(hs, "InstantHeat", CalcType.Sum);
                        sh1 = Calc(hs, "SumHeat", CalcType.Sum);
                    }

                    bool success = true;
                    if (hasRecuritFluxDevice)
                    {
                        if (hasRecuritFluxData)
                        {
                            data.IR  = ir;
                            data.SR  = sr;
                            data.REx = recuritEx;
                        }
                        else
                        {
                            success = false;
                        }
                    }

                    //
                    //
                    if (success)
                    {
                        if (hasFirstFluxDevice)
                        {
                            if (hasFirstFluxData)
                            {
                                // xd100e ai5 == if1
                                //
                                // ai1 - gt1, ai2 - bt1
                                //
                                data.IF1 = if1;
                                data.SF1 = sf1;

                                data.AI5 = Convert.ToSingle(if1);
                                data.AI1 = Convert.ToSingle(gt1);
                                data.AI2 = Convert.ToSingle(bt1);

                                data.IH1 = ih1;
                                data.SH1 = sh1;
                            }
                            else
                            {
                                success = false;
                            }
                        }
                    }

                    if (success)
                    {
                        data.DT = DateTime.Now;
                        xd100eDevice.DeviceDataManager.Last = data;

                        int deviceID = GuidHelper.ConvertToInt32(xd100eDevice.Guid);
                        Console.WriteLine("write xd100e id: " + deviceID);
                        DBI.Instance.InsertXd100eData(deviceID, data);
                    }

                    //if (success && success2)
                    //{
                    //    data.IR = ir;
                    //    data.SR = sr;
                    //    data.REx = recuritEx;

                    //    data.IF1 = if1;
                    //    data.SF1 = sf1;

                    //    if (hasFirstFluxDevice)
                    //    {
                    //        // xd100e ai5 == if1
                    //        //
                    //        // ai1 - gt1, ai2 - bt1
                    //        //
                    //        data.AI5 = Convert.ToSingle(if1);
                    //        data.AI1 = Convert.ToSingle(GetGT1FromCRL_G(xd100eDevice));
                    //        data.AI2 = Convert.ToSingle(GetBT1FromCRL_G(xd100eDevice));
                    //    }

                    //    data.DT = DateTime.Now;
                    //    xd100eDevice.DeviceDataManager.Last = data;

                    //    int deviceID = GuidHelper.ConvertToInt32(xd100eDevice.Guid);
                    //    Console.WriteLine("write xd100e id: " + deviceID);
                    //    DBI.Instance.InsertXd100eData(deviceID, data);
                    //}
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="deviceSource"></param>
        /// <returns></returns>
        public override IDevice OnCreate(IDeviceSource deviceSource)
        {
            SimpleDeviceSource s = (SimpleDeviceSource)deviceSource;
            Xd100e d = new Xd100e();
            d.Address = s.Address;
            d.Name = s.DeviceName;
            d.DeviceSource = deviceSource;
            d.DeviceType = this.Dpu.DeviceType;
            d.Dpu = this.Dpu;
            d.Guid = s.Guid;
            d.StationGuid = s.StationGuid;

            return d;
        }