Exemplo n.º 1
0
        private void MenuItem_GrainbrainBrewingMonitor(object sender, RoutedEventArgs e)
        {
            IPAddress ipAddr;

            if (GrainbrainNetDiscovery.GetGrainBrainAddress(out ipAddr))
            {
                var bm = new BrewingMonitor(ipAddr);
                bm.ShowDialog();
            }
        }
Exemplo n.º 2
0
        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            bool grainBrainConnected = false;

            if (GrainbrainNetDiscovery.ScanGrainBrains())
            {
                grainBrainConnected = true;
            }

            handleGrainBrainStatus(grainBrainConnected);
        }
Exemplo n.º 3
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());
        }
Exemplo n.º 4
0
        private void handleGrainBrainStatus(bool isConnectToGrainBrain)
        {
            GrainBrainMenuItem.IsEnabled = isConnectToGrainBrain;

            if (!isConnectToGrainBrain)
            {
                lblGrainBrainState.Text = "State - Not connected";
                lblRemainingTime.Text   = "-";
                return;
            }

            var s = GrainbrainNetDiscovery.GetGrainBrainStatus();

            if (s.State == BrewStep.Idle)
            {
                lblGrainBrainState.Text = String.Format("State - {0}", s.State);
                lblRemainingTime.Text   = "-";
                return;
            }

            lblGrainBrainState.Text = String.Format("State - {0}", s.State);


            string time;

            if (s.RemainingMashStepList.Count() != 0)
            {
                var ms = s.RemainingMashStepList.First();
                time = String.Format("{0} minutes left at {1}", ms.StepTime, ms.Temperature);
            }
            else
            {
                time = String.Format("{0} minutes of boiling left", s.RemainingBoilTime);
            }
            lblRemainingTime.Text = time;

            this.progressBar.Value = s.Progress;

            handleBrewProcess(s);
        }
Exemplo n.º 5
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();
            }
        }
Exemplo n.º 6
0
        private void handleBrewProcess(GrainBrainStatus status)
        {
            if (status.State == BrewStep.StrikeWaterTempReached)
            {
                //dispatcherTimer.Tick -= brewProcessTimer_Tick;
                dispatcherTimer.IsEnabled = false;

                var swrw = new StrikeWaterReachedWindow();
                swrw.ShowDialog();

                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);

                GrainsAddedNotify req  = new GrainsAddedNotify();
                Empty             resp = cl.GrainsAdded(req);
                ch.ShutdownAsync().Wait();

                //dispatcherTimer.Tick += brewProcessTimer_Tick;
                dispatcherTimer.IsEnabled = true;
            }

            if (status.State == BrewStep.MashDoneStartSparge)
            {
                dispatcherTimer.IsEnabled = false;

                var sdw = new SpargeDoneWindow();
                sdw.ShowDialog();

                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);

                SpargeDoneNotify req  = new SpargeDoneNotify();
                Empty            resp = cl.SpargeDone(req);
                ch.ShutdownAsync().Wait();

                dispatcherTimer.IsEnabled = true;
            }

            if (status.State == BrewStep.BoilDone)
            {
                dispatcherTimer.IsEnabled = false;

                var wcsw = new WortChillerSanitizedWindow();
                wcsw.ShowDialog();

                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);

                WortChillerSanitizedDoneNotify req = new WortChillerSanitizedDoneNotify();
                Empty resp = cl.WortChillerSanitizedDone(req);
                ch.ShutdownAsync().Wait();

                dispatcherTimer.IsEnabled = true;
            }
        }