public ObjectModel(double dt) { this.dt = dt; firstVessel = new List <BaseBlock>(); secondVessel = new List <BaseBlock>(); pipe1 = new ComplexBlock(); pipe2 = new ComplexBlock(); pipe3 = new ComplexBlock(); pipe4 = new ComplexBlock(); valveLimit = new LimitBlock(0, 100); firstVessel.Add(new APBlock(dt, 30, 0, 150)); secondVessel.Add(new APBlock(dt, 30, 0, 100)); pipe1.Blocks.Add(new GainBlock(1)); pipe2.Blocks.Add(new GainBlock(1)); pipe3.Blocks.Add(new GainBlock(1)); pipe3.Blocks.Add(new DelayBlock(1, dt)); pipe4.Blocks.Add(new GainBlock(1)); pipe4.Blocks.Add(new DelayBlock(1, dt)); valve1 = 0; valve2 = 0; valve3 = 0; valve4 = 0; Time = 0; firstVesselValue = 0; secondVesselValue = 0; }
public BoilerControl(double dt) : base() { DT = dt; InputStream = 0; var blocks = new Queue <IBlock>(); blocks.Enqueue(new DelayBlock(dt, Settings.Delay)); blocks.Enqueue(new GainBlock(Settings.Gain1)); blocks.Enqueue(new GainBlock(Settings.Gain2)); blocks.Enqueue(new IntegralBlock(dt)); blocks.Enqueue(new InterferenceBlock(Settings.Interference)); Object = new ComplexBlock(blocks); }
public BarrelControlSystem(double dt) : base() { DT = dt; InputStream = 0; InputStreamBlock = new GainBlock(SystemSettings.Gain); m_withoutHitBlock = new AperiodicBlock(dt, SystemSettings.TForValve); var blocks = new Queue <IBlock>(); blocks.Enqueue(new DelayBlock(dt, SystemSettings.Delay)); blocks.Enqueue(new IntegralBlock(dt)); blocks.Enqueue(new InterferenceBlock(SystemSettings.Interference)); Object = new ComplexBlock(blocks); Regulator = new PIDRegulator(dt); }
public TankControlSystem(double dt) : base() { DT = dt; Valve = 0; InputStream = SystemSettings.MaxInputStream; OutputStream = SystemSettings.MaxOutputStream; OutputGain = 0.2; m_withoutHitBlock = new AperiodicBlock(dt, SystemSettings.T); var blocks = new Queue <IBlock>(); blocks.Enqueue(new DelayBlock(dt, SystemSettings.Delay)); blocks.Enqueue(new AperiodicBlock(DT, SystemSettings.T)); blocks.Enqueue(new GainBlock(SystemSettings.T)); blocks.Enqueue(new InterferenceBlock(SystemSettings.Interference)); Object = new ComplexBlock(blocks); Regulator = new PIDRegulator(dt); }
// Use this for initialization void Start() { speeder = gameObject.GetComponent<Rigidbody>(); speeder.velocity = Vector3.down * speed; group = gameObject.GetComponentInParent<ComplexBlock>(); }
public ICodeBlock Translate(ICodeBlock parent = null, int start = 0, int finish = -1) { if (finish == -1) { finish = Code.Count; } ICodeBlock result; if (parent != null) { result = new ComplexBlock(parent); } else { result = new NamespaceBlock(null); } var interpreted = new List <ICodeBlock>(); var startPlainBlock = start; for (var i = start; i < finish; i++) { if (Empty.IsMatch(Code[i]) || Comment.IsMatch(Code[i])) { continue; } var match = Condition.Match(Code[i]); if (match.Success) { CheckForPlain(result, startPlainBlock, i, interpreted); interpreted.Add(TranslateCondition(result, match.Groups["condition"].ToString(), i, out i)); startPlainBlock = i; continue; } match = WhileCycle.Match(Code[i]); if (match.Success) { CheckForPlain(result, startPlainBlock, i, interpreted); interpreted.Add(TranslateWhile(result, match.Groups["condition"].ToString(), i, out i)); startPlainBlock = i + 1; continue; } } CheckForPlain(result, startPlainBlock, finish, interpreted); if (interpreted.Count == 1 && parent != null) { result = interpreted[0]; result.ParentBlock = parent; } else if (result is ComplexBlock complexBlock) { complexBlock.Code = interpreted; } else { ((NamespaceBlock)result).Code = interpreted; } return(result); }
//TODO: make it more adjustable via input manager private void controlBlock(ComplexBlock block) { if (block == null) return; Transform blockTransform = block.gameObject.transform; Vector3 coords = blockTransform.position; Quaternion spin = blockTransform.rotation; //this is the actual block we'll need to maintain if (block.tag != "PlacedBlock") { //x , y axis move if (Input.GetKeyUp(KeyCode.Q)) { Debug.Log("q"); coords = Vector3.MoveTowards(coords , coords + Vector3.right , 1f); block.Moved = true; } if (Input.GetKeyUp(KeyCode.E)) { Debug.Log("e"); coords = Vector3.MoveTowards(coords , coords + Vector3.left , 1f); block.Moved = true; } if (Input.GetAxis("Mouse ScrollWheel") > 0) { coords = Vector3.MoveTowards(coords , coords + Vector3.forward , 1f); block.Moved = true; } if (Input.GetAxis("Mouse ScrollWheel") < 0) { coords = Vector3.MoveTowards(coords , coords + Vector3.back , 1f); block.Moved = true; } //x,y axis spin if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyUp(KeyCode.Q)) { Debug.Log("q shift"); spin = spin * Quaternion.AngleAxis(0.25f,Vector3.up); block.Moved = true; } if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyUp(KeyCode.E)) { Debug.Log("e shift" ); spin = spin * Quaternion.AngleAxis(-0.25f , Vector3.up); block.Moved = true; } if (Input.GetKey(KeyCode.LeftControl) && Input.GetAxis("Mouse ScrollWheel") > 0) { spin = spin * Quaternion.AngleAxis(0.25f , Vector3.left); block.Moved = true; } if (Input.GetKey(KeyCode.LeftControl) && Input.GetAxis("Mouse ScrollWheel") < 0) { spin = spin * Quaternion.AngleAxis(-0.25f , Vector3.left); block.Moved = true; } block.transform.position = coords; block.speeder.velocity = Vector3.down * block.speed; } else chosenBlock = null; }
// Update is called once per frame void FixedUpdate() { chosenBlock = selectBlock(); controlBlock(chosenBlock); updateStates(); ControlBody(); }