private void Update() { if (this.worldSpeed < 0.0001f || this.runningRoutine == null) { return; } if (this.runningRoutine == this.moveForward) { this.robot.transform.position = this.robot.transform.position + this.robot.transform.forward * this.worldSpeed * Time.deltaTime; var dirToDest = this.destination - this.robot.transform.position; var dot = Vector3.Dot(dirToDest, this.transform.forward); if (dot < 0) { this.robot.transform.position = this.destination; this.FinishedCallback(); this.FinishedCallback = null; this.runningRoutine = null; } } if (this.runningRoutine == this.rotateLeft || this.runningRoutine == this.rotateRight) { this.robot.transform.rotation = Quaternion.RotateTowards(this.transform.rotation, this.targetRotation, 1f); var dot = Quaternion.Dot(this.transform.rotation, this.targetRotation); if (dot > 0.9999f) { this.robot.transform.rotation = this.targetRotation; this.FinishedCallback(); this.FinishedCallback = null; this.runningRoutine = null; } } }
private void ReloadSubroutine() { Log.Write("Reloading subroutine " + SubRoutineBlueprint); if (this.subRoutineInstance != null) { this.subRoutineInstance.Destroy(); this.subRoutineInstance.ExitNode.OnExecuted -= ExitNode_OnExecuted; this.subRoutineInstance.EntryNode.OnRequestData -= EntryNode_OnRequestData; this.subRoutineInstance = null; } try { this.subRoutineInstance = KSPOperatingSystem.LoadSubRoutine(SubRoutineBlueprint, true); } catch (Exception e) { Log.Write("Failed to load subroutine: " + e.Message); } if (this.subRoutineInstance == null) { Log.Write("Could not load SubRoutine " + SubRoutineBlueprint + ", deleting node"); RequestRemoval(); } else { this.subRoutineInstance.ExitNode.OnExecuted += ExitNode_OnExecuted; this.subRoutineInstance.EntryNode.OnRequestData += EntryNode_OnRequestData; SyncInputs(); SyncOutputs(); } }
private void RotateRight(int[] args, Action callback) { this.runningRoutine = this.rotateRight; this.FinishedCallback = callback; int dist = args.Length == 1 ? args[0] : 0; this.targetRotation = robot.transform.rotation * Quaternion.Euler(0, 90, 0); this.worldSpeed = this.TickSpeedToWorldSpeed(this.Speed); }
private void MoveForward(int[] args, Action callback) { this.runningRoutine = this.moveForward; this.FinishedCallback = callback; int dist = args.Length == 1 ? args[0] : 0; this.destination = robot.transform.position + robot.transform.forward * STEP_SIZE * dist; this.worldSpeed = this.TickSpeedToWorldSpeed(this.Speed); }
public void AddSubroutine(SubRoutine sub) { if (!this.subs.ContainsKey(sub.Name)) { this.subs.Add(sub.Name, sub); } if (!this.subs.ContainsKey(sub.FullName)) { this.subs.Add(sub.FullName, sub); } }
IEnumerator Routine(UnityAsyncHandler.Input input, SubRoutine[] subRoutines) { float subProgressTerm = 1 / (float)subRoutines.Length; IEnumerator enumerator; SubRoutineOutput subOutput = new SubRoutineOutput(); for (int n = 0, count = subRoutines.Length; n < count; ++n) { subOutput.outSubProgress = 0; this.SetSubProgressRange(this.Progress + subProgressTerm); SubRoutine subRoutine = subRoutines[n]; enumerator = subRoutine(input, this.Out, subOutput); while (enumerator.MoveNext()) { this.SetSubProgress(subOutput.outSubProgress); this.Update(); yield return(enumerator.Current); if (CancellableSignal.IsCancelled(input.signal)) { if (!this.IsCanceled) { this.Cancel(); } this.OnCancelDone(); yield break; } } this.SetSubProgress(1); this.Update(); yield return(null); if (CancellableSignal.IsCancelled(input.signal)) { if (!this.IsCanceled) { this.Cancel(); } this.OnCancelDone(); yield break; } } this.Done(); yield return(null); }
public ISubRoutine WaitSubRoutine(IEnumerator <IYieldable> routineEnumerator, [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0) { var currentCoroutine = currentRoutine as Coroutine; if (currentCoroutine != null) { throw new Exception("코루틴이 시작되지 않은 상태에서 입니다."); } var subRoutine = new SubRoutine(); subRoutine.Initialize(routineEnumerator, filePath, lineNumber); return(subRoutine); }
// Start is called before the first frame update void Start() { this.robot = this.GetComponentInParent <RobotBehavior>(); this.game = GameObject.FindObjectOfType <GameManager>(); this.animator = this.GetComponent <Animator>(); var chassis = this.GetComponentInParent <ChassisBehavior>(); var cpu = chassis.GetComponentInChildren <CpuBehavior>(); this.harvestRoutine = new SubRoutine { Name = "harvest", FullName = "arm.harvest", Owner = this.GetComponent <RobotPart>(), Fn = this.Harvest }; cpu.AddSubroutine(this.harvestRoutine); }
// Start is called before the first frame update void Start() { this.robot = this.GetComponentInParent <RobotBehavior>(); this.game = GameObject.FindObjectOfType <GameManager>(); var chassis = this.GetComponentInParent <ChassisBehavior>(); var cpu = chassis.GetComponentInChildren <CpuBehavior>(); this.waterParticles.Pause(); this.waterRoutine = new SubRoutine { Name = "water", FullName = "arm.water", Owner = this.GetComponent <RobotPart>(), Fn = this.Water }; cpu.AddSubroutine(this.waterRoutine); }
private void Start() { this.robot = this.GetComponentInParent <RobotBehavior>(); this.game = GameObject.FindObjectOfType <GameManager>(); var chassis = this.GetComponentInParent <ChassisBehavior>(); var cpu = chassis.GetComponentInChildren <CpuBehavior>(); this.moveForward = new SubRoutine { Name = "move_forward", FullName = "leg.move_forward", Owner = this.GetComponent <RobotPart>(), Fn = this.MoveForward }; this.rotateLeft = new SubRoutine { Name = "rotate_left", FullName = "leg.rotate_left", Owner = this.GetComponent <RobotPart>(), Fn = this.RotateLeft }; this.rotateRight = new SubRoutine { Name = "rotate_right", FullName = "leg.rotate_right", Owner = this.GetComponent <RobotPart>(), Fn = this.RotateRight }; cpu.AddSubroutine(this.moveForward); cpu.AddSubroutine(this.rotateLeft); cpu.AddSubroutine(this.rotateRight); this.destination = robot.transform.position; }
private void DrawNodeToolbar() { toolbarScrollPos = GUILayout.BeginScrollView(toolbarScrollPos, GUILayout.Width(toolbarWidth), GUILayout.Height(WinRect.height - 40)); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); if (GUILayout.Button("<", GUIController.CustomStyles)) { selectedProgram--; } GUILayout.Label("Program " + (selectedProgram + 1) + "/" + KSPOperatingSystem.ProgramCount); if (GUILayout.Button(">", GUIController.CustomStyles)) { selectedProgram++; } GUILayout.EndHorizontal(); #region back button //draw back button if (GUILayout.Button(nodeCats.TopCategory ? "---- Nodes ----" : "---- Back ----", GUIController.CustomStyles)) { if (nodeCats.TopCategory) { showNodes = !showNodes; } else { nodeCats.CategoryUp(); } } #endregion #region nodes if (showNodes) { //Draw categories var cats = nodeCats.ListSubCategories(); if (cats.Length > 0) { foreach (var cat in cats) { GUI.backgroundColor = cat.color; if (GUILayout.Button(cat.name, GUIController.CustomStyles)) { nodeCats.SelectSubCategory(cat.name); return; } } } //Draw nodes var nodes = nodeCats.ListNodes(); foreach (var node in nodes) { GUI.backgroundColor = node.color; if (GUILayout.Button(node.name, GUIController.CustomStyles) && Program != null) { Log.Write("Adding node: " + node.name); draggedNode = Program.AddNode(node.type, GUIUtility.GUIToScreenPoint(GUIController.mousePos)); dragInfo = new Vector2(0, 0); } } } #endregion GUILayout.Space(GUIController.ElSize); #region variables GUI.backgroundColor = GUIController.DefaultColor; //Draw add variable if (Program != null) { if (GUILayout.Button("---- Variables ----", GUIController.CustomStyles)) { showVariables = !showVariables; } if (showVariables) { MethodInfo addMethod = Program.GetType().GetMethod("AddVariable"); GUILayout.Label("Add variables"); foreach (var k in selectableVariableTypes) { GUI.backgroundColor = TypeColor(k.Value); if (GUILayout.Toggle(selectedVariableType == k.Value, k.Key, GUIController.CustomStyles)) { selectedVariableType = k.Value; } } GUI.backgroundColor = GUIController.DefaultColor; GUILayout.Label("Name"); currentVarName = GUILayout.TextField(currentVarName, GUIController.CustomStyles); if (GUILayout.Button("Add", GUIController.CustomStyles)) { if (!string.IsNullOrEmpty(currentVarName)) { Program.AddVariable(selectedVariableType, currentVarName); } } GUILayout.Label("Variables"); //draw variables foreach (var v in Program.Variables) { GUILayout.BeginHorizontal(); GUI.backgroundColor = TypeColor(v.Value.Type); if (GUILayout.Button(v.Key, GUIController.CustomStyles)) { //add variableNode draggedNode = Program.AddVariableNode(GUIUtility.GUIToScreenPoint(GUIController.mousePos), v.Key); dragInfo = new Vector2(0, 0); } if (GUILayout.Button("X", GUILayout.MaxWidth(GUIController.ElSize))) { //remove variable Program.RemoveVariable(v.Key); } GUILayout.EndHorizontal(); } } } GUI.backgroundColor = GUIController.DefaultColor; #endregion GUILayout.Space(GUIController.ElSize); #region subroutines if (GUILayout.Button("---- Subroutines ----", GUIController.CustomStyles)) { showSubRoutines = !showSubRoutines; } if (showSubRoutines && Program != null) { foreach (var s in subRoutines) { if (GUILayout.Button(s, GUIController.CustomStyles)) { draggedNode = Program.AddSubRoutineNode(GUIUtility.GUIToScreenPoint(GUIController.mousePos), s); dragInfo = new Vector2(0, 0); } GUILayout.BeginHorizontal(); if (GUILayout.Button("Edit", GUIController.CustomStyles)) { currentSubroutine = KSPOperatingSystem.LoadSubRoutine(s, true); currentSubroutineName = s; } GUI.backgroundColor = Color.red; if (GUILayout.Button("Delete", GUIController.CustomStyles)) { KSPOperatingSystem.DeleteSubRoutine(s); ReloadSubRoutines(); } GUI.backgroundColor = GUIController.DefaultColor; GUILayout.EndHorizontal(); } if (currentSubroutine == null) { if (GUILayout.Button("Create Subroutine", GUIController.CustomStyles)) { currentSubroutine = new SubRoutine(); } } else { GUILayout.Label("Add parameter"); if (GUILayout.Toggle(selectedParameterType == typeof(Connector.Exec), "Exec", GUIController.CustomStyles)) { selectedParameterType = typeof(Connector.Exec); } foreach (var k in selectableVariableTypes) { GUI.backgroundColor = TypeColor(k.Value); if (GUILayout.Toggle(selectedParameterType == k.Value, k.Key, GUIController.CustomStyles)) { selectedParameterType = k.Value; } } GUI.backgroundColor = GUIController.DefaultColor; GUILayout.Label("Name", GUIController.CustomStyles); currentParamName = GUILayout.TextField(currentParamName, GUIController.CustomStyles); GUILayout.BeginHorizontal(); if (GUILayout.Button("Add Input", GUIController.CustomStyles) && !string.IsNullOrEmpty(currentParamName)) { currentSubroutine.EntryNode.AddRoutineInput(currentParamName, selectedParameterType); } if (GUILayout.Button("Add Output", GUIController.CustomStyles) && !string.IsNullOrEmpty(currentParamName)) { currentSubroutine.ExitNode.AddRoutineOuput(currentParamName, selectedParameterType); } GUILayout.EndHorizontal(); GUILayout.Space(GUIController.ElSize); currentSubroutineName = GUILayout.TextField(currentSubroutineName, GUIController.CustomStyles); if (GUILayout.Button("Save", GUIController.CustomStyles) && !string.IsNullOrEmpty(currentSubroutineName)) { KSPOperatingSystem.SaveSubRoutine(currentSubroutineName, currentSubroutine, true); currentSubroutine = null; currentSubroutineName = ""; ReloadSubRoutines(); KSPOperatingSystem.InitPrograms(); } if (GUILayout.Button("Cancel", GUIController.CustomStyles)) { currentSubroutine = null; currentSubroutineName = ""; } } } #endregion GUILayout.EndVertical(); GUILayout.EndScrollView(); GUI.backgroundColor = GUIController.DefaultColor; }
/// <summary> /// Returns a list of sub-routines and their parameters. /// </summary> /// <returns>A <code>List<<see cref="SubRoutine">SubRoutine</see>></code> containing the subroutines.</returns> /// <example> /// <code> /// ## /// ## ListSubs /// /// $Sys.ListSubs("Powershell\") /// </code> /// </example> public object ListSubs() { string line; List<SubRoutine> setlist = new List<SubRoutine>(); try { xplHalSend("LISTSUBSEX"); line = GetLine(); if (line.StartsWith(XH224)) { while (1 == 1) { line = GetLine(); if (line != ".\r\n") { string[] list = line.Split('\t'); SubRoutine x = new SubRoutine(); x.ScriptName = list[0]; x.FunctionName = list[1]; x.Parameters = list[2]; setlist.Add(x); } else break; } return setlist; } else throw new Exception("Unexpected result received from server."); } finally { Disconnect(); } }
public void PublishFrame(VoltVarController Frame, string inputdatafolder, VoltVarController PreviousFrame) { SubRoutine sub = new SubRoutine(); ReadCurrentControl ReadCurrentCon = new ReadCurrentControl(); #region [ Read the Input Value Key Pairs] foreach (KeyValuePair <string, object> kvp in Frame.RawkeyValuePairs) { m_inputFrame.RawkeyValuePairs.Add(kvp.Key, kvp.Value); } #endregion #region [ Measurements Mapping ] m_inputFrame.OnNewMeasurements(); #endregion #region [ Read The Previous Run ] m_inputFrame.ReadPreviousRun(PreviousFrame); #endregion #region [ Verify Program Controls ] ReadCurrentCon.VerifyProgramControl(m_inputFrame.SubstationAlarmDevice.LtcProgram); #endregion #region [ Adjust Control Delay Counters ] //#-----------------------------------------------------------------------# //# adjust the cap bank control delay counter, which is used to ensure: # //# a. we don't do two cap bank control within 30 minutes of each other. # //# b. we don't do a tap control within a minute of a cap bank control. # //#-----------------------------------------------------------------------# if (m_inputFrame.SubstationInformation.Ncdel < m_inputFrame.SubstationInformation.Zcdel) { m_inputFrame.SubstationInformation.Ncdel = m_inputFrame.SubstationInformation.Ncdel + 1; } //#-----------------------------------------------------------------------# //# Adjust the tap control delay counter, which is used to ensure we # //# don't do a cap bank control within a minute of a tap control. # //#-----------------------------------------------------------------------# if (m_inputFrame.SubstationInformation.Ntdel < m_inputFrame.SubstationInformation.Zdel) { m_inputFrame.SubstationInformation.Ntdel = m_inputFrame.SubstationInformation.Ntdel + 1; } #endregion #region [ Read Curren Tx Values and Voltages ] m_inputFrame = ReadCurrentCon.ReadCurrentTransformerValuesAndVoltages(m_inputFrame); #endregion #region [ Check if the Previous Control Reults can Meet Our Expectation ] m_inputFrame = ReadCurrentCon.CheckPreviousControlResults(m_inputFrame); #endregion #region [ Call Sub Taps ] m_inputFrame = sub.Taps(m_inputFrame); #endregion #region [CapBank] m_inputFrame = sub.CapBank(m_inputFrame); #endregion #region [ Save before Exit ] m_logMessage = ReadCurrentCon.MessageInput; m_logMessage += sub.MessageInput; m_inputFrame.RawkeyValuePairs.Clear(); m_inputFrame.LtcStatus.Avv = 0; m_inputFrame.LtcStatus.Nins = 0; m_inputFrame.LtcStatus.MinVar = 99999; m_inputFrame.LtcStatus.MaxVar = -9999; #endregion }
public void ProcessDB(string TableName) { Constants constants = new Constants(); SubRoutine sub = new SubRoutine(); DataSet dsCount = new DataSet(); DataSet dsProcess = new DataSet(); OleDbCommand dbCmd = new OleDbCommand(); OleDbDataAdapter dbAd = new OleDbDataAdapter(); string base64Text = ""; OleDbConnection conn2 = new OleDbConnection { //ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + // "Data source= D:\\This PC\\Pars Info\\Rick PC\\rick laptop\\pars_prod_2013_pic1.accdb" ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data source=D:\\Users\\dmand\\projects\\AcccesImages\\AcccesImages\\bin\\Debug\\pars_prod_2013.accdb" }; OleDbCommandBuilder builder = new OleDbCommandBuilder(dbAd); try { conn2.Open(); dbCmd = sub.DBCommand(TableName, conn2); dbAd = new OleDbDataAdapter(dbCmd); dbAd.Fill(dsCount, TableName); } catch (Exception ex) { MessageBox.Show("Failed to process dataset.\n" + ex.Message, "ProcessDB"); } // set file path string fullpath = @constants.SystemPath + @"\"; fullpath = fullpath.Substring(6); try { double FirstHalf = 0; double SecondHalf = 0; double ReadCount = 0; double StartCount = 0; int StartCountInt = 0; int OddNumber = 0; // get record count of table double RowCount = dsCount.Tables[0].Rows.Count; // delete existing for (int xInt = 1; xInt < 3; xInt++) { if (File.Exists(fullpath + @constants.PicTable + xInt + ".json")) { File.Delete(fullpath + @constants.PicTable + xInt + ".json"); } } // set variables for even or odd record count if (RowCount % 2 == 0) { FirstHalf = RowCount / 2; SecondHalf = RowCount / 2; ReadCount = FirstHalf; } else { FirstHalf = Math.Truncate(RowCount / 2); SecondHalf = Math.Round(RowCount / 2); if (FirstHalf + SecondHalf != RowCount) { SecondHalf = SecondHalf + 1; } ReadCount = FirstHalf; OddNumber = -1; } DataSet ds = new DataSet(); //dbAd.Fill(ds, (int)StartCount, (int)ReadCount, @constants.PicTable + xInt); dbAd.Fill(ds, (int)StartCount, (int)ReadCount, TableName); // loop through tables //for (int xInt = 1; xInt < 3; xInt++) //for (int xInt = 1; xInt < dsCount.Tables[0].Rows.Count; xInt++) for (int xInt = 1; xInt < 3; xInt++) { //DataSet ds = new DataSet(); //dbAd.Fill(ds, (int)StartCount, (int)ReadCount, @constants.PicTable + xInt); //for (int yInt = 0; yInt < ds.Tables[0].Rows.Count; yInt++) for (StartCount = 0; StartCount < ReadCount; StartCount++) { StartCountInt = (int)StartCount; } { // delete image if (File.Exists(fullpath + "image_temp.jpg")) { File.Delete(fullpath + "image_temp.jpg"); } if (File.Exists(fullpath + "image_temp_compressed.jpg")) { File.Delete(fullpath + "image_temp_compressed.jpg"); } // save image to file byte[] blobpic = (byte[])ds.Tables[0].Rows[StartCountInt]["PicBlob"]; File.WriteAllBytes(fullpath + "image_temp.jpg", blobpic); // compress image base64Text = Convert.ToBase64String(blobpic); Image img = Base64ToImage(base64Text); // get image Image imgFromFile = Image.FromFile(fullpath + "image_temp.jpg"); DefaultCompresion(imgFromFile, fullpath, "image_temp_compressed.jpg"); imgFromFile.Dispose(); // release file resources // read compressed image in as base64 string ImageAsBase64 = ImageToBase64(fullpath, "image_temp_compressed.jpg"); // update ds image filed with new compressed base64 DataTable picTable = ds.Tables[0]; OleDbCommand cmdUpdate = new OleDbCommand { Connection = conn2, //CommandText = "UPDATE tblPicture1 SET PicName = 'me' WHERE IDPictures = " + ds.Tables[0].Rows[yInt]["IDPictures"] CommandText = "UPDATE " + TableName + " SET PicBlob = '" + ImageAsBase64 + "' WHERE IDPictures = " + ds.Tables[0].Rows[StartCountInt]["IDPictures"] }; cmdUpdate.ExecuteNonQuery(); //// serialize json //string output2 = JsonConvert.SerializeObject(ds, Formatting.Indented); //// write to file //File.AppendAllText(fullpath + TableName + "_" + xInt + ".json", output2); //// set second half //ReadCount = SecondHalf; //StartCount = SecondHalf + OddNumber; // images to base64 //sub.ProcessPictures(ds, TableName, constants.SystemPath, constants.PicFile); ds.Dispose(); } // serialize json string output2 = JsonConvert.SerializeObject(ds, Formatting.Indented); // write to file File.AppendAllText(fullpath + TableName + "_" + xInt + ".json", output2); //// set second half ReadCount = SecondHalf; StartCount = SecondHalf + OddNumber; } } catch (Exception ex) { MessageBox.Show("Failed to process dataset.\n" + ex.Message); } }
private void DrawNode(Node node) { bool drawInputs = true; bool drawOutputs = true; bool isEditable = false; bool isVariableNode = false; SubRoutine subRoutine = null; string variableName = ""; //find variable node NodeCategories.NodeInfo info = new NodeCategories.NodeInfo(); var nodeType = node.GetType(); if (nodeType.IsGenericType) { if (nodeType.GetGenericTypeDefinition() == typeof(VariableNode <>)) { isVariableNode = true; Variable v = node.GetType().GetProperty("Variable").GetValue(node, null) as Variable; var n = from va in Program.Variables where va.Value == v select va.Key; if (n.Count() > 0) { variableName = n.First(); info = new NodeCategories.NodeInfo(variableName, v.Type, "Variable node", TypeColor(v.Type), 120); } } } else if (node is SubroutineNode) { var sr = node as SubroutineNode; subRoutine = sr.SubRoutineInstance; info = new NodeCategories.NodeInfo(sr.SubRoutineBlueprint, typeof(SubRoutine), "Subroutine", Color.cyan, 220); } else if (node is SubRoutineEntry) { drawInputs = false; isEditable = true; info = new NodeCategories.NodeInfo("Entry", typeof(SubRoutineEntry), "Entry", Color.cyan, 220); } else if (node is SubRoutineExit) { drawOutputs = false; isEditable = true; info = new NodeCategories.NodeInfo("Exit", typeof(SubRoutineExit), "Exit", Color.cyan, 220); } else { info = nodeCats.GetNodeInfo(node.GetType()); } info.width = Mathf.Max(info.width, GUI.skin.label.CalcSize(new GUIContent(info.name)).x + GUIController.ElSize * 2); //Log.Write("Drawing node " + node + " width: " + info.width); float height = Math.Max(node.InputCount * 2 - node.InputExecCount, node.OutputCount) * GUIController.ElSize; height += GUIController.ElSize; GUI.BeginGroup(new Rect(node.Position.x, node.Position.y, info.width, height)); if (GUI.Button(new Rect(info.width - GUIController.ElSize * 1.5f, -5f, GUIController.ElSize, GUIController.ElSize), "x")) { if (draggedConnection != null) { if (draggedConnection.Node == node) { draggedConnection = null; } } Program.RemoveNode(node); return; } if (node is BaseExecutableNode) { if (subRoutine != null) { GUI.skin.label.alignment = TextAnchor.LowerCenter; if (GUI.Button(new Rect(info.width - GUIController.ElSize * 2.5f, -5f, GUIController.ElSize, GUIController.ElSize), "e")) { currentSubroutineName = (node as SubroutineNode).SubRoutineBlueprint; currentSubroutine = subRoutine; } } float c = Mathf.Max(0, Mathf.Min(1, (Time.time - (node as BaseExecutableNode).LastExecution) * 3f)); GUI.skin.label.alignment = TextAnchor.UpperRight; GUI.color = new Color(c, 1 - c, 0); GUI.Label(new Rect(info.width - GUIController.ElSize, -5f, GUIController.ElSize, GUIController.ElSize), "■"); GUI.color = Color.white; GUI.skin.label.alignment = TextAnchor.UpperCenter; } GUI.backgroundColor = info.color; GUI.Box(new Rect(0, 0, info.width, height), info.name); if (PointerAvailable && GUIController.mousePressed) { if (GUIController.mousePos.x > toolbarWidth) { if (new Rect(0, 0, info.width, 20).Contains(GUIUtility.ScreenToGUIPoint(GUIController.mousePos))) { if (Event.current.control) { if (!(node is SubRoutineEntry || node is SubRoutineExit)) { if (node is SubroutineNode) { draggedNode = Program.AddSubRoutineNode(node.Position.GetVec2(), (node as SubroutineNode).SubRoutineBlueprint); dragInfo = GUIUtility.ScreenToGUIPoint(GUIController.mousePos); } else if (isVariableNode) { draggedNode = Program.AddVariableNode(node.Position.GetVec2(), variableName); dragInfo = GUIUtility.ScreenToGUIPoint(GUIController.mousePos); } else { draggedNode = Program.AddNode(nodeType, node.Position.GetVec2()); dragInfo = GUIUtility.ScreenToGUIPoint(GUIController.mousePos); } } } else { draggedNode = node; dragInfo = GUIUtility.ScreenToGUIPoint(GUIController.mousePos); } } } } if (drawInputs) { DrawNodeInputs(node.Inputs, info.width, isEditable); } if (drawOutputs) { DrawNodeOutputs(node.Outputs, info.width, isEditable); } GUI.backgroundColor = GUIController.DefaultColor; GUI.EndGroup(); }
public override void Start() { currentSubroutine = null; }
public void GetData(Input inputData, _InputMeta inputMeta, VoltVarController PreviousFrame) { #region [ openECA inputData Extraction ] // Extract inputData from openECA //m_inputFrame.ControlTransformers[0].TapV = inputData.TapVTx4; m_inputFrame.ControlTransformers[0].MwV = inputData.MwVTx4; m_inputFrame.ControlTransformers[0].MvrV = inputData.MvrVTx4; m_inputFrame.ControlTransformers[0].VoltsV = inputData.VoltsVTx4; //m_inputFrame.ControlTransformers[1].TapV = inputData.TapVTx5; m_inputFrame.ControlTransformers[1].MwV = inputData.MwVTx5; m_inputFrame.ControlTransformers[1].MvrV = inputData.MvrVTx5; m_inputFrame.ControlTransformers[1].VoltsV = inputData.VoltsVTx5; m_inputFrame.ControlCapacitorBanks[0].BusBkrV = inputData.BusBkrVCap1; //m_inputFrame.ControlCapacitorBanks[0].CapBkrV = inputData.CapBkrVCap1; m_inputFrame.ControlCapacitorBanks[0].LockvV = inputData.LocKvVCap1; m_inputFrame.ControlCapacitorBanks[1].BusBkrV = inputData.BusBkrVCap2; //m_inputFrame.ControlCapacitorBanks[1].CapBkrV = inputData.CapBkrVCap2; m_inputFrame.ControlCapacitorBanks[1].LockvV = inputData.LocKvVCap2; m_inputFrame.SubstationInformation.G1Mw = inputData.G1Mw; m_inputFrame.SubstationInformation.G1Mvr = inputData.G1Mvr; m_inputFrame.SubstationInformation.G2Mw = inputData.G2Mw; m_inputFrame.SubstationInformation.G2Mvr = inputData.G2Mvr; #endregion SubRoutine sub = new SubRoutine(); ReadCurrentControl ReadCurrentCon = new ReadCurrentControl(); VoltVarController Frame = new VoltVarController(); #region [ Measurements Mapping ] m_inputFrame.OnNewMeasurements(); #endregion #region [ Read The Previous Run ] m_inputFrame.ReadPreviousRun(PreviousFrame); #endregion #region [ Verify Program Controls ] ReadCurrentCon.VerifyProgramControl(m_inputFrame.SubstationAlarmDevice.LtcProgram); #endregion #region [ Adjust Control Delay Counters ] //#-----------------------------------------------------------------------# //# adjust the cap bank control delay counter, which is used to ensure: # //# a. we don't do two cap bank control within 30 minutes of each other. # //# b. we don't do a tap control within a minute of a cap bank control. # //#-----------------------------------------------------------------------# if (m_inputFrame.SubstationInformation.Ncdel < m_inputFrame.SubstationInformation.Zcdel) { m_inputFrame.SubstationInformation.Ncdel = m_inputFrame.SubstationInformation.Ncdel + 1; } //#-----------------------------------------------------------------------# //# Adjust the tap control delay counter, which is used to ensure we # //# don't do a cap bank control within a minute of a tap control. # //#-----------------------------------------------------------------------# if (m_inputFrame.SubstationInformation.Ntdel < m_inputFrame.SubstationInformation.Zdel) { m_inputFrame.SubstationInformation.Ntdel = m_inputFrame.SubstationInformation.Ntdel + 1; } #endregion #region [ Read Curren Tx Values and Voltages ] m_inputFrame = ReadCurrentCon.ReadCurrentTransformerValuesAndVoltages(m_inputFrame); #endregion #region [ Check if the Previous Control Reults can Meet Our Expectation ] m_inputFrame = ReadCurrentCon.CheckPreviousControlResults(m_inputFrame); #endregion #region [ Call Sub Taps ] m_inputFrame = sub.Taps(m_inputFrame); #endregion #region [CapBank] m_inputFrame = sub.CapBank(m_inputFrame); #endregion #region [ Save before Exit ] m_logMessage = ReadCurrentCon.MessageInput; m_logMessage += sub.MessageInput; m_inputFrame.LtcStatus.Avv = 0; m_inputFrame.LtcStatus.Nins = 0; m_inputFrame.LtcStatus.MinVar = 99999; m_inputFrame.LtcStatus.MaxVar = -99999; #endregion }