Пример #1
0
        public void OracleTest()
        {
            BaseKeyPair kp            = BaseKeyPair.Generate();
            Account     oracleAccount = fluentClient.ConstructAccount(kp);
            Account     account       = fluentClient.ConstructAccount(baseKeyPair);
            ulong       money         = (ulong)1m.ToAettos(Unit.AE);
            bool        result        = account.SendAmount(oracleAccount.KeyPair.PublicKey, money).WaitForFinish(TimeSpan.FromSeconds(30));

            Assert.IsTrue(result);
            oracleAccount.Refresh();
            Assert.AreEqual(oracleAccount.Balance, money);

            OracleServer <CityQuery, TemperatureResponse> query = oracleAccount.RegisterOracle <CityQuery, TemperatureResponse>().WaitForFinish(TimeSpan.FromSeconds(30));
            CityTemperatureService svc = new CityTemperatureService();

            svc.Server = query;
            Task.Factory.StartNew(svc.Start);
            OracleClient <CityQuery, TemperatureResponse> reg = account.GetOracle <CityQuery, TemperatureResponse>(query.OracleId);
            TemperatureResponse resp = reg.Ask(new CityQuery {
                City = "montevideo"
            }).WaitForFinish(TimeSpan.FromSeconds(300));

            Assert.AreEqual(resp.TemperatureCelsius, 24);
            resp = reg.Ask(new CityQuery {
                City = "sofia"
            }).WaitForFinish(TimeSpan.FromSeconds(30));
            Assert.AreEqual(resp.TemperatureCelsius, 25);
            resp = reg.Ask(new CityQuery {
                City = "hell"
            }).WaitForFinish(TimeSpan.FromSeconds(30));
            Assert.AreEqual(resp.TemperatureCelsius, 2000);
            svc.Stop();
        }
        private BillCheque OnBillChequePrintingCallback(Guid orderId)
        {
            BillCheque billCheque = new BillCheque();

            try
            {
                IPrinterRef receiptChequePrinter = PluginContext.Operations.TryGetReceiptChequePrinter(false);
                if (receiptChequePrinter == null)
                {
                    PluginContext.Operations.AddErrorMessage("Cannot print temperature info: printer is missing", nameof(TemperaturePlugin));
                    return(billCheque);
                }
                IEnumerable <TemperatureResponse> temperature = this._apiClient.GetTemperature();
                if (temperature == null)
                {
                    PluginContext.Operations.AddErrorMessage("Cannot print temperature info: could not get temperature info", nameof(TemperaturePlugin));
                    return(billCheque);
                }
                TemperatureResponse temperatureResponse = temperature.FirstOrDefault(i => Guid.Parse(i.StoreExternalId) == _storeExternalId);
                if (temperatureResponse == null)
                {
                    PluginContext.Operations.AddErrorMessage("Cannot print temperature info: could not find current store id", nameof(TemperaturePlugin));
                    return(billCheque);
                }

                XElement xelement1 = new XElement("doc");

                var checkDate = temperatureResponse.CheckDate;

                var day = checkDate.Day;
                checkDate = temperatureResponse.CheckDate;
                var month = checkDate.Month;
                checkDate = temperatureResponse.CheckDate;
                var    year    = checkDate.Year;
                string dateStr = string.Format("{0}.{1}.{2}  ", day, month, year);
                checkDate = temperatureResponse.CheckDate;
                var hour = checkDate.Hour;
                checkDate = temperatureResponse.CheckDate;
                var minute = checkDate.Minute;
                checkDate = temperatureResponse.CheckDate;
                var second = checkDate.Second;

                string timeStr     = string.Format("{0}:{1}:{2}", hour, minute, second);
                string dateTimeStr = $"<b>Temperature information on {dateStr} {timeStr}</b>";
                var    xelement2   = new XElement("fill", dateTimeStr);
                var    xelement3   = new XElement("fill", string.Format("Avarage temperature: {0}", temperatureResponse.TemperatureInfo.AverageTemp));
                xelement1.Add(xelement2);
                xelement1.Add(xelement3);

                PluginContext.Operations.Print(receiptChequePrinter, xelement1);
            }
            catch (Exception ex)
            {
                PluginContext.Log.Error("Cannot print temperature: " + ex.Message);
                PluginContext.Operations.AddErrorMessage("Cannot print temperature info: could not get temperature info", nameof(TemperaturePlugin));
            }
            return(billCheque);
        }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="canopy"></param>
 /// <param name="pathway"></param>
 /// <param name="water"></param>
 /// <param name="leaf"></param>
 public Transpiration(
     ICanopyParameters canopy,
     IPathwayParameters pathway,
     IWaterInteraction water,
     TemperatureResponse leaf
     )
 {
     Canopy  = canopy;
     Pathway = pathway;
     Water   = water;
     Leaf    = leaf;
 }
Пример #4
0
        public TemperatureResponse Map(Temperature entity)
        {
            var result = new TemperatureResponse()
            {
                Id             = entity.Id,
                Note           = entity.Note,
                ValueInCelsius = entity.ValueInCelsius,
                When           = entity.When
            };

            return(result);
        }
        public override Task <TemperatureResponse> RequestTemperature(TemperatureRequest request,
                                                                      ServerCallContext context)
        {
            var ret = new TemperatureResponse();

            try
            {
                ret.Temperature = _cameraInstance.Features["DeviceTemperature"].FloatValue;
            }
            catch (Exception e)
            {
                ret.Error = ServiceHelper.BuildError(e, Error.Types.Level.Error);
            }

            return(Task.FromResult(ret));
        }
Пример #6
0
        public static DCAPSTModel SetUpModel(
            ICanopyParameters CP,
            IPathwayParameters PP,
            int DOY,
            double latitude,
            double maxT,
            double minT,
            double radn)
        {
            // Model the solar geometry
            var SG = new SolarGeometry
            {
                Latitude  = latitude.ToRadians(),
                DayOfYear = DOY
            };

            // Model the solar radiation
            var SR = new SolarRadiation(SG)
            {
                Daily = radn,
                RPAR  = 0.5
            };

            // Model the environmental temperature
            var TM = new Temperature(SG)
            {
                MaxTemperature      = maxT,
                MinTemperature      = minT,
                AtmosphericPressure = 1.01325
            };

            // Model the pathways
            var SunlitAc1 = new AssimilationPathway(CP, PP);
            var SunlitAc2 = new AssimilationPathway(CP, PP);
            var SunlitAj  = new AssimilationPathway(CP, PP);

            var ShadedAc1 = new AssimilationPathway(CP, PP);
            var ShadedAc2 = new AssimilationPathway(CP, PP);
            var ShadedAj  = new AssimilationPathway(CP, PP);

            // Model the canopy
            IAssimilation A;

            if (CP.Type == CanopyType.C3)
            {
                A = new AssimilationC3(CP, PP);
            }
            else if (CP.Type == CanopyType.C4)
            {
                A = new AssimilationC4(CP, PP);
            }
            else
            {
                A = new AssimilationCCM(CP, PP);
            }

            var sunlit = new AssimilationArea(SunlitAc1, SunlitAc2, SunlitAj, A);
            var shaded = new AssimilationArea(ShadedAc1, ShadedAc2, ShadedAj, A);
            var CA     = new CanopyAttributes(CP, PP, sunlit, shaded);

            // Model the transpiration
            var WI = new WaterInteraction(TM);
            var TR = new TemperatureResponse(CP, PP);
            var TS = new Transpiration(CP, PP, WI, TR);

            // Model the photosynthesis
            var DM = new DCAPSTModel(SG, SR, TM, PP, CA, TS)
            {
                B = 0.409
            };

            return(DM);
        }