コード例 #1
0
        public void Start()
        {
            cf.ShowDialog();
            if (cf.solutionId == -2)
            {
                return;
            }
            else if (cf.solutionId != -1)
            {
                m_requestTimer          = new System.Timers.Timer(10000);
                m_requestTimer.Elapsed += (sender, e) => { SolutionRequest((ulong)cf.solutionId); };
                m_requestTimer.Start();
                waiting.WaitOne();
                return;
            }
            problemData = cf.dvrpDescription;
            //problemData = GenerateData2();

            SolveRequest();
            waiting.WaitOne();
        }
コード例 #2
0
        private void ReceiveSolutionInfo(ulong _id)
        {
            var solutionInfo = DeserializeMessage <Solutions>(Receive());

            solutions = solutionInfo.Solutions1;
            if (solutions != null && solutions[0].Type == SolutionsSolutionType.Final && solutions[0].TaskIdSpecified == false)
            {
                m_requestTimer.Stop();                                                      //zapis danych na dysku
                SolutionDescription             solutionDescription             = SerializeToClass <SolutionDescription>(solutions[0].Data);
                SolutionDescriptionToFileParser solutionDescriptionToFileParser = new SolutionDescriptionToFileParser();
                m_des = SerializeToClass <DVRPDescription>(solutionInfo.CommonData);
                Console.WriteLine("Received Problem Solution Id = {0}.", solutionInfo.Id);
                Console.WriteLine("Write name of the file for solution (MAX 15 characters)");
                string solutionFileName = Console.ReadLine();
                if (solutionFileName.Length == 0)
                {
                    solutionFileName = "Result File";
                }
                solutionFileName = solutionFileName.Substring(0, solutionFileName.Length < 15 ? solutionFileName.Length : 15);
                int[][] x = m_sol = solutionDescription.m_permutation;
                //solutionDescriptionToFileParser.WriteSolutionToFile(solutionDescription, solutionFileName + ".txt");
                solutionDescriptionToFileParser.WriteSolutionToFile(solutionDescription.m_permutation, solutionDescription.m_result, solutionFileName + ".txt");
                Console.WriteLine("Solution saved correctly in file " + solutionFileName);
                Console.WriteLine("Would you like to see the visualisation? [y/n]");
                string visualisationChoice = Console.ReadLine();
                if (visualisationChoice.Length > 0 && (visualisationChoice[0] == 'y' || visualisationChoice[0] == 'Y'))
                {
                    Thread t = new Thread(new ThreadStart(ShowVisualisation));
                    t.Start();
                }
                Console.WriteLine("Work done. Good bye!");
                Console.ReadLine();
                waiting.Release();
            }
            else
            {
                Console.WriteLine("We haven't result yet");
            }
        }