public static void SubmitSol(SharedSerialization.Solution solution) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) SubmitSol..."); lock (lock_submit) { var ep = GetCurrentEpoch(); switch (ep) { case Episode.mf: if (hasMfJob() && solution.job.origin == Episode.user) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) SubmitSol going out bc origin==user"); return; } break; case Episode.gf: if (hasGfJob() && solution.job.origin == Episode.mf) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) SubmitSol going out bc origin==mf"); return; } break; case Episode.user: if (hasUserJob() && solution.job.origin == Episode.gf) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) SubmitSol going out bc origin==gf"); return; } break; } if (solution.job.origin == ep) { switch (ep) { case Episode.user: if (curr_m?.IsConnected == true) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) Submitting solution Connection id {curr_m.id} SOL: job id {solution.job.ToString()} origine {solution.job.origin.ToString()}. "); curr_m.SendSolution(solution); totalsolutionCounter++; userSolutions++; } break; case Episode.mf: if (curr_mf?.IsConnected == true) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) Submitting solution Connection id {curr_mf.id} SOL: job id {solution.job.ToString()} origine {solution.job.origin.ToString()}. "); curr_mf.SendSolution(solution); totalsolmfcnt++; } break; case Episode.gf: if (curr_gf?.IsConnected == true) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) Submitting solution Connection id {curr_gf.id} SOL: job id {solution.job.ToString()} origine {solution.job.origin.ToString()}. "); curr_gf.SendSolution(solution); totalsolgfcnt++; } break; } } else { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) Cant be here. (origin != ep)"); } solutionCounter++; } }
public static void SubmitSol(SharedSerialization.Solution solution) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) SubmitSol..."); lock (lock_submit) { var ep = GetCurrentEpoch(); switch (ep) { case Episode.mf: if (hasMfJob() && solution.job.origin == Episode.user) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) SubmitSol going out bc origin==user"); return; } break; case Episode.gf: if (hasGfJob() && solution.job.origin == Episode.mf) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) SubmitSol going out bc origin==mf"); return; } break; case Episode.user: if (hasUserJob() && solution.job.origin == Episode.gf) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) SubmitSol going out bc origin==gf"); return; } break; } if (solution.job.origin == ep) { switch (ep) { case Episode.user: if (curr_m?.IsConnected == true) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) Submitting solution Connection id {curr_m.id} SOL: job id {solution.job.jobID} origine {solution.job.origin.ToString()}. "); curr_m.SendSolution(solution); totalsolutionCounter++; } break; case Episode.mf: if (curr_mf?.IsConnected == true) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) Submitting solution Connection id {curr_mf.id} SOL: job id {solution.job.jobID} origine {solution.job.origin.ToString()}. "); curr_mf.SendSolution(solution); totalsolmfcnt++; } break; case Episode.gf: if (curr_gf?.IsConnected == true) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) Submitting solution Connection id {curr_gf.id} SOL: job id {solution.job.jobID} origine {solution.job.origin.ToString()}. "); curr_gf.SendSolution(solution); totalsolgfcnt++; } break; } } else { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) Cant be here. (origin != ep)"); } solutions++; solutionCounter++; if (solutionCounter == solverswitch - prepConn) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) SWITCHER: start connecting mf gf"); //start connecting mf gf if (!isMfConnecting) { stopConnecting = false; isMfConnecting = true; Task.Run(() => ConnectMf()); } if (!IsGfConnecting) { stopConnecting = false; IsGfConnecting = true; Task.Run(() => ConnectGf()); } } else if (solutionCounter == solverswitch) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) solutionCounter == solverswitch"); if (curr_mf?.IsConnected == true) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) SWITCHER: pushing MF job to workers"); curr_mf.PushJobToWorkers(); } } else if (solutionCounter == solverswitch + 10) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) solutionCounter == solverswitch + 10"); if (curr_gf?.IsConnected == true) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) SWITCHER: pushing GF job to workers"); curr_gf.PushJobToWorkers(); } } else if (solutionCounter == solverswitch + 20) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) solutionCounter == solverswitch + 20"); if (curr_m?.IsConnected == true) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) SWITCHER: pushing USER job to workers"); curr_m.PushJobToWorkers(); } else { stopConnecting = false; ConnectMain(); } /// !!!!!!!!!!!!!!! resetRound(); //remove this if we want two m-mf-gf-m, now we have m-mf-gf so it will never fall to next else-if stopConnecting = true; //in case mf gf are not reachable, they are trying to connect here in loop tryCloseConn(curr_mf); tryCloseConn(curr_gf); } else if (solutionCounter >= solutionRound) { Logger.Log(LogLevel.DEBUG, $"({solutionCounter}) Cant be here: solutionCounter >= solutionRound"); //this only executes in case we switch to m-mf-gf-m //now it is only m-mf-gf co never comes here resetRound(); } } }
//worker found solution public static void SubmitSolution(SharedSerialization.Solution sol) { //todo wrap Solution into richer class with internal info // diff check !! ConnectionManager.SubmitSol(sol); }