예제 #1
0
        public MatrixBasedDependencyAnalysis(IEnumerable <WorkflowComponent> models)
        {
            ModelsList = models?.ToList() ?? throw new NullReferenceException();

            List <Data> data = models.GetAllData();

            //Model-Based Incidence Matrix
            IM = LibishMatrixCalculators.GetIncidenceMatrix(models.ToList(), data);
            // Model-Based DSM for model forward tracing
            DSM = CreateDSM(IM);
            // Model-Based transposed DSM for model backward tracing
            DSMT = DSM.Transpose();

            Models       = models.ToArray();
            ModelIndices = Models.Select((m, i) => new { m.Id, Index = i }).ToDictionary(m => m.Id, m => m.Index);

            // Variable-Based Incidence Matrix
            Matrix <double> VBIM = IM.Transpose();

            // Variable-Based DSM for data forward tracing
            VBDSM = CreateDSM(VBIM);
            // Variable-Based transposed DSM for data backward tracing
            VBDSMT = VBDSM.Transpose();

            DataIndices = LibishMatrixCalculators.GetDataIndices(data);
            var allData = data.ToDictionary(d => d.Id);

            Data = new Data[DataIndices.Count];
            foreach (KeyValuePair <string, int> kvp in DataIndices)
            {
                Data[kvp.Value] = allData[kvp.Key];
            }
        }
예제 #2
0
        public override void OnInspectorGUI()
        {
            Datasack ds = (Datasack)target;

            DrawDefaultInspector();

            EditorGUILayout.BeginVertical();

            if (GUILayout.Button("CODEGEN"))
            {
                GenerateCode();
            }

            GUILayout.Space(20);

            if (GUILayout.Button("RUNTIME POKE"))
            {
                ds.Poke();
            }

            GUILayout.Space(20);

            if (GUILayout.Button("RUNTIME TOGGLE"))
            {
                ds.bValue = !ds.bValue;
            }

            GUILayout.Space(20);

            GUI.color = Color.green;
            if (GUILayout.Button("RESET TO INITIAL VALUE"))
            {
                ds.Value = ds.InitialValue;
            }

            GUILayout.Space(20);

            GUI.color = Color.cyan;
            if (GUILayout.Button("OUTPUT CURRENT VALUE"))
            {
                string part1 = "Datasack " + ds.FullName + " is currently: '" + ds.Value + "'";
                string part2 = " <not parseable as float>";
                try
                {
                    part2 = "--> as float value = " + ds.fValue;
                }
                catch { }                               // gotta catch 'em all: fairly harmless in a small context
                Debug.Log(part1 + part2);
            }

            GUILayout.Space(20);

            GUI.color = Color.yellow;
            if (GUILayout.Button("DELETE SAVED VALUE"))
            {
                if (PlayerPrefs.HasKey(PlayerPrefsKey()))
                {
                    PlayerPrefs.DeleteKey(PlayerPrefsKey());
                    PlayerPrefs.Save();
                }
            }

            GUILayout.Space(20);

            GUI.color = Color.red;
            if (GUILayout.Button("DELETE ALL PLAYER PREFS"))
            {
                if (EditorUtility.DisplayDialog("CONFIRM!",
                                                "Confirm DELETE all PlayerPrefs stored settings?\n\n" +
                                                "(THIS ACTION CANNOT BE UNDONE!)", "DELETE ALL PREFS", "Cancel"))
                {
                    DSM.ResetDictionaryIfRunning();
                    PlayerPrefs.DeleteAll();
                    PlayerPrefs.Save();
                }
            }

            GUILayout.Space(20);

            GUI.color = ds.DebugBreak ? Color.white : Color.gray;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Debug Break", GUILayout.Width(160));
            ds.DebugBreak = GUILayout.Toggle(ds.DebugBreak, "BREAK");
            GUILayout.EndHorizontal();

            GUI.color = ds.DebugLogging ? Color.white : Color.gray;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Debug Logging", GUILayout.Width(160));
            ds.DebugLogging = GUILayout.Toggle(ds.DebugLogging, "LOG");
            GUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }
예제 #3
0
        public override void OnInspectorGUI()
        {
            Datasack ds = (Datasack)target;

            DrawDefaultInspector();

            EditorGUILayout.BeginVertical();

            if (GUILayout.Button("CODEGEN"))
            {
                GenerateCode();
            }

            GUILayout.Space(20);

            if (GUILayout.Button("RUNTIME POKE"))
            {
                ds.Poke();
            }

            GUILayout.Space(20);

            if (GUILayout.Button("RUNTIME TOGGLE"))
            {
                ds.bValue = !ds.bValue;
            }

            GUILayout.Space(20);

            GUI.color = Color.green;
            if (GUILayout.Button("RESET TO INITIAL VALUE"))
            {
                ds.Value = ds.InitialValue;
            }

            GUILayout.Space(20);

            GUI.color = Color.cyan;
            if (GUILayout.Button("OUTPUT CURRENT VALUE"))
            {
                Debug.Log(ds.DisplayDebugOutput());
            }

            GUILayout.Space(20);

            GUI.color = Color.yellow;
            if (GUILayout.Button("DELETE SAVED VALUE"))
            {
                if (PlayerPrefs.HasKey(PlayerPrefsKey()))
                {
                    PlayerPrefs.DeleteKey(PlayerPrefsKey());
                    PlayerPrefs.Save();
                }
            }

            GUILayout.Space(20);

            GUI.color = Color.red;
            if (GUILayout.Button("DELETE ALL PLAYER PREFS"))
            {
                if (EditorUtility.DisplayDialog("CONFIRM!",
                                                "Confirm DELETE all PlayerPrefs stored settings?\n\n" +
                                                "(THIS ACTION CANNOT BE UNDONE!)", "DELETE ALL PREFS", "Cancel"))
                {
                    DSM.ResetDictionaryIfRunning();
                    PlayerPrefs.DeleteAll();
                    PlayerPrefs.Save();
                }
            }

            GUILayout.Space(20);

            GUI.color = ds.DebugBreak ? Color.white : Color.gray;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Debug Break", GUILayout.Width(160));
            ds.DebugBreak = GUILayout.Toggle(ds.DebugBreak, "BREAK");
            GUILayout.EndHorizontal();

            GUI.color = ds.DebugLogging ? Color.white : Color.gray;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Debug Logging", GUILayout.Width(160));
            ds.DebugLogging = GUILayout.Toggle(ds.DebugLogging, "LOG");
            GUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }