private static StatusThreadsThread StatusThreadsThreadFromNodeWorker(NodeWorker worker) { StatusThreadsThread thread = new StatusThreadsThread(); thread.State = worker.StateString; if (worker.State == true) { if (thread.HowLong > 0) { thread.HowLong = worker.HowLong; thread.HowLongSpecified = true; } else thread.HowLongSpecified = false; thread.TaskIdSpecified = true; thread.TaskId = worker.TaskId; thread.ProblemInstanceId = worker.ProblemInstanceId; thread.ProblemInstanceIdSpecified = true; thread.ProblemType = worker.ProblemType; } else { thread.TaskIdSpecified = false; thread.HowLongSpecified = false; thread.ProblemInstanceIdSpecified = false; } return thread; }
protected override string ReceivedSolvePartialProblems(SolvePartialProblems solvePartialProblems) { ///// Hey here is the problem to solve! (undivided, everything is in CommonData) string problem = Utilities.Base64Decode(solvePartialProblems.CommonData); globalProblem = problem; //solvePartialProblems.Id; NodeWorker worker = new NodeWorker(solvePartialProblems.Id); worker.problemObject = ProblemLoader.loadnewExampleString(globalProblem); Workers.Add(worker); double sol = worker.calculateAlgorithm(); Solutions solutions = new Solutions(); solutions.Id = solvePartialProblems.Id; solutions.CommonData = Utilities.Base64Encode(sol.ToString()); Console.WriteLine("How Long = " + this.Workers.First().HowLong); CMSocket.Instance.SendMessage(this.Port, this.IP, solutions.SerializeToXML(), this); return null; }