public void Start() { // Spawn all runners for (int runnerCount = 0; runnerCount < numberOfRunners; runnerCount++) { GameObject runner = Instantiate(runnerObject) as GameObject; runner.GetComponent <RunnerCtrl>().SetupRunner(runnerCount); } generation = FileCtrl.GetStatistics()[0]; }
public void SetupEventHandlers() { LMLoggers.LognLM applog = NC.App.Loggers.Logger(LMLoggers.AppSection.App); /// set up the 7 magic event handlers /// here I have a base handler that does the same thing for every event (writes a string to the log) SetEventHandler(ActionEvents.EventType.PreAction, (object o) => { string s = FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.PreAction, applog, LogLevels.Verbose, o); }); SetEventHandler(ActionEvents.EventType.ActionPrep, (object o) => { string s = FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.ActionPrep, applog, LogLevels.Verbose, o); }); SetEventHandler(ActionEvents.EventType.ActionStart, (object o) => { string s = FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.ActionStart, applog, LogLevels.Verbose, o); }); SetEventHandler(ActionEvents.EventType.ActionInProgress, (object o) => { string s = FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.ActionInProgress, applog, LogLevels.Verbose, o); }); SetEventHandler(ActionEvents.EventType.ActionStop, (object o) => { string s = FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.ActionStop, applog, LogLevels.Warning, o); }); SetEventHandler(ActionEvents.EventType.ActionCancel, (object o) => { string s = FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.ActionCancel, applog, LogLevels.Warning, o); }); SetEventHandler(ActionEvents.EventType.ActionFinished, (object o) => { FileCtrl f = (FileCtrl)o; if (o == null) { String s = "Finished: SOH " + NC.App.Opstate.SOH + " but no processing occurred"; applog.TraceEvent(LogLevels.Verbose, FileCtrl.logid[ActionEvents.EventType.ActionFinished], s); } else { FileCtrl.LoggableFileProcessingStatus(ActionEvents.EventType.ActionFinished, applog, LogLevels.Verbose, o); } NC.App.Opstate.SOH = NCC.OperatingState.Stopped; // in case we got here after a Cancel NC.App.Loggers.Flush(); }); NC.App.Opstate.SOH = NCC.OperatingState.Stopped; }
private void On_BTN_Resolve_Click(object sender, RoutedEventArgs e) { bool bResolved = FileCtrl.ResolveFile(_resolveFile.FilePath, Convert.ToBoolean(CB_IsDecrypt.IsChecked)); if (bResolved) { MessageBox.Show("解析成功!"); } else { MessageBox.Show("解析失敗!"); } }
void Awake() { if (GameObject.FindGameObjectsWithTag("Canvas").Length > 1 && !firstCanvas) { Destroy(gameObject); } else { firstCanvas = true; } stats = FileCtrl.GetStatistics(); genTxt.text = "Generation:\n" + stats[0].ToString(); fitTxt.text = "Top Fitness:\n" + stats[1].ToString(); }
public NN(int playerID, int inputNodes, int hiddenNodes, int outputNodes) { NN_Data saveData = FileCtrl.ReadData(playerID); // If file exists for this playerID, read file and set NN data if (saveData != null) { nn_data.ih_w = saveData.ih_w; nn_data.ih_b = saveData.ih_b; nn_data.ho_w = saveData.ho_w; nn_data.ho_b = saveData.ho_b; } // If file does not exist for this playerID, create new set of NN_Data else { nn_data.ih_w = Math.RandomMatrix(inputNodes, hiddenNodes); nn_data.ih_b = Math.RandomLst(hiddenNodes); nn_data.ho_w = Math.RandomMatrix(hiddenNodes, outputNodes); nn_data.ho_b = Math.RandomLst(outputNodes); } }
// Genetic algorithm to create new neural networks void Reproduce() { // Breed and save children to file for (int ID = 0; ID < numberOfRunners - 1; ID++) { // Selection NN_Data[] parents = SelectParents(); // Cross Over to child DNA and mutate the child's DNA NN_Data childDNA = CrossOver(parents); // Save new genes FileCtrl.WriteData(ID, childDNA); } // Save the fittest runner on his own FileCtrl.WriteData(deathList.Count - 1, deathList[deathList.Count - 1].nn_data); FileCtrl.SaveStats(generation + 1, deathList[deathList.Count - 1].framesAlive); UnityEngine.SceneManagement.SceneManager.LoadScene(0); }
private void On_BTN_Merge_Click(object sender, RoutedEventArgs e) { BTN_Merge.IsEnabled = false; List <String> fileList = new List <String>(); foreach (CopyFileVM vm in _fileColle) { fileList.Add(vm.FilePath); } bool bMerged = FileCtrl.MergeFiles(fileList, Convert.ToBoolean(CB_IsEncrypt.IsChecked), TXTBOX_AnotherPubKey.Text); if (bMerged) { MessageBox.Show("合併成功!"); } else { MessageBox.Show("合併失敗!"); } BTN_Merge.IsEnabled = true; }
// Use this for initialization void Awake() { instance = this; }
public void ResetPressed() { FileCtrl.DeleteData(); Destroy(GameObject.Find("Canvas")); UnityEngine.SceneManagement.SceneManager.LoadScene(0); }
/// <summary> /// Set up action event handlers for a FileCtrl instance, uses FCtrlBind subclass /// </summary> /// <returns></returns> public bool InitializeFileControllers() { procFctrl = new FCtrlBind(); measFctrl = new FCtrlBind(); LMLoggers.LognLM applog = NC.App.Logger(LMLoggers.AppSection.App); /* * The action event handlers. * * There are 7 event types, see ActionEvents.EventType. * * The code fires a registered event handler at appropriate processing stages based on the action event type. * Unregistered handlers are simply ignored. * E.g. The ActionStart event is fired when an action starts. An action is a specific user task such as 'assay' * over NCD files or an assay from live LMMM DAQ. * * In the examples shown here for NCD file processing, very little reporting actually occurs. * The parameter for each event hnadler is an object, and as yet undefined. * I would use delegates to force the appropriate parameter types here, unlike the timer callbacks above. * But I've not yet completed this design and implementation * * Implementing these to report complex status to the logger and the UI control is the next step. * * I do not know which approach will serve us better for a large system, but we do have both timer pull and system push approaches here, so I'll keep them for now. * */ /// set up the 7 magic event handlers /// here I have a base handler that does the same thing for every event (writes a string to the log), /// and I reuse that string by posting it to the progress handler measFctrl.SetEventHandler(ActionEvents.EventType.PreAction, (object o) => { string s = FileCtrl.LogAndSkimFileProcessingStatus(ActionEvents.EventType.PreAction, applog, LogLevels.Verbose, o); measFctrl.mProgressTracker.ReportProgress(0, s);// "..."); }); measFctrl.SetEventHandler(ActionEvents.EventType.ActionPrep, (object o) => { string s = FileCtrl.LogAndSkimFileProcessingStatus(ActionEvents.EventType.ActionPrep, applog, LogLevels.Verbose, o); measFctrl.mProgressTracker.ReportProgress(0, s);//"Prep"); }); measFctrl.SetEventHandler(ActionEvents.EventType.ActionStart, (object o) => { string s = FileCtrl.LogAndSkimFileProcessingStatus(ActionEvents.EventType.ActionStart, applog, LogLevels.Verbose, o); measFctrl.mProgressTracker.ReportProgress(1, s);//"Starting..."); }); measFctrl.SetEventHandler(ActionEvents.EventType.ActionInProgress, (object o) => { measStatus = new MeasurementStatus(); measStatus.UpdateWithMeasurement(); measStatus.UpdateWithInstruments(); updateGUIWithChannelRatesData = true; string s2 = FileCtrl.LogAndSkimFileProcessingStatus(ActionEvents.EventType.ActionInProgress, applog, LogLevels.Verbose, o); if (!string.IsNullOrEmpty(s2)) { s2 = "(" + s2 + ")"; } int per = Math.Abs(Math.Min(100, (int)Math.Round(100.0 * ((measStatus.CurrentRepetition - 1) / (double)measStatus.RequestedRepetitions)))); try { measFctrl.mProgressTracker.ReportProgress(per, // a % est of files string.Format("{0} of {1} {2}", measStatus.CurrentRepetition, measStatus.RequestedRepetitions, s2)); // n of m, and file name } catch (ArgumentOutOfRangeException) { applog.TraceEvent(LogLevels.Verbose, 58, "{0} inconsistent", per); } }); measFctrl.SetEventHandler(ActionEvents.EventType.ActionStop, (object o) => { string s = FileCtrl.LogAndSkimFileProcessingStatus(ActionEvents.EventType.ActionStop, applog, LogLevels.Warning, o); measFctrl.mProgressTracker.ReportProgress(100, s);//"Stopping..."); }); measFctrl.SetEventHandler(ActionEvents.EventType.ActionCancel, (object o) => { string s = FileCtrl.LogAndSkimFileProcessingStatus(ActionEvents.EventType.ActionCancel, applog, LogLevels.Warning, o); measFctrl.mProgressTracker.ReportProgress(100, s);//"Cancelling..."); }); measFctrl.SetEventHandler(ActionEvents.EventType.ActionFinished, (object o) => { string s = ""; if (o != null && o is FileCtrl) { FileCtrl f = (FileCtrl)o; measStatus = new MeasurementStatus(); // preps local state for refresh on channel and computed rates for now, follow up with all other state measStatus.UpdateWithMeasurement(); s = FileCtrl.MeasStatusString(measStatus); updateGUIWithChannelRatesData = true; UpdateGUIWithNewdata(); } NC.App.Opstate.SOH = NCC.OperatingState.Stopped; // in case we got here after a Cancel // general logger: to the console, and/or listbox and/or log file or DB applog.TraceEvent(LogLevels.Verbose, ActionEvents.logid[ActionEvents.EventType.ActionFinished], s); // specialized updater for UI or file measFctrl.mProgressTracker.ReportProgress(100, "Completed"); }); procFctrl.SetEventHandler(ActionEvents.EventType.PreAction, (object o) => { string s = FileCtrl.LogAndSkimFileProcessingStatus(ActionEvents.EventType.PreAction, applog, LogLevels.Verbose, o); procFctrl.mProgressTracker.ReportProgress(0, s);// "..."); }); procFctrl.SetEventHandler(ActionEvents.EventType.ActionPrep, (object o) => { string s = FileCtrl.LogAndSkimFileProcessingStatus(ActionEvents.EventType.ActionPrep, applog, LogLevels.Verbose, o); procFctrl.mProgressTracker.ReportProgress(0, s);//"Prep"); }); procFctrl.SetEventHandler(ActionEvents.EventType.ActionStart, (object o) => { string s = FileCtrl.LogAndSkimFileProcessingStatus(ActionEvents.EventType.ActionStart, applog, LogLevels.Verbose, o); procFctrl.mProgressTracker.ReportProgress(1, s);//"Starting..."); }); procFctrl.SetEventHandler(ActionEvents.EventType.ActionInProgress, (object o) => { NCCTransfer.TransferEventArgs e = (NCCTransfer.TransferEventArgs)o; procFctrl.mProgressTracker.ReportProgress(e.percent, e.msg); }); procFctrl.SetEventHandler(ActionEvents.EventType.ActionStop, (object o) => { string s = FileCtrl.LogAndSkimFileProcessingStatus(ActionEvents.EventType.ActionStop, applog, LogLevels.Warning, o); procFctrl.mProgressTracker.ReportProgress(100, s);//"Stopping..."); }); procFctrl.SetEventHandler(ActionEvents.EventType.ActionCancel, (object o) => { string s = FileCtrl.LogAndSkimFileProcessingStatus(ActionEvents.EventType.ActionCancel, applog, LogLevels.Warning, o); procFctrl.mProgressTracker.ReportProgress(100, s);//"Cancelling..."); }); procFctrl.SetEventHandler(ActionEvents.EventType.ActionFinished, (object o) => { NC.App.Opstate.SOH = OperatingState.Stopped; // in case we got here after a Cancel // general logger: to the console, and/or listbox and/or log file or DB applog.TraceEvent(LogLevels.Verbose, ActionEvents.logid[ActionEvents.EventType.ActionFinished]); // specialized updater for UI or file procFctrl.mProgressTracker.ReportProgress(100, "Completed"); }); NC.App.Opstate.SOH = OperatingState.Void; return(true); }
protected void Page_Load(object sender, EventArgs e) { base.LoadPage(); m_szInfo = ""; ACTIVITYPLANREQ vrParameter = new ACTIVITYPLANREQ(); UNIACTIVITYPLAN[] vrResult; string id = Request["id"]; vrParameter.dwGetType = (uint)ACTIVITYPLANREQ.DWGETTYPE.ACTIVITYPLANGET_BYID; vrParameter.szGetKey = id; FileCtrl fileCtrl = new FileCtrl(); string[] szImgList = fileCtrl.readlist(Server.MapPath(@"ActivityPlanImg\" + id)); if (szImgList == null || szImgList.Length <= 0) { space_tabs.Style.Add("display", "none"); } else { string szTemp = "none"; foreach (string f in szImgList)//xiaobaigang为文件夹名称 { if (szTemp == "none") { szImgBig += "<img src='ActivityPlanImg/" + id + "/" + f + "' width='510' height='350'>"; szTemp = ""; } szImgSmall += "<li><a href='' class='cur'><img src='ActivityPlanImg/" + id + "/" + f + "' width='84' height='55'></a></li>"; } space_tabs.Style.Add("display", "inline"); } if (m_Request.Reserve.GetActivityPlan(vrParameter, out vrResult) == REQUESTCODE.EXECUTE_SUCCESS) { for (int i = 0; i < vrResult.Length; i++) { string szRepory = ""; uint uStatue = (uint)vrResult[i].dwStatus; if ((uStatue & (uint)ADMINCHECK.DWCHECKSTAT.CHECKSTAT_ADMINOK) <= 0) { continue; } if ((uStatue & (uint)UNITESTPLAN.DWSTATUS.TESTPLANSTAT_UNOPEN) > 0) { continue; } uint dwPublishDate = (uint)vrResult[i].dwPublishDate; uint dwEnrollDeadline = (uint)vrResult[i].dwEnrollDeadline; uint dwActivityDate = (uint)vrResult[i].dwActivityDate; uint dwBegIntime = (uint)vrResult[i].dwBeginTime; uint dwEndTime = (uint)vrResult[i].dwEndTime; m_szInfo += "</tr><tr class=\"detail\" style=\"display:inline;\"><td colspan=\"2\">"; m_szInfo += "<p><table style=\"margin:12px\">"; m_szInfo += "<tr><td colspan=\"2\">" + szRepory + "</td></tr>"; m_szInfo += "<tr><td style=\"width:100px\">活动主题</td><td>" + vrResult[i].szActivityPlanName.ToString() + "</td></tr>"; m_szInfo += "<tr><td>主办单位</td><td>" + vrResult[i].szHostUnit.ToString() + "</td></tr>"; m_szInfo += "<tr><td>承办单位</td><td>" + vrResult[i].szOrganizer.ToString() + "</td></tr>"; m_szInfo += "<tr><td>主讲人</td><td>" + vrResult[i].szPresenter.ToString() + "</td></tr>"; m_szInfo += "<tr><td>活动介绍</td><td>" + vrResult[i].szIntroInfo.ToString() + "</td></tr>"; m_szInfo += "<tr><td>参与者要求</td><td>" + vrResult[i].szDesiredUser.ToString() + "</td></tr>"; m_szInfo += "<tr><td>活动介绍</td><td>" + vrResult[i].szIntroInfo + "</td></tr>"; m_szInfo += "<tr><td>联系人</td><td>" + vrResult[i].szContact.ToString() + "</td></tr>"; m_szInfo += "<tr><td>联系人电话</td><td>" + vrResult[i].szTel.ToString() + "</td></tr>"; m_szInfo += "<tr><td>限制报名人数</td><td>" + vrResult[i].dwMaxUsers.ToString() + "</td></tr>"; m_szInfo += "<tr><td>已申请人数</td><td>" + vrResult[i].dwEnrollUsers.ToString() + "</td></tr>"; if (dwActivityDate != 20990101) { m_szInfo += "<tr><td>申请加入截止日期</td><td>" + dwEnrollDeadline / 10000 + "-" + (dwEnrollDeadline / 100 % 100) + "-" + (dwEnrollDeadline % 100) + "</td></tr>"; string szResvTime = ((int)vrResult[i].dwBeginTime / 100) + ":" + ((int)vrResult[i].dwBeginTime % 100).ToString("00") + "—" + ((int)vrResult[i].dwEndTime / 100) + ":" + ((int)vrResult[i].dwEndTime % 100).ToString("00"); m_szInfo += "<tr><td>活动安排时间</td><td>" + dwActivityDate / 10000 + "-" + (dwActivityDate / 100 % 100) + "-" + (dwActivityDate % 100) + " " + szResvTime + "</td></tr>"; } else { m_szInfo += "<tr><td>申请加入截止日期</td><td>待定</td></tr>"; m_szInfo += "<tr><td>活动安排时间</td><td>待定</td></tr>"; } m_szInfo += "<tr><td>主办地点</td><td>" + vrResult[i].szSite.ToString() + "</td></tr>"; m_szInfo += "<tr><td> </td><td> </td></tr>"; m_szInfo += "</table></p></td></tr>"; } } else { m_szInfo = m_Request.szErrMessage; } }