示例#1
0
        private void MenuItem_GrainbrainStart(object sender, RoutedEventArgs e)
        {
            var sgw = new StartGrainbrainWindow();

            sgw.ShowDialog();

            LoadBrewProfileRequest req = new LoadBrewProfileRequest();

            req.BoilTime = BoilTime;

            foreach (Domain.MashProfileStep ms in  MashProfileList)
            {
                req.MashProfileSteps.Add(new Grpcproto.MashProfileStep {
                    Temperature = (int)(Math.Round(ms.Temperature)), StepTime = ms.StepTime, HeatOverTime = ms.HeatOverTime
                });
                log.Info(String.Format("Mash time {0} at {1} C", ms.StepTime, ms.Temperature));
            }

            foreach (HopAddition bh in BoilHops)
            {
                if (bh.Stage == HopAdditionStage.Boil)
                {
                    req.HopAdditionStep.Add(new HopAdditionStep {
                        Time = bh.Duration, Name = bh.Hop.Name
                    });
                    log.Info(String.Format("{0} at {1} min", bh.Hop.Name, bh.Duration));
                }
            }

            req.GrainbillWeight = GrainBillSize;
            req.MashWaterVolume = Volumes.FinalBatchVolume;
            IPAddress ipAddr;

            GrainbrainNetDiscovery.GetGrainBrainAddress(out ipAddr);
            string  addr    = String.Format("{0}:50051", ipAddr);
            Channel channel = new Channel(addr, ChannelCredentials.Insecure);

            McServer.McServerClient client = new McServer.McServerClient(channel);
            SuccessReply            reply  = client.LoadBrewProfile(req);

            StartStopRequest startReq = new StartStopRequest();

            startReq.StartStop = StartStopRequest.Types.StartStop.Start;
            SuccessReply relpy2 = client.StartStopAbort(startReq);

            log.Info("Started - Response: " + reply.Success.ToString());
        }
示例#2
0
        private void MenuItem_GrainbrainStop(object sender, RoutedEventArgs e)
        {
            var sbpw = new StopBrewingProcessWindow();

            sbpw.ShowDialog();
            if (sbpw.Abort)
            {
                IPAddress ipAddr;
                if (!GrainbrainNetDiscovery.GetGrainBrainAddress(out ipAddr))
                {
                    return;
                }
                string addr = String.Format("{0}:50051", ipAddr);

                Channel ch = new Channel(addr, ChannelCredentials.Insecure);

                McServer.McServerClient cl = new McServer.McServerClient(ch);

                StartStopRequest req = new StartStopRequest();
                req.StartStop = StartStopRequest.Types.StartStop.Stop;
                SuccessReply resp = cl.StartStopAbort(req);
                ch.ShutdownAsync().Wait();
            }
        }