Beispiel #1
0
        private void ButtonSendSolveRequest_Click(object sender, RoutedEventArgs e)
        {
            var message = this.computationalClient.SendSolveRequest(this.solveRequestMessage);

            this.potwierdzenie.Text += "\nReceived form CC" + message;

            var serializer = new ComputationSerializer <SolveRequestResponseMessage>();
            SolveRequestResponseMessage srrm = serializer.Deserialize(message);

            this.problemId           = srrm.Id;
            this.potwierdzenie.Text += "\n\nAssigned problem ID = " + this.problemId;
        }
Beispiel #2
0
        private void ThreadBackgroundWork()
        {
            SolutionRequestMessage srm = new SolutionRequestMessage()
            {
                Id = this.problemId
            };

            SolutionsMessage sm      = null;
            String           message = String.Empty;
            double           len     = 0;
            string           ttt;

            while (sm == null)
            {
                //this.potwierdzenie.Text += "\n\nAsking for Final solution... ";
                string str = "\nAsking for Final solution... ";
                this.potwierdzenie.Dispatcher.Invoke(new UpdateTextCallback(this.UpdateText), new object[] { str });
                message = this.computationalClient.SendSolutionRequest(srm);
                if (message != String.Empty)
                {
                    switch (bn.GetMessageName(message))
                    {
                    case "Solutions":
                        var serializer = new ComputationSerializer <SolutionsMessage>();
                        sm = serializer.Deserialize(message);
                        foreach (var solution in sm.Solutions)
                        {
                            if (solution.Type == SolutionType.Final)
                            {
                                //str = "\n\nFinal solution: " + System.Text.Encoding.UTF8.GetString(solution.Data);
                                //len = DynamicVehicleRoutingProblem.DVRPPartialSolution.Parse2FinalSolLenght(System.Text.Encoding.UTF8.GetString(solution.Data));

                                DVRP.Solutions.FinalSolution finalSolution
                                    = (DVRP.Solutions.Solution.ToSolution(solution.Data)).ToFinalSolution();

                                ttt = finalSolution.ToString();

                                this.potwierdzenie.Dispatcher.Invoke(new UpdateTextCallback(this.UpdateText), new object[] { "\n\n Path lenght: " + ttt });
                                this.potwierdzenie.Dispatcher.Invoke(new UpdateTextCallback(this.UpdateText), new object[] { "\n SOLVED!!! \n SOLVED!!!" });
                                break;
                            }
                        }

                        sm = null;
                        break;

                    case "Other...?":
                        break;

                    default:
                        break;
                    }
                    if (len != 0)
                    {
                        break;
                    }
                }
                else
                {
                    //str = "\n\n Message empty";
                    //this.potwierdzenie.Dispatcher.Invoke(new UpdateTextCallback(this.UpdateText), new object[] { str });
                }
                str = " Computing...";
                this.potwierdzenie.Dispatcher.Invoke(new UpdateTextCallback(this.UpdateText), new object[] { str });
                Thread.Sleep(10000);
            }
        }