// Update is called once per frame void Update() { // if we have only have one object, it cant really trade places with anything.. if (SwitchableObjects.Length <= 1) return; if (state == SwitchState.GettingObjects) { int numberOfObjects = SwitchableObjects.Length; objectToSwitch1 = Random.Range(0, SwitchableObjects.Length); objectToSwitch2 = objectToSwitch1; while (objectToSwitch2 == objectToSwitch1) { objectToSwitch2 = Random.Range(0, SwitchableObjects.Length); } //set vector3 target positions for tw objects objOneTarget = SwitchableObjects[objectToSwitch2].transform.position; objTwoTarget = SwitchableObjects[objectToSwitch1].transform.position; state = SwitchState.Switching; } else if (state == SwitchState.Switching) { setNewPosition(objectToSwitch1, objOneTarget); setNewPosition(objectToSwitch2, objTwoTarget); if (getCuurentPosition(objectToSwitch1) == objOneTarget) { NumberOfSwitching--; if (NumberOfSwitching > 0) { state = SwitchState.CountingDown; lastTimeSinceSwitch = TimeBetweenSwitching; } else { state = SwitchState.Done; playerInput.enabled = true; } } } else if (state == SwitchState.CountingDown) { if (lastTimeSinceSwitch < 0) { lastTimeSinceSwitch = TimeBetweenSwitching; state = SwitchState.GettingObjects; } else { lastTimeSinceSwitch -= Time.deltaTime; } } else { return; } }
// Use this for initialization void Start() { lastTimeSinceSwitch = TimeStartMoving; state = SwitchState.CountingDown; playerInput = GetComponent<PlayerInput>(); playerInput.enabled = false; }
public Switch(int id, string name, SwitchState defaultState) { _id = id; _name = name; _state = defaultState; _lastState = defaultState; _defaultState = defaultState; }
// Update is called once per frame void Update() { // if we have only have one object, it cant really trade places with anything.. if (SwitchableObjects.Length <= 3) return; if (state == SwitchState.GettingObjects) { SwitchableObjects = shuffleArray(SwitchableObjects); //set vector3 target positions for two objects objOneATarget = SwitchableObjects[objectToSwitch1b].transform.position; objOneBTarget = SwitchableObjects[objectToSwitch1a].transform.position; objTwoATarget = SwitchableObjects[objectToSwitch2b].transform.position; objTwoBTarget = SwitchableObjects[objectToSwitch2a].transform.position; state = SwitchState.Switching; } else if (state == SwitchState.Switching) { setNewPosition(objectToSwitch1a, objOneATarget); setNewPosition(objectToSwitch1b, objOneBTarget); setNewPosition(objectToSwitch2a, objTwoATarget); setNewPosition(objectToSwitch2b, objTwoBTarget); if (getCuurentPosition(objectToSwitch1a) == objOneATarget && getCuurentPosition(objectToSwitch2a) == objTwoATarget) { NumberOfSwitching--; if (NumberOfSwitching > 0) { state = SwitchState.CountingDown; lastTimeSinceSwitch = TimeBetweenSwitching; } else { state = SwitchState.Done; playerInput.enabled = true; } } } else if (state == SwitchState.CountingDown) { if (lastTimeSinceSwitch < 0) { lastTimeSinceSwitch = TimeBetweenSwitching; state = SwitchState.GettingObjects; } else { lastTimeSinceSwitch -= Time.deltaTime; } } else { return; } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Player") { if(state == SwitchState.Off) { sr.sprite = switchOn; state = SwitchState.On; door.SendMessage("CheckCondition"); } } }
public Switch(DataRow switchData) : base(switchData) { equipmentType = EquipmentTopoTypes.Switch; NormallyOpen = (bool)switchData["NormallyOpen"]; Term2Name = (string)switchData["Terminal2"]; if (NormallyOpen) { SwitchState = SwitchState.open; } else { SwitchState = SwitchState.closed; } }
public async Task ToggleSwitchAsync(string name, SwitchState state) { var idx = await GetIdByName(name); if (!idx.HasValue) { _logger.LogError($"Device with name {name} not found"); return; } string uri = GetCommandUri($"type=command¶m=switchlight&idx={idx.Value}&switchcmd={state}"); var result = await _httpClient.GetAsync(uri); var content = await result.Content.ReadAsStringAsync(); _logger.LogInformation($"Swith {idx.Value} to state {state} result with {content}"); }
public SwitchState GetPrevSwitchState() { SwitchState note = SwitchState.None; if (negativeSwitch.isSelected && positiveSwitch.isSelected) { note = SwitchState.Both; } else if (!negativeSwitch.isSelected && positiveSwitch.isSelected) { note = SwitchState.Negative; } else if (!negativeSwitch.isSelected && positiveSwitch.isSelected) { note = SwitchState.Positive; } return(note); }
public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { if ((value == null)) { return(null); } SwitchState valueCasted = ((SwitchState)(value)); if ((valueCasted == SwitchState.Open)) { return("open"); } if ((valueCasted == SwitchState.Close)) { return("close"); } throw new ArgumentOutOfRangeException("value"); }
/** * Creates a MZCondition that requires the player to have a particular * {@link MZSymbol}. * * @param e the symbol that the player must have for the MZCondition to be * satisfied */ public MZCondition(MZSymbol e) { if (e.GetValue() == (int)MZSymbol.MZSymbolValue.SwitchOff) { keyLevel = 0; switchState = SwitchState.Off; } else if (e.GetValue() == (int)MZSymbol.MZSymbolValue.SwitchOn) { keyLevel = 0; switchState = SwitchState.On; } else { keyLevel = e.GetValue() + 1; switchState = SwitchState.Either; } }
// Start is called before the first frame update void Start() { //Set reference variables player = selectedFighter.GetComponent <Transform>(); animator = selectedFighter.GetComponent <Animator>(); //Set canMove to true canMove = true; assistMoveExecuted = false; //Secondary move index secMoveIndex = 0; //Teamwork variables partyIndex = 0; selectedFighter = transform.GetChild(partyIndex).GetComponent <PKMNEntity>(); numPartners = transform.childCount - 1; //Set UI Elements if (numPartners >= 2) { abilityIconSets[1].gameObject.SetActive(true); } if (numPartners >= 3) { abilityIconSets[2].gameObject.SetActive(true); } abilityUIMap = new Dictionary <PKMNEntity, AbilityUI>(); for (int i = 0; i < numPartners; i++) { PKMNEntity curFighter = transform.GetChild(i).GetComponent <PKMNEntity>(); SwitchState curSwitchState = curFighter.gameObject.AddComponent <SwitchState>(); abilityUIMap[curFighter] = abilityIconSets[i]; //Abilities abilityIconSets[i].setUp(curFighter); curSwitchState.setUpState(abilityIconSets[i]); curFighter.healthBar = healthBars[i]; //Stat bars curFighter.armorBar = armorBars[i]; statMenu.addFighter(curFighter); } }
private List <Switch> translatePinMask(byte[] newStateMask) { List <Switch> changed = new List <Switch>(); //this creates an array of bits. However, the bits are reversed and the 1st bit is unused per byte. //so bits[0,8,16,32,40...] will always be 0 //and bits[1] is really switch index 6 //and bits[2] is really switch index 5 //and bits[3] is really switch index 4 //and bits[4] is really switch index 3 //and bits[5] is really switch index 2 //and bits[6] is really switch index 1 //and bits[7] is really switch index 0 bool[] bits = newStateMask.SelectMany(getBits).ToArray(); int switchIndex = SWITCHOFFSET; for (int bank = 0; bank < 8; bank++) { for (int slot = 8; slot > 1; slot--) { int bitArrayIndex = (bank * 8) + slot - 1; SwitchState onOff = bits[bitArrayIndex] ? SwitchState.On : SwitchState.Off; _state[switchIndex].State = onOff; if (_state[switchIndex].LastState != onOff) { changed.Add(_state[switchIndex]); } switchIndex++; if (switchIndex >= _state.Length) { break; } } if (switchIndex >= _state.Length) { break; } } return(changed); }
//Controller actions for teamwork: includes changing characters and assist moves void teamwork() { int leftIndex = (partyIndex - 1 + numPartners) % numPartners; int rightIndex = (partyIndex + 1) % numPartners; SwitchState leftState = transform.GetChild(leftIndex).GetComponent <SwitchState>(); SwitchState rightState = transform.GetChild(rightIndex).GetComponent <SwitchState>(); //Switching between teammates if (Input.GetKeyDown("e") && rightState.canSwitch()) //Switch right { int prevPartyIndex = partyIndex; partyIndex = rightIndex; if (prevPartyIndex != partyIndex) { StartCoroutine(rotateCharacters()); } } if (Input.GetKeyDown("q") && leftState.canSwitch()) //Switch left { int prevPartyIndex = partyIndex; partyIndex = leftIndex; if (prevPartyIndex != partyIndex) { StartCoroutine(rotateCharacters()); } } //Assist Moves if (Input.GetKeyDown("c") && assistFighter == null && leftState.canSwitch()) //Use left character move { StartCoroutine(assistMoveExecute(leftIndex, player.position)); } if (Input.GetKeyDown("v") && assistFighter == null && rightState.canSwitch()) //Use right character move { StartCoroutine(assistMoveExecute(rightIndex, player.position)); } }
// Update is called once per frame void Update() { if (switch1 && switch2) { state = SwitchState.Active; } else { state = SwitchState.Inactive; } if (previousState == SwitchState.Inactive && state == SwitchState.Active) { onActivate.Invoke(); } else if (previousState == SwitchState.Active && state == SwitchState.Inactive) { onDeactivate.Invoke(); } }
// Interactable void OnPlayerClicked() { AudioSource.PlayClipAtPoint(buttonPressSound, transform.position); startTime = Time.time; switch (curState) { case SwitchState.ON: curState = SwitchState.OFF; break; case SwitchState.OFF: curState = SwitchState.ON; break; default: Debug.Log("Reached default case of switch statement for elec switch!"); break; } if (curState == SwitchState.ON) { NPC.transform.GetComponentInChildren <InteractionNPC> ().currentDialog = newNPCDialog; if (!electricityEffects.isPlaying) { electricityEffects.Play(); } electricity.active = true; // if (!playerInfo.isGhost) { // playerInfo.isGhost = true; // } } else { electricity.active = false; if (electricityEffects.isPlaying) { electricityEffects.Stop(); } } }
void OnTriggerExit(Collider other) { if (other.tag == "Player") { if (swapped == false) { switchState = SwitchState.OFF; foreach (GameObject obj in activatedObjects) { if (!Stay) { obj.SendMessage("ObjectDeactivate", SendMessageOptions.DontRequireReceiver); } } foreach (GameObject obj in activatedSwitches) { obj.SendMessage("ObjectDeactivate", SendMessageOptions.DontRequireReceiver); } } } }
void MapStoriesToProps(Story story) { SwitchesStory switchesStory = story.Get <SwitchesStory>(); SwitchStory switchStory = switchesStory.GetStory(location); SwitchState state = switchStory.state; if (state == SwitchState.OFF) { gameObject.GetComponent <SpriteRenderer>().sprite = switchOffSprite; } else { gameObject.GetComponent <SpriteRenderer>().sprite = switchOnSprite; } // SwitchStory switchStory = // Dictionary<Enemy, Location> characterLocations= story.Get<EnemyPositionStory>().characterLocations; // Text text = GetComponent<Text>(); // text.text = enemy.ToString() + ":" +characterLocations[enemy].ToString(); }
/// <summary> /// Sets the state of the SwitchController instance. /// </summary> /// <param name="state">State.</param> public void SetState(SwitchState state) { // saving state State = state; // updating view based on state if (On != null) { On.SetActive(state == SwitchState.On); } if (Off != null) { Off.SetActive(state == SwitchState.Off); } if (Transition != null) { Transition.SetActive(state == SwitchState.Transition); } }
public async void SwitchOff(bool isInstant = false) { if (isInstant) { if (State == SwitchState.SwitchingOn) { // switch on fail currentSwitchCompletedCallback?.Invoke(false); currentSwitchCompletedCallback = null; } // switched off State = SwitchState.Off; SwitchValue = t = 0; currentSwitchCompletedCallback?.Invoke(true); currentSwitchCompletedCallback = null; } else { await SwitchOffAsync(); } }
// Disable the SpriteRenderer of the parent GO. void SetActivationState(SwitchState state) { m_state = state; // Make sure there is a SpriteRenderer Component Attached if (GetComponent <SpriteRenderer>() != null) { if (state == SwitchState.Closed) { GetComponent <SpriteRenderer>().enabled = true; } else { GetComponent <SpriteRenderer>().enabled = false; } } else { Debug.LogError("Attempting to call SetActivationState() on " + gameObject.name + " but it does not contain a SpriteRenderer"); } }
protected void Update() { if (State == SwitchState.SwitchingOn) { t += Time.deltaTime / switchTime; if (t >= 1) { // switched on State = SwitchState.On; SwitchValue = t = 1; currentSwitchCompletedCallback?.Invoke(true); currentSwitchCompletedCallback = null; } else { SwitchValue = Easing.GetEasingFunction(easeType)(0, 1, t); } OnValueChanged?.Invoke(SwitchValue); } else if (State == SwitchState.SwitchingOff) { t -= Time.deltaTime / switchTime; if (t <= 0) { // switched off State = SwitchState.Off; SwitchValue = t = 0; currentSwitchCompletedCallback?.Invoke(true); currentSwitchCompletedCallback = null; } else { SwitchValue = Easing.GetEasingFunction(easeType)(0, 1, t); } OnValueChanged?.Invoke(SwitchValue); } }
private void OnStateChange(SwitchState newValue) { if (_state != newValue) { _state = newValue; UpdateState(); if (newValue == SwitchState.OFF) { foreach (SwitchHandler target in targets) { target.OnSwitchOff(); } } else if (newValue == SwitchState.ON) { foreach (SwitchHandler target in targets) { target.OnSwitchTrigger(); } } } }
public override void LoadFSM() { BaseFSM.FSM <StatesID> subFsm = new BaseFSM.FSM <StatesID>("Sub"); subFsm.OnFinish += (x, y) => { System.Console.WriteLine("*** subFSM onFinish()"); }; SetSubFSM(subFsm); StableState stateSubOne = new StableState(StatesID.SUB_ONE) { isStart = true }; stateSubOne.AddAction("DoSubA", (o) => true, (o) => System.Console.WriteLine("sub action a")) .AddExitTransition(subFsm, StatesID.SUB_TWO); SwitchState stateSubTwo = new SwitchState(StatesID.SUB_TWO) { isFinish = true }; subFsm.AddState(stateSubTwo); }
public void SetState(SwitchState state) { switchState = state; if (state == SwitchState.Up) { MeshRenderer r = coloredGameObject.GetComponent <MeshRenderer>(); Material rmat = r.sharedMaterial; rmat.SetColor(Shader.PropertyToID("_EmissiveColor"), Color.cyan); } else if (state == SwitchState.Down) { MeshRenderer r = coloredGameObject.GetComponent <MeshRenderer>(); Material rmat = r.sharedMaterial; rmat.SetColor(Shader.PropertyToID("_EmissiveColor"), Color.black); } if (!string.IsNullOrEmpty(outputSignal)) { KerbalVR.Events.AvionicsInt(outputSignal).Send((int)state); } }
void OnTriggerExit(Collider other) { if (other.tag == "Player" || other.tag == "Cube" || other.tag == "Clone") { objectCount--; if (swapped == false && objectCount == 0) { switchState = SwitchState.OFF; foreach (GameObject obj in activatedObjects) { obj.SendMessage("ObjectDeactivate", SendMessageOptions.DontRequireReceiver); } } } /*if (other.tag == "Cube") { * switchState = SwitchState.OFF; * foreach (GameObject obj in activatedObjects) { * obj.SendMessage("ObjectDeactivate", SendMessageOptions.DontRequireReceiver); * } * }*/ }
public void OnDrag(PointerEventData data) { float y = data.delta.y; float RotaionX = GoHandle.transform.localRotation.eulerAngles.z; if (RotaionX + y >= 355) { return; } if (RotaionX + y <= 336) { return; } Quaternion newRotation = new Quaternion(GoHandle.transform.rotation.x, GoHandle.transform.rotation.y, GoHandle.transform.rotation.z, GoHandle.transform.rotation.w); newRotation *= Quaternion.Euler(0, 0, y); GoHandle.transform.rotation = newRotation; float finalX = GoHandle.transform.localEulerAngles.z; if (finalX <= 343 && finalX >= 317) { //Debug.Log("Swich Close"); if (m_bSwitchState == SwitchState.SwitchOpen) { m_bSwitchState = SwitchState.SwitchClose; SwitchCallBack?.Invoke(m_bSwitchState); } } else { //Debug.Log("Swich open"); if (m_bSwitchState == SwitchState.SwitchClose) { m_bSwitchState = SwitchState.SwitchOpen; SwitchCallBack?.Invoke(m_bSwitchState); } } }
/// <summary> /// Set the ColumnSpan AttachedProperty to all columns of the parent Grid. /// </summary> /// <param name="switchState"></param> protected void SetFullColumnSpan(SwitchState switchState) { // If the parent DependencyObject is a Grid, perform the ColumnSpan if (this.ParentElement is Grid) { Grid grid = this.ParentElement as Grid; // If there is more than one column ... if (grid.ColumnDefinitions.Count > 0) { if (switchState == SwitchState.On) { // ... and FullColumnSpan is turned ON -> set the ColumnSpanProperty to all subsequent columns Grid.SetColumnSpan(this, grid.ColumnDefinitions.Count - Grid.GetColumn(this)); } else { // ... otherwise clear the ColumnSpanProperty this.ClearValue(Grid.ColumnSpanProperty); } } } }
public async void SwitchOn(bool isInstant = false) { if (isInstant) { if (State == SwitchState.SwitchingOff) { // switch off fail currentSwitchCompletedCallback?.Invoke(false); currentSwitchCompletedCallback = null; } // switched on State = SwitchState.On; SwitchValue = t = 1; currentSwitchCompletedCallback?.Invoke(true); currentSwitchCompletedCallback = null; } else { await SwitchOnAsync(); } }
protected override IEnemyState InitializeStates() { var idle = new IdleState(this); var claimForward = new ClaimForwardState(this, claimerPrefab); var moveForward = new MoveForwardState(this, stepTime); var forwardCounter = new CounterState(this, forwardSteps); var switchState = new SwitchState(this); var claimRight = new ClaimRightState(this, claimerPrefab); var moveRight = new MoveRightState(this, stepTime); var rightCounter = new CounterState(this, rightSteps); var claimLeft = new ClaimLeftState(this, claimerPrefab); var moveLeft = new MoveLeftState(this, stepTime); var leftCounter = new CounterState(this, leftSteps); idle.AddTransition(() => { return(true); }, claimForward); claimForward.AddTransition(() => { return(claimForward.IsDone()); }, moveForward); moveForward.AddTransition(() => { return(moveForward.IsDone()); }, forwardCounter); forwardCounter.AddTransition(() => { return(forwardCounter.IsAmountReached()); }, switchState); forwardCounter.AddTransition(() => { return(forwardCounter.IsAmountReached() == false); }, claimForward); switchState.AddTransition(() => { return(switchState.Value == true); }, claimRight); switchState.AddTransition(() => { return(switchState.Value == false); }, claimLeft); claimRight.AddTransition(() => { return(claimRight.IsDone()); }, moveRight); moveRight.AddTransition(() => { return(moveRight.IsDone()); }, rightCounter); rightCounter.AddTransition(() => { return(rightCounter.IsAmountReached()); }, idle); rightCounter.AddTransition(() => { return(rightCounter.IsAmountReached() == false); }, claimRight); claimLeft.AddTransition(() => { return(claimLeft.IsDone()); }, moveLeft); moveLeft.AddTransition(() => { return(moveLeft.IsDone()); }, leftCounter); leftCounter.AddTransition(() => { return(leftCounter.IsAmountReached()); }, idle); leftCounter.AddTransition(() => { return(leftCounter.IsAmountReached() == false); }, claimLeft); return(idle); }
/** * Gets the single {@link MZSymbol} needed to make this MZCondition and another * MZCondition identical. * <p> * If {@link #and}ed to both MZConditions, the MZConditions would then imply * each other. * * @param other the other MZCondition * @return the MZSymbol needed to make the MZConditions identical, or null if * there is no single MZSymbol that would make them identical or if * they are already identical. */ public MZSymbol SingleSymbolDifference(MZCondition other) { // If the difference between this and other can be made up by obtaining // a single new symbol, this returns the symbol. If multiple or no // symbols are required, returns null. if (this.Equals(other)) { return(null); } if (switchState == other.switchState) { return(new MZSymbol(Math.Max(keyLevel, other.keyLevel) - 1)); } else { if (keyLevel != other.keyLevel) { return(null); } // Multiple symbols needed ^^^ if (switchState != SwitchState.Either && other.switchState != SwitchState.Either) { return(null); } SwitchState nonEither = switchState != SwitchState.Either ? switchState : other.switchState; return(new MZSymbol(nonEither == SwitchState.On ? (int)MZSymbol.MZSymbolValue.SwitchOn : (int)MZSymbol.MZSymbolValue.SwitchOff)); } }
public async Task <int> OnExecuteAsync(IConsole console) { var address = IPAddress.Parse(TargetDevice); if (ShowJson) { var plug = new Plug(address); await plug.FetchAsync().ConfigureAwait(false); console.WriteLine(_jsonService.Serialize(plug)); } else { SwitchState desiredState = SwitchState.Off; bool shouldToggleState = false; if (string.Equals(DesiredState, "toggle", StringComparison.InvariantCultureIgnoreCase)) { shouldToggleState = true; } var plug = new Plug(address); if (shouldToggleState) { await plug.FetchAsync().ConfigureAwait(false); desiredState = plug.RelayState == SwitchState.Off ? SwitchState.On : SwitchState.Off; } else if (!Enum.TryParse(DesiredState, true, out desiredState)) { throw new Exception("Invalid value for parameter \"state\"."); } await plug.SetRelayStateAsync(desiredState).ConfigureAwait(false); } return(0); }
void OnTriggerEnter(Collider other) { if (other.tag == "Player") { foreach (GameObject obj in activatedSwitches) { obj.SendMessage("ObjectActivate", SendMessageOptions.DontRequireReceiver); } switchState = SwitchState.ON; } if (other.tag == "Clone") { foreach (GameObject obj in activatedSwitches) { obj.SendMessage("ObjectActivate", SendMessageOptions.DontRequireReceiver); } switchState = SwitchState.ON; } foreach (GameObject obj in activatedSwitches) { SwitchState s1State = switchState; SwitchState s2State = obj.GetComponent <DualSwitches> ().switchState; ActivateState a1State = activateState; ActivateState a2State = obj.GetComponent <DualSwitches> ().activateState; if (s1State == SwitchState.ON && s2State == SwitchState.ON && a1State == ActivateState.ON && a2State == ActivateState.ON) { foreach (GameObject obj2 in activatedObjects) { obj2.SendMessage("ObjectActivate", SendMessageOptions.DontRequireReceiver); } } } }
private void PlayToState(SwitchState state) { // set the animation time that we want to play to targetAnimationEndTime = GetNormalizedTimeForState(state); // note that the normalizedTime always resets to zero after finishing the clip. // so if switch was at Up and it was already done playing, its normalizedTime is // 0f, even though the Up state corresponds to a time of 1f. so, for this special // case, force set it to 1f. if (switchState == SwitchState.Up && switchAnimationState.normalizedTime == 0f && !switchAnimation.isPlaying) { switchAnimationState.normalizedTime = 1f; } // move either up or down depending on where the switch is right now switchAnimationState.speed = Mathf.Sign(targetAnimationEndTime - switchAnimationState.normalizedTime) * 1f; // play animation and actuate switch switchAnimation.Play(animationName); SetState(state); }
#pragma warning disable RCS1213 // Remove unused member declaration. private static async Task Main2() #pragma warning restore RCS1213 // Remove unused member declaration. { using (var client = new SmartHomeClient()) { client.Start(); await Task.Delay(1000).ConfigureAwait(false); Console.WriteLine("Client initialized."); while (true) { Console.Write("Command: "); string command = Console.ReadLine(); if (command?.ToLower() == "exit") { return; } foreach (Device device in client.GetDevices()) { if (device is LightBulb lb) { SwitchState state = string.Equals(command, "x", StringComparison.CurrentCultureIgnoreCase) ? SwitchState.On : SwitchState.Off; await lb.TransitionStateAsync(state).ConfigureAwait(false); LightBulbState state2 = lb.State; Console.WriteLine($"{lb.Alias} ({lb.DeviceId}): {state2.PowerState}"); } } } } }
public ZWaveOperationResult SetSwitchState(ZWaveValueIdentity identity, SwitchState state) { var node = _nodeList.AllNodes.SingleOrDefault(x => x.NodeIdentity.Equals(identity.NodeIdentity)); if (node == null) { var message = string.Format("Could not locate a node with HomeId {0} and NodeId {1}", identity.HomeId, identity.NodeId); return(ZWaveOperationResult.Fail(message)); } var value = node.Values.SingleOrDefault(x => x.GetId().Equals(identity.ValueId)); if (value == null) { var message = string.Format("Could not locate a value for {0}", identity); return(ZWaveOperationResult.Fail(message)); } var switchValueBool = state == SwitchState.On; _manager.SetValue(value, switchValueBool); return(ZWaveOperationResult.Success); }
public void SetSwitchState(SwitchState state, bool animated = true, Action <Switch> completion = null) { if (Enabled && internalSwitchState != state) { internalSwitchState = state; if (animated) { animateToState(state, (Switch s) => { s.SendActionForControlEvents(UIControlEvent.ValueChanged); if (completion != null) { completion(s); } if (s.Delegate != null) { s.Delegate.SwitchStateChanged(this, this.internalSwitchState); } }); } else { Button.SetX(state == SwitchState.On ? onPosition : offPosition); styleForState(state); SendActionForControlEvents(UIControlEvent.ValueChanged); if (completion != null) { completion(this); } if (Delegate != null) { Delegate.SwitchStateChanged(this, this.internalSwitchState); } } } }
internal Label[] Switch(int labelCount) { SwitchState state = new SwitchState(this.DefineLabel(), this.DefineLabel()); Label[] labels = new Label[labelCount]; for (int i = 0; i < labels.Length; i++) { labels[i] = this.DefineLabel(); } if (this.codeGenTrace != CodeGenTrace.None) { this.EmitSourceInstruction("switch ("); foreach (Label label in labels) { this.EmitSourceInstruction(" " + label.GetHashCode()); } this.EmitSourceInstruction(") {"); } this.ilGen.Emit(OpCodes.Switch, labels); this.Br(state.DefaultLabel); this.blockStack.Push(state); return labels; }
internal Label[] Switch(int labelCount) { SwitchState switchState = new SwitchState(DefineLabel(), DefineLabel()); Label[] caseLabels = new Label[labelCount]; for (int i = 0; i < caseLabels.Length; i++) caseLabels[i] = DefineLabel(); _ilGen.Emit(OpCodes.Switch, caseLabels); Br(switchState.DefaultLabel); _blockStack.Push(switchState); return caseLabels; }
/// <summary> /// Switch /// </summary> /// <param name="labelCount"></param> /// <returns></returns> public Label[] Switch(int labelCount) { SwitchState state = new SwitchState(this.DefineLabel(), this.DefineLabel()); Label[] labels = new Label[labelCount]; for (int i = 0; i < labels.Length; i++) { labels[i] = this.DefineLabel(); } this.ilGen.Emit(OpCodes.Switch, labels); this.Br(state.DefaultLabel); this.blockStack.Push(state); return labels; }
public virtual void On() { switchState = SwitchState.On; }
public virtual void Off() { switchState = SwitchState.Off; }
void getKeyIndex(Keys key, SwitchState value) { switch (key) { case Keys.D5: //Coin1 _state[0].State = value; break; case Keys.D6://Coin2 _state[1].State = value; break; case Keys.D1://Start1 _state[2].State = value; break; case Keys.D2://Start2 _state[3].State = value; break; case Keys.Right://Right _state[4].State = value; break; case Keys.Left://Left _state[5].State = value; break; case Keys.Up://Up _state[6].State = value; break; case Keys.Down://Down _state[7].State = value; break; case Keys.Control://LeftControl _state[8].State = value; break; case Keys.Alt://1SW2 _state[9].State = value; break; case Keys.Space://Space _state[10].State = value; break; case Keys.ShiftKey://LeftShift _state[11].State = value; break; case Keys.Z://1SW5 _state[12].State = value; break; case Keys.X://1SW6 _state[13].State = value; break; case Keys.C://1SW7 _state[14].State = value; break; case Keys.V://1SW8 _state[15].State = value; break; case Keys.P://1A _state[16].State = value; break; case Keys.Enter://1B _state[17].State = value; break; case Keys.G://2Right _state[18].State = value; break; case Keys.D://2Left _state[19].State = value; break; case Keys.R://2Up _state[20].State = value; break; case Keys.F://2Down _state[21].State = value; break; case Keys.A://2SW1 _state[22].State = value; break; case Keys.S://2SW2 _state[23].State = value; break; case Keys.Q://2SW3 _state[24].State = value; break; case Keys.W://2SW4 _state[25].State = value; break; case Keys.I://2SW5 _state[26].State = value; break; case Keys.K://2SW6 _state[27].State = value; break; case Keys.L://2SW8 _state[28].State = value; break; case Keys.Tab://2B _state[29].State = value; break; case Keys.Escape://2B _state[30].State = value; break; case Keys.Add: case Keys.Apps: case Keys.Attn: case Keys.B: case Keys.Back: case Keys.BrowserBack: case Keys.BrowserFavorites: case Keys.BrowserForward: case Keys.BrowserHome: case Keys.BrowserRefresh: case Keys.BrowserSearch: case Keys.BrowserStop: case Keys.Cancel: case Keys.Capital: //case Keys.CapsLock: case Keys.Clear: case Keys.ControlKey: case Keys.Crsel: case Keys.D0: case Keys.D3: case Keys.D4: case Keys.D7: case Keys.D8: case Keys.D9: case Keys.Decimal: case Keys.Delete: case Keys.Divide: case Keys.E: case Keys.End: case Keys.EraseEof: case Keys.Execute: case Keys.Exsel: case Keys.F1: case Keys.F10: case Keys.F11: case Keys.F12: case Keys.F13: case Keys.F14: case Keys.F15: case Keys.F16: case Keys.F17: case Keys.F18: case Keys.F19: case Keys.F2: case Keys.F20: case Keys.F21: case Keys.F22: case Keys.F23: case Keys.F24: case Keys.F3: case Keys.F4: case Keys.F5: case Keys.F6: case Keys.F7: case Keys.F8: case Keys.F9: case Keys.FinalMode: case Keys.H: case Keys.HanguelMode: //case Keys.HangulMode: case Keys.HanjaMode: case Keys.Help: case Keys.Home: break; case Keys.IMEAccept: //case Keys.IMEAceept: case Keys.IMEConvert: case Keys.IMEModeChange: case Keys.IMENonconvert: case Keys.Insert: case Keys.J: case Keys.JunjaMode: break; //case Keys.KanaMode: //case Keys.KanjiMode: case Keys.KeyCode: break; case Keys.LButton: case Keys.LControlKey: case Keys.LMenu: case Keys.LShiftKey: case Keys.LWin: case Keys.LaunchApplication1: case Keys.LaunchApplication2: case Keys.LaunchMail: break; case Keys.LineFeed: case Keys.M: case Keys.MButton: case Keys.MediaNextTrack: case Keys.MediaPlayPause: case Keys.MediaPreviousTrack: case Keys.MediaStop: case Keys.Menu: case Keys.Modifiers: case Keys.Multiply: case Keys.N: case Keys.Next: case Keys.NoName: case Keys.None: case Keys.NumLock: case Keys.NumPad0: case Keys.NumPad1: case Keys.NumPad3: case Keys.NumPad4: case Keys.NumPad5: case Keys.NumPad6: case Keys.NumPad7: case Keys.NumPad8: case Keys.NumPad9: case Keys.O: case Keys.Oem1: case Keys.Oem102: case Keys.Oem2: case Keys.Oem3: case Keys.Oem4: case Keys.Oem5: case Keys.Oem6: case Keys.Oem7: case Keys.Oem8: //case Keys.OemBackslash: case Keys.OemClear: //case Keys.OemCloseBrackets: case Keys.OemMinus: //case Keys.OemOpenBrackets: case Keys.OemPeriod: //case Keys.OemPipe: //case Keys.OemQuestion: //case Keys.OemQuotes: //case Keys.OemSemicolon: case Keys.Oemcomma: case Keys.Oemplus: //case Keys.Oemtilde: break; case Keys.Pa1: case Keys.Packet: //case Keys.PageDown: case Keys.PageUp: case Keys.Pause: case Keys.Play: case Keys.Print: case Keys.PrintScreen: //case Keys.Prior: case Keys.ProcessKey: break; case Keys.RButton: case Keys.RControlKey: case Keys.RMenu: case Keys.RShiftKey: case Keys.RWin: //case Keys.Return: case Keys.Scroll: case Keys.Select: case Keys.SelectMedia: case Keys.Separator: case Keys.Shift: case Keys.Sleep: //case Keys.Snapshot: case Keys.Subtract: case Keys.T: break; case Keys.U: break; case Keys.VolumeDown: case Keys.VolumeMute: case Keys.VolumeUp: break; case Keys.XButton1: case Keys.XButton2: case Keys.Y: break; case Keys.Zoom: default: break; } }
/// <summary> /// Manually overrides the state of the lock. This can be used to force lock or /// force unlock the opener. This will cause this opener to ignore the state of /// the lock (if specified) and only read the specified lock state. /// </summary> public void OverrideLock(SwitchState overridedState) { lock (this) { this._overridedLockState = overridedState; this._lockOverride = true; } }
internal Label[] Switch(int labelCount) { SwitchState switchState = new SwitchState(DefineLabel(), DefineLabel()); Label[] caseLabels = new Label[labelCount]; for (int i = 0; i < caseLabels.Length; i++) caseLabels[i] = DefineLabel(); if (codeGenTrace != CodeGenTrace.None) { EmitSourceInstruction("switch ("); foreach (Label l in caseLabels) EmitSourceInstruction(" " + l.GetHashCode()); EmitSourceInstruction(") {"); } ilGen.Emit(OpCodes.Switch, caseLabels); Br(switchState.DefaultLabel); blockStack.Push(switchState); return caseLabels; }
/// <summary> /// Determines whether the state of this instance is the specified state. /// </summary> /// <returns> /// <c>true</c> if this instance is state the specified state; otherwise, <c>false</c>. /// </returns> /// <param name="state"> /// The state to compare to. /// </param> public Boolean IsState(SwitchState state) { return (this.State == state); }
public void SetSwitchState(uint switchId, SwitchState switchState) { uint lParam = (switchState == SwitchState.Pressed) ? SWITCH_PRESSED : SWITCH_RELEASED; if (_wmSensorySwitchInput != 0) SendNotifyMessage(HWND_BROADCAST, _wmSensorySwitchInput, switchId, lParam); }
/// <summary> /// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Components.Switches.SwitchStateChangeEventArgs"/> /// class with the old and new states. /// </summary> /// <param name="oldState"> /// The previous state of the switch. /// </param> /// <param name="newState"> /// The new state of the switch. /// </param> public SwitchStateChangeEventArgs(SwitchState oldState, SwitchState newState) : base() { this._oldState = oldState; this._newState = newState; }