private void CreateTaskSets() { bool bStatus; allTaskSets = new List <CTaskSet>(); //Create Configuration config = CConfiguration.GetObject(20, 3, 3, 40, 1, 7, 0, 0); config.bUniqueExecutionTimes = true; //Add Sched Tests schedTests = new List <ISchedulabilityTest>(); ISchedulabilityTest sch1 = new CHyperbolicSchedulabilityTest(); ISchedulabilityTest sch2 = new CLiuLaylandSchedulabilityTest(); ISchedulabilityTest sch3 = new CUtilizationSchedulabilityTest(); schedTests.Add(sch1); schedTests.Add(sch2); schedTests.Add(sch3); //Add Satisfiability Conditions satConditions = new List <ISatisfiabilityCondition>(); ISatisfiabilityCondition sat1 = new CPFRPSatisfiabilityCondition(); satConditions.Add(sat1); //Generate Period Sets and Execution Times List <CPeriodSet> _periodSets = GetPeriods(config); List <double> _executionTimes = GetExecutionTime(config); //Generate Release Offsets List <double> _releaseOffsets = GetReleaseOffsets(config); //Create Callbacks CCallBack cb = new CCallBack(); cb.funcReceivedTaskSet += CheckSchedulability; //Call Task Set Generator CTaskSetGenerator tsg = new CTaskSetGenerator(); tsg.GenerateTaskSets(_periodSets, _executionTimes, _releaseOffsets, config, cb); //Write Task Set Files CSimpleFileFormatter ff = new CSimpleFileFormatter(); bStatus = ff.WriteFiles(allTaskSets, Application.StartupPath + "\\Files", config); if (bStatus) { MessageBox.Show("All Files Successively Written"); } }
static public bool SendMessageToC(string className, string selector, object[] arguments, bool carryCallback) { Debug.Log("Unity: ATUnityCBridge::SendMessageToC()"); Dictionary <string, object> msgDict = new Dictionary <string, object>(); msgDict.Add("class", className); msgDict.Add("selector", selector); msgDict.Add("arguments", arguments); CCallBack callback = null; if (carryCallback) { callback = MessageFromC; } #if UNITY_IOS || UNITY_IPHONE return(message_from_unity(Json.Serialize(msgDict), callback)); #else return(false); #endif }
//This Function Runs in a new Thread private void StartTaskGeneration(Object threadObject) { bool bStatus; CThreadObject to = (CThreadObject)threadObject; CConfiguration config = to.config; List <CPeriodSet> periodSets; List <double> executionTimes; List <double> releaseOffsets; //Set Global Vars _config = config; _taskCount = 1; _allTaskSets = new List <CTaskSet>(); //Generate Period Sets UpdateStatus("Calling Period Generator ..."); IPeriodGenerator pg = (IPeriodGenerator)_internalConfig.selectedPeriodGenerator.objMain; //try //{ periodSets = pg.GetPeriods(config, null); //} //catch (Exception e) //{ //if(pg != null) // MessageBox.Show("Error in Period Generation. Message from selected Plug In : " + pg.Message); //else // MessageBox.Show("Error in Period Generation." + e.Message); //return; //} AddRunTimeMessage("Period Generator", pg.Message); //Generate Execution Times UpdateStatus("Calling Execution Time Generator ..."); IExecutionTimeGenerator etg = (IExecutionTimeGenerator)_internalConfig.selectedExecutionTimeGenerator.objMain; try { executionTimes = etg.GetExecutionTimes(config); } catch (Exception e) { if (etg != null) { MessageBox.Show("Error in Execution Time Generation. Message from selected Plug In : " + etg.Message); } else { MessageBox.Show("Error in Execution Time Generation." + e.Message); } return; } AddRunTimeMessage("Execution Time Generator", etg.Message); //Generate Release Offset UpdateStatus("Calling Release Offset Generator ..."); IReleaseOffsetGenerator rog = (IReleaseOffsetGenerator)_internalConfig.selectedReleaseOffsetGenerator.objMain; try { releaseOffsets = rog.GetReleaseOffsets(config); } catch (Exception e) { if (rog != null) { MessageBox.Show("Error in Release Offset Generation. Message from selected Plug In : " + rog.Message); } else { MessageBox.Show("Error in Release Offset Generation." + e.Message); } return; } AddRunTimeMessage("Release Offsets", rog.Message); //Create Callback Function UpdateStatus("Setting Callback Function ..."); CCallBack cb = new CCallBack(); cb.funcReceivedTaskSet += CheckSchedulability; //Call Task Set Generator UpdateStatus("Calling Task Generator..."); ITaskSetGenerator tsg = (ITaskSetGenerator)_internalConfig.selectedTaskSetGenerator.objMain; try { tsg.GenerateTaskSets(periodSets, executionTimes, releaseOffsets, config, cb); } catch (Exception e) { if (tsg != null) { MessageBox.Show("Error in Task Set Generation. Message from Selected Plug In : " + tsg.Message); } else { MessageBox.Show("Error in Task Set Generation." + e.Message); } return; } AddRunTimeMessage("Task Set Generator", tsg.Message); //Write Task Set Files UpdateStatus("Writing Task Files..."); if (checkBoxPruneFolder.Checked) { //Delete Files DeleteFilesFromFolder(to.folderPathforFiles); } IFileFormatter ff = (IFileFormatter)_internalConfig.selectedFileFormatter.objMain; try { bStatus = ff.WriteFiles(_allTaskSets, to.folderPathforFiles, config); } catch (Exception e) { if (tsg != null) { MessageBox.Show("Error in Task Set Generation. Message from Selected Plug In : " + tsg.Message); } else { MessageBox.Show("Error in Task Set Generation." + e.Message); } return; } AddRunTimeMessage("File Formatter", ff.Message); UpdateStatus("Task Set Generation Complete"); }
extern static int get_message_for_unity(string msg, CCallBack callback);
extern static bool message_from_unity(string msg, CCallBack callback);
public void GenerateTaskSets(List <CPeriodSet> periodSets, List <double> executionTimes, List <double> releaseOffsets, CConfiguration config, CCallBack addTaskCallback) { CTaskSet ts; CTask task; int ii; int executionTimeIdx = 0; int releaseOffsetIdx = 0; int count = 0; _message = ""; if (periodSets.Count < config.NumberOfTaskSets) { _message = "Number of period sets is lower than number of required tasks. This task generator can only generate number of tasks same as period sets"; } periodSets.Sort(); try { foreach (CPeriodSet ps in periodSets) { ts = new CTaskSet(); if (count == config.NumberOfTaskSets) { break; } for (ii = 0; ii < ps.Count; ii++) { task = new CTask("T" + ii.ToString(), ii, ps.Get(ii), executionTimes[executionTimeIdx++], releaseOffsets[releaseOffsetIdx], 0); ts.Add(task); if (executionTimeIdx >= executionTimes.Count) { executionTimeIdx = 0; } if (releaseOffsetIdx >= releaseOffsets.Count) { releaseOffsetIdx = 0; } } //Task Set Created, Now Call Delegate if (addTaskCallback.AddGeneratedTaskSet(ts)) { count++; } } } catch (Exception e) { _message = "Error in Task Generation Routine : " + e.Message; } }