예제 #1
0
 public QueryInfo(
     Emera3Driver driver,
     SynchRequestDataDrv requestData,
     SynchParamsDataDrv requestParam,
     Emera3SharedSetting ss,
     Emera3ContentSetting cs,
     DriverSetting driverSetting)
 {
     RequestData   = requestData;
     RequestParam  = requestParam;
     this.driver   = driver;
     Request       = new Emera3Request(driver, driverSetting, driver.ReadTimeOutRequestMSec());
     DriverSetting = driverSetting;
     DataBus       = driver.Channel;
     Ss            = ss;
     Cs            = cs;
     NextPoint     = new AccountNextPoint(
         TimeZoneMap.Local,
         timeOffset: TimeOffset.Level_1,
         useMin3: false,
         useMin30: ss.Enbl30min,
         useDay1: true,
         useMonth1: true,
         useYear1: false,
         archSync: ss.Arch.ToSch());
     ElectroChannel = driver.ElectroChannel.ByBrowseName <ElectroChannel>(ElectroChannels.BN.ElectroChannel);
 }
예제 #2
0
        public override SynchResponse ReadIm(SynchRequestDataDrv request, ReadImParamsDataDrv param)
        {
            var           ss         = request.GetSharedSetting <Emera3SharedSetting>(() => new Emera3SharedSetting());
            var           cs         = request.GetContentSetting <Emera3ContentSetting>(() => new Emera3ContentSetting());
            var           drvSetting = request.GetDriverSetting(() => new DriverSetting());
            Emera3Request emera      = new Emera3Request(this, drvSetting, ReadTimeOutRequestMSec());
            ImNextPoint   nextPoint  = new ImNextPoint(TimeZoneMap.Local, 0, imNextItem: new ImNextItem("im", ss.Im.ToSch()));

            using (var session = new PhysicalSessionIm <Emera3SynchState, ImNextPoint>(this, request, nextPoint))
            {
                session.Open();
                if (!session.LaunchPoint(nextPoint.GetItem("im")))
                {
                    return(session);
                }
                if (session.BeginOperation())
                {
                    InstantaneousValues iv;
                    OperationResult     resData = OperationResult.Good;
                    if (DataBusSetting.StubData)
                    {
                        iv = new InstantaneousValues(true);
                    }
                    else
                    {
                        double koef;
                        resData = emera.TryReadKoef(this.Channel, cs.Address, cs.Psw, out koef, out bool isHalfHour);
                        if (resData.IsGood)
                        {
                            resData = emera.TryReadInstantaneousValues(this.Channel, cs.Address, cs.Psw, out iv);
                            if (resData.IsGood)
                            {
                                iv.Calc(koef);
                                ElectroChannel electroChannel = this.ElectroChannel.ByIndex <ElectroChannel>(0);
                                iv.WriteTags(this.Storage, electroChannel, resData.Quality, DateTimeUtc.Now);
                            }
                        }
                    }
                    session.EndOperation(resData);
                    Log.Trace.Write(1, (l) => l.Info(SR.READ_IM, resData.ToString()));
                }
                return(session);
            }
        }
예제 #3
0
        public override TestResult Test(TestRequestDataDrv request)
        {
            TestResult result = new TestResult();

            var           drvSetting = request.GetDriverSetting(() => new DriverSetting());
            var           cs         = request.GetContentSetting <Emera3ContentSetting>(() => new Emera3ContentSetting());
            Emera3Request emera      = new Emera3Request(this, drvSetting, ReadTimeOutRequestMSec());

            //var sr = new Def.ShortRequest(cs.Address);

            if ((request.TestLevel == TestLevel.Ping) || (request.TestLevel == TestLevel.Search))
            {
                DateTimeUtc dateTimeUtc;
                int         timeTwoSidePathMsec;
                if (!DataBusSetting.StubData)
                {
                    var readRes = emera.TryReadDateTime(this.Channel, cs.Address, cs.Psw, TimeZoneMap.Local, out dateTimeUtc, out timeTwoSidePathMsec);
                    if (!readRes.IsGood)
                    {
                        result.Add(new TestDriverError(false, "Error Connect. {0}", readRes.ErrorMsg));
                    }
                }
            }
            else if (request.TestLevel == TestLevel.Full)
            {
                DateTimeUtc dateTimeUtcPrb = DateTimeUtc.MinValue;
                int         timeTwoSidePathMsec;
                if (!OneTest(SR.Test_DT, request, result, () =>
                {
                    var res = emera.TryReadDateTime(this.Channel, cs.Address, cs.Psw, TimeZoneMap.Local, out dateTimeUtcPrb, out timeTwoSidePathMsec);
                    return(new MsgTest(res, res.IsGood ? dateTimeUtcPrb.ToLocal().ToString() : string.Empty));
                }))
                {
                    return(result);
                }
                TimeSpan diffTime = DateTimeUtc.Now - dateTimeUtcPrb;

                string sn = string.Empty;
                if (!OneTest(SR.Test_SN, request, result, () =>
                {
                    var res = emera.TryReadSerialNumber(this.Channel, cs.Address, cs.Psw, out sn);
                    return(new MsgTest(res, res.IsGood ? sn : string.Empty));
                }))
                {
                    return(result);
                }

                string deviceConfiguration = string.Empty;
                if (!OneTest(SR.Test_SV, request, result, () =>
                {
                    var res = emera.TryReadDeviceConfiguration(this.Channel, cs.Address, cs.Psw, out deviceConfiguration, true);
                    return(new MsgTest(res, res.IsGood ? deviceConfiguration.ToString() : string.Empty));
                }))
                {
                    return(result);
                }

                /*if (!OneTest(SR.Test_Error_Req, request, result, () =>
                 * {
                 * Energy eRead;
                 * var res = emera.TryReadSlicesEnergy(this.Channel, DeviceCompOn.Default, SlicesQuery.GetEmulError(sr.Address), TypeInfo.Imp, out eRead);
                 * return new MsgTest(res, res.IsGood ? "" : "Ok");
                 * }, true)) return result;*/

                result.Message = String.Format("Сер.Номер: {0}, Временной разрыв: {1} sec, Конфигурация: {2}", sn, (int)diffTime.TotalSeconds, deviceConfiguration);
            }
            return(result);
        }