private bool belongsToEnum(string state) { state = state.ToLower(); stateEnum outEnum = stateEnum.active; return(Enum.TryParse(state, out outEnum)); }
private void cmdAdd_Click(object sender, EventArgs e) { this.editText(true); this.txtSymbol.Text = ""; this.txtDescription.Text = ""; this.state = stateEnum.add; }
//INITIALIZE THINGS FOR SWAPING FROM BUY TO BUILD STATE public void ResetEverything() { //OWNER ID IS BACK GAME ownerID = 0; //RESET VALUES setValues(); //RESET OWNER & STATE myOwner = ownerEnum.game; myState = stateEnum.Buy; //SET BACK TO ORIGINAL POS transform.position = startPos; //INSTANTIATE CHILD SCRIPT if (myType == typeEnum.leisure) { childTerrain = transform.Find("BV_Mesh_terrain").gameObject; BV_Terrain terrainScript = childTerrain.GetComponent <BV_Terrain>(); //CHANGE CHILD COLOR terrainScript.changeColor(0); if (PhotonNetwork.room != null) { terrainScript.sendRPC(0); } //SWAP COLLIDERS childTerrain.SetActive(true); gameObject.GetComponent <BoxCollider>().enabled = false; } }
// Handle the direct method call private static Task <MethodResponse> SetFanState(MethodRequest methodRequest, object userContext) { if (fanState == stateEnum.failed) { // Acknowledge the direct method call with a 400 error message. string result = "{\"result\":\"Fan failed\"}"; redMessage("Direct method failed: " + result); return(Task.FromResult(new MethodResponse(Encoding.UTF8.GetBytes(result), 400))); } else { try { var data = Encoding.UTF8.GetString(methodRequest.Data); // Remove quotes from data. data = data.Replace("\"", ""); // Parse the payload, and trigger an exception if it's not valid. fanState = (stateEnum)Enum.Parse(typeof(stateEnum), data); greenMessage("Fan set to: " + data); // Acknowledge the direct method call with a 200 success message. string result = "{\"result\":\"Executed direct method: " + methodRequest.Name + "\"}"; return(Task.FromResult(new MethodResponse(Encoding.UTF8.GetBytes(result), 200))); } catch { // Acknowledge the direct method call with a 400 error message. string result = "{\"result\":\"Invalid parameter\"}"; redMessage("Direct method failed: " + result); return(Task.FromResult(new MethodResponse(Encoding.UTF8.GetBytes(result), 400))); } } }
private async Task OnDesiredPropertyChanged(TwinCollection desiredProperties, object userContext) { whiteMessage("Desired Twin Property Changed:"); whiteMessage($"{desiredProperties.ToJson()}"); // Read the desired Twin Properties. if (desiredProperties.Contains("fanstate") & fanState != stateEnum.failed) { string desiredFanState = desiredProperties["fanstate"]; desiredFanState = desiredFanState.ToLower(); if (desiredFanState == "on" || desiredFanState == "off") { fanState = (stateEnum)Enum.Parse(typeof(stateEnum), desiredFanState); greenMessage($"Set the fan to: {desiredFanState}"); } else { redMessage($"Illegal fan state received: {desiredFanState}"); } } if (desiredProperties.Contains("temperature")) { string desiredTemperatureString = desiredProperties["temperature"]; try { desiredTemperature = double.Parse(desiredTemperatureString); greenMessage($"Setting the desired temperature to: {desiredTemperatureString}"); } catch { redMessage($"Illegal temperature received: {desiredTemperatureString}"); } } if (desiredProperties.Contains("humidity")) { string desiredHumidityString = desiredProperties["humidity"]; try { desiredHumidity = double.Parse(desiredHumidityString); greenMessage($"Setting the desired humidity to: {desiredHumidityString}"); } catch { redMessage($"Illegal humidity received: {desiredHumidityString}"); } } // Report Twin properties. var reportedProperties = new TwinCollection(); reportedProperties["fanstate"] = fanState.ToString(); reportedProperties["humidity"] = desiredHumidity; reportedProperties["temperature"] = desiredTemperature; await s_deviceClient.UpdateReportedPropertiesAsync(reportedProperties).ConfigureAwait(false); greenMessage($"Reported Twin Properties: {reportedProperties.ToJson()}"); }
void Hunting() { if (distanceToPlayer < swarmTrigger) { state = stateEnum.Swarming; } destination = vectorToPlayer; }
private void cmdEdit_Click(object sender, EventArgs e) { if (stockListView.SelectedItems.Count > 0) { this.editText(true); this.state = stateEnum.edit; } }
//INITIALIZE THINGS FOR SWAPING FROM BUY TO BUILD STATE public void BuildToRenovate() { //START PARTICLES instantiateParticles(new Vector3(transform.position.x, 0f, transform.position.z)); //CHANGE STATE myState = stateEnum.Renovate; //SWAP COLLIDERS gameObject.GetComponent <BoxCollider>().enabled = true; childTerrain.GetComponent <BoxCollider>().enabled = false; childTerrain.SetActive(false); setValues(); }
public HandledException SetReaderException(HandledException ex) { lock (_stateLock) { if (_readerException == null) { _readerException = ex; } _state = stateEnum.Error; } return(_readerException); }
public async Task <Tool> setToolToStatusById(int toolId, stateEnum newState, Justification justification) { var tool = await _context.Tools .Where(x => x.toolId == toolId) .FirstOrDefaultAsync(); if (tool == null) { return(null); } return(await updateTool(tool, newState, justification)); }
public async Task <Tool> setTootlToStatusByNumber(string toolSerialNumber, stateEnum newState, Justification justification) { var tool = await _context.Tools .Where(x => x.serialNumber == toolSerialNumber) .FirstOrDefaultAsync(); if (tool == null) { return(null); } return(await updateTool(tool, newState, justification)); }
public HandledException SetWriterException(HandledException ex) { lock (_stateLock) { if (_writerException == null) { _writerFirst = _readerException == null; _writerException = ex; } _state = stateEnum.Error; } return(_writerException); }
void callEvent(stateEnum _stateEnum) { if (_stateAndItsEvents.Where(s => s.state == _stateEnum).First() != null) { eventToExecute = _stateAndItsEvents.Where(s => s.state == _stateEnum).First()._event; executionDelay = _stateAndItsEvents.Where(s => s.state == _stateEnum).First().executionDelay; if (executionDelay < 0) { executionDelay = 0; } StartCoroutine("WaitAndExecute"); } }
internal Coordinator(uint validationCrc, IValidation reader, IValidation writer, long processSize) { _processSize = processSize; _crcs = null; _validationCrc = validationCrc; _state = stateEnum.Unset; _stateLock = new object(); _readerVerifyCrc = reader.RequireVerifyCrc; _readerValidationCrc = reader.RequireValidationCrc; _writerVerifyCrc = writer.RequireVerifyCrc; _writerValidationCrc = writer.RequireValidationCrc; _readerException = null; _writerException = null; _writerFirst = false; }
public async Task <IActionResult> UpdateByNumber([FromQuery] string productionordernumber, [FromQuery] string state) { stateEnum newState = stateEnum.created; if (!Enum.TryParse(state, out newState)) { return(BadRequest("State Not Found")); } var productionOrders = await _stateManagementService.setProductionOrderToStatusByNumber(productionordernumber, newState); if (productionOrders == null) { return(BadRequest("State Change not Allowed By Configuration")); } return(Ok(productionOrders)); }
public AgeichenkoTestTask() { InitializeComponent(); stateOfForm = stateEnum.stateNodeAdding; paintBox = pictureBoxGraph.CreateGraphics(); graph = new GraphClass(); sqlHandler = new SqlHandlerClass(); serializer = new SerializeHandlerClass(); notifiers = new List<ToolTip>(); updatePaintingSettings(); currentLanguage = "en"; switchLanguage(currentLanguage); }
public async Task <IActionResult> UpdateByNumber([FromBody] Justification justification, [FromQuery] string serial, [FromQuery] string state) { stateEnum newState = stateEnum.available; if (!Enum.TryParse(state, out newState)) { return(BadRequest("State Not Found")); } var tools = await _stateManagementService.setTootlToStatusByNumber(serial, newState, justification); if (tools == null) { return(BadRequest("State Change not Allowed By Configuration")); } return(Ok(tools)); }
public async Task <Tool> setToolToStatusById(int toolId, stateEnum newState, Justification justification, string username) { var tool = await _context.Tools .Where(x => x.toolId == toolId) .FirstOrDefaultAsync(); tool.username = username; Console.WriteLine("setToolToStatusById - username: "); Console.WriteLine(username); if (tool == null) { return(null); } return(await updateTool(tool, newState, justification, username)); }
//INITIALIZE THINGS FOR SWAPING FROM BUY TO BUILD STATE public void BuyToBuild(int i) { //INSTANTIATE SHADERER SCRIPT BV_BuildingShaderer shaderer = transform.GetComponent <BV_BuildingShaderer> (); shaderer.updateColor(); //INSTANTIATE CHILD SCRIPT BV_Terrain terrainScript = childTerrain.GetComponent <BV_Terrain>(); //CHANGE CHILD COLOR terrainScript.changeColor(i); terrainScript.sendRPC(i); myState = stateEnum.Build; setValues(); switch (i) { case 0: myOwner = ownerEnum.game; break; case 1: myOwner = ownerEnum.playerBlue; ownerID = 1; break; case 2: myOwner = ownerEnum.playerGreen; ownerID = 2; break; case 3: myOwner = ownerEnum.playerOrange; ownerID = 3; break; case 4: myOwner = ownerEnum.playerRed; ownerID = 4; break; case 5: myOwner = ownerEnum.playerYellow; ownerID = 5; break; } }
private void progress(stateEnum testState, stateEnum setState) { stateEnum s; lock (_stateLock) { s = _state; if (s == testState) { #if DEBUG // Console.WriteLine(string.Format("\r\nState a: {1}(Test={2})({0})", Thread.CurrentThread.ManagedThreadId.ToString(), setState.ToString(), testState.ToString())); #endif _state = setState; return; } else if (s > testState) { throw new Exception(string.Format("State is {0} (beyond {1})", s.ToString(), testState.ToString())); } } #if DEBUG // lock (_stateLock) // Console.WriteLine(string.Format("\r\nState b: {1}(Test={2})({0})", Thread.CurrentThread.ManagedThreadId.ToString(), setState.ToString(), testState.ToString())); #endif while (_state != testState) { Thread.Sleep(250); //lazy wait, it's not time critical if (_state == stateEnum.Error) { throw new Exception("Exception reported to ProcessCoordinator - Exceptioning out"); } } lock (_stateLock) { #if DEBUG // Console.WriteLine(string.Format("\r\nState c: {1}(Test={2})({0})", Thread.CurrentThread.ManagedThreadId.ToString(), setState.ToString(), testState.ToString())); #endif _state = setState; } }
private async Task <Tool> updateTool(Tool tool, stateEnum newState, Justification justification, string username) { var curState = _stateConfiguration.states .Where(x => x.state == tool.status.ToString()).FirstOrDefault(); if (curState == null) { return(null); } var newStateObject = _stateConfiguration.states .Where(x => x.state == newState.ToString()).FirstOrDefault(); if (newStateObject.needsJustification) { if (justification == null) { return(null); } else if (String.IsNullOrEmpty(justification.text)) { return(null); } } else { justification = null; } if (curState.possibleNextStates.Contains(newState.ToString())) { tool.status = newState.ToString(); _context.Entry(tool).State = EntityState.Modified; await _context.SaveChangesAsync(); // passa o nome do usuario que fez a modificação na ferramenta tool.username = username; await _stateTransitionHistoryService.addToolHistory(tool.toolId, newStateObject.needsJustification, tool.currentLife, tool, justification, curState.state.ToString(), newState.ToString()); Trigger(tool); return(tool); } return(null); }
// Handle the direct method call private static Task <MethodResponse> SetFanState(MethodRequest methodRequest, object userContext) { if (fanState == stateEnum.failed) { // Acknowledge the direct method call with a 400 error message. string result = "{\"result\":\"Fan failed\"}"; redMessage("Direct method failed: " + result); return(Task.FromResult(new MethodResponse(Encoding.UTF8.GetBytes(result), 400))); } else { try { var data = Encoding.UTF8.GetString(methodRequest.Data); // Remove quotes from data. data = data.Replace("\"", ""); // Parse the payload, and trigger an exception if it's not valid. fanState = (stateEnum)Enum.Parse(typeof(stateEnum), data); greenMessage("Fan set to: " + data); // Acknowledge the direct method call with a 200 success message. string result = "{\"result\":\"Executed direct method: " + methodRequest.Name + "\"}"; return(Task.FromResult(new MethodResponse(Encoding.UTF8.GetBytes(result), 200))); } catch { // Acknowledge the direct method call with a 400 error message. string result = "{\"result\":\"Invalid parameter\"}"; redMessage("Direct method failed: " + result); return(Task.FromResult(new MethodResponse(Encoding.UTF8.GetBytes(result), 400))); } } // Get the device twin to report the initial desired properties. Twin deviceTwin = s_deviceClient.GetTwinAsync().GetAwaiter().GetResult(); greenMessage("Initial twin desired properties: " + deviceTwin.Properties.Desired.ToJson()); // Set the device twin update callback. s_deviceClient.SetDesiredPropertyUpdateCallbackAsync(OnDesiredPropertyChanged, null).Wait(); }
void Attacking() { attackMove -= Time.deltaTime * 2.5f; if (attackSoundPlayed == false) { audioSource.PlayOneShot(attackingClip); attackSoundPlayed = true; } if (distanceToPlayer < 0.6f)//TODO change for if collision { attackTimer = 0; state = stateEnum.Swarming; attackSoundPlayed = false; } FindPointOnCircle(); }
//Unpauses the scene after a minigame public void UnPauseScene() { //Shows the pause button again when scene unpaused and makes the ticket interactable again pauseButton.SetActive(true); ticketObject.GetComponent <CanvasGroup>().alpha = 1; ticketObject.GetComponent <CanvasGroup>().interactable = true; ticketObject.GetComponent <CanvasGroup>().blocksRaycasts = true; isScenePaused = false; sceneCam.gameObject.SetActive(true); state = stateEnum.playing; //Hides the background cover cover.SetActive(false); //makes mess at the recently used station messSpawner.MakeMess(currentStationPos + messOffset, 1); //updates score scoreCurrent += AddScore(); }
//Sets everything necessary back to their starting values void ResetKitchen() { minigamesComplete = 0; ingredientSpawner.SelectDish(); //ingredientSpawner.SelectDish("HandSpongeRat"); //sets up stations for not first time use GetStations(false); //creates a new dish item object and deactivates it for now completeDish = Instantiate <GameObject>(dishObject); completeDish.GetComponent <Item>().Type = MenuScript.IngredientType.dish; completeDish.SetActive(false); //deactivates the cover cover.SetActive(false); //makes sure state is playing again state = stateEnum.playing; isScenePaused = false; //start with ticket active ticketObject.SetActive(true); SetupTicket(); if (FindObjectsOfType(GetType()).Length > 1) { Destroy(gameObject); } //list to hold ingredients ingredientObjects = new List <GameObject>(); foreach (GameObject g in GameObject.FindGameObjectsWithTag("Holdable")) { ingredientObjects.Add(g); } SetIngredientsGlow(true); }
void Swarming() { if (distanceToPlayer > swarmTrigger) { state = stateEnum.Hunting; } if (visibility) { attackTimer += Time.deltaTime; } if (attackTimer > attackCooldown) { //attack player state = stateEnum.Attacking; } if (attackMove < 0) { attackMove += Time.deltaTime * 3.5f; } FindPointOnCircle(); }
public async Task <IActionResult> UpdateById([FromQuery] int productionorderid, [FromQuery] string state, [FromQuery] string username) { Console.WriteLine("username: "******"State Not Found")); } var productionOrders = await _stateManagementService.setProductionOrderToStatusById(productionorderid, newState, username); if (productionOrders == null) { return(BadRequest("State Change not Allowed By Configuration")); } return(Ok(productionOrders)); }
private void Update() { if (SeePlayerAttackable() == true) { state = stateEnum.Attacking; } else if (SeePlayer() == true) { Debug.Log("chasing"); state = stateEnum.Chasing; } else { Debug.Log("I am patrolling"); state = stateEnum.Patrolling; } if (shootingTime >= 0) { shootingTime -= Time.deltaTime; } CheckState(); }
//Pauses the scene while a minigame is playing public void PauseScene() { //Returns if it is already paused if (isScenePaused) { return; } //Hides the pause button during minigame pauseButton.SetActive(false); //Hides the ticket object and stops the player from interacting with it ticketObject.GetComponent <CanvasGroup>().alpha = 0; ticketObject.GetComponent <CanvasGroup>().interactable = false; ticketObject.GetComponent <CanvasGroup>().blocksRaycasts = false; sceneCam.gameObject.SetActive(false); isScenePaused = true; //sets kitchen state to paused state = stateEnum.paused; //activates background cover cover.SetActive(true); }
private void buttonShortWay_Click(object sender, EventArgs e) { stateOfForm = stateEnum.stageShortWayFinding; infoUpdate("InfoTextDefaultS"); }
// Async method to send simulated telemetry. private async Task SendDeviceToCloudMessagesAsync2(DeviceClient deviceClient) { double currentTemperature = ambientTemperature; // Initial setting of temperature. double currentHumidity = ambientHumidity; // Initial setting of humidity. Random rand = new Random(); while (true) { // Simulate telemetry. double deltaTemperature = Math.Sign(desiredTemperature - currentTemperature); double deltaHumidity = Math.Sign(desiredHumidity - currentHumidity); if (fanState == stateEnum.on) { // If the fan is on the temperature and humidity will be nudged towards the desired values most of the time. currentTemperature += (deltaTemperature * rand.NextDouble()) + rand.NextDouble() - 0.5; currentHumidity += (deltaHumidity * rand.NextDouble()) + rand.NextDouble() - 0.5; // Randomly fail the fan. if (rand.NextDouble() < 0.01) { fanState = stateEnum.failed; redMessage("Fan has failed"); } } else { // If the fan is off, or has failed, the temperature and humidity will creep up until they reaches ambient values, // thereafter fluctuate randomly. if (currentTemperature < ambientTemperature - 1) { currentTemperature += rand.NextDouble() / 10; } else { currentTemperature += rand.NextDouble() - 0.5; } if (currentHumidity < ambientHumidity - 1) { currentHumidity += rand.NextDouble() / 10; } else { currentHumidity += rand.NextDouble() - 0.5; } } // Check: humidity can never exceed 100%. currentHumidity = Math.Min(100, currentHumidity); // Create JSON message. var telemetryDataPoint = new { temperature = Math.Round(currentTemperature, 2), humidity = Math.Round(currentHumidity, 2) }; var messageString = JsonConvert.SerializeObject(telemetryDataPoint); var message = new Message(Encoding.ASCII.GetBytes(messageString)); // Add custom application properties to the message. message.Properties.Add("sensorID", "S1"); message.Properties.Add("fanAlert", (fanState == stateEnum.failed) ? "true" : "false"); // Send temperature or humidity alerts, only if they occur. if ((currentTemperature > desiredTemperature + desiredTempLimit) || (currentTemperature < desiredTemperature - desiredTempLimit)) { message.Properties.Add("temperatureAlert", "true"); } if ((currentHumidity > desiredHumidity + desiredHumidityLimit) || (currentHumidity < desiredHumidity - desiredHumidityLimit)) { message.Properties.Add("humidityAlert", "true"); } colorMessage($"Message data: {messageString}", ConsoleColor.White); // Send the telemetry message await deviceClient.SendEventAsync(message); greenMessage("Message sent\n"); await Task.Delay(intervalInMilliseconds); } }
public Reference() { this.sizeField = new sizeType(); this.outlineColorField = new rgbExtendedColorType(); this.colorField = new rgbColorType(); this.statusField = stateEnum.OFF; }
public Map() { this.webField = new ObservableCollection<Web>(); this.symbolField = new ObservableCollection<Symbol>(); this.sizeField = new sizeType(); this.scaleBarField = new ScaleBar(); this.referenceField = new Reference(); this.queryMapField = new QueryMap(); this.outputFormatField = new ObservableCollection<OutputFormat>(); this.legendField = new Legend(); this.layerField = new ObservableCollection<Layer>(); this.includeField = new ObservableCollection<string>(); this.imageColorField = new rgbColorType(); this.configField = new ObservableCollection<itemTypeItem>(); this.angleField = 0D; this.debugField = "OFF"; this.defResolutionField = "72"; this.resolutionField = "72"; this.unitsField = "METERS"; this.statusField = stateEnum.ON; }
public Class() { this.symbolField = new symbolType(); this.styleField = new ObservableCollection<Style>(); this.labelField = new Label(); this.expressionField = new expressionType(); this.colorField = new rgbColorType(); this.backgroundColorField = new rgbColorType(); this.maxSizeField = "50"; this.minSizeField = "0"; this.sizeField = "1"; this.statusField = stateEnum.ON; }
public Layer() { this.validationField = new ObservableCollection<itemTypeItem>(); this.processingField = new ObservableCollection<string>(); this.offsiteField = new rgbColorType(); this.metadataField = new ObservableCollection<itemTypeItem>(); this.joinField = new Join(); this.gridField = new Grid(); this.filterField = new expressionType(); this.featureField = new ObservableCollection<Feature>(); this.clusterField = new Cluster(); this.classField = new ObservableCollection<Class>(); this.debugField = "OFF"; this.dumpField = booleanEnum.FALSE; this.labelCacheField = stateEnum.ON; this.postLabelCacheField = booleanEnum.FALSE; this.sizeUnitsField = "PIXELS"; this.tileItemField = "LOCATION"; this.toleranceUnitsField = "PIXELS"; this.transformField = "TRUE"; this.statusField = "ON"; }
private void buttonDeleteNode_Click(object sender, EventArgs e) { stateOfForm = stateEnum.stateNodeDeleting; infoUpdate("InfoTextDefaultS"); }
public async Task <ProductionOrder> setProductionOrderToStatusByNumber(string productionOrderNumber, stateEnum newState) { var produtionOrder = await _context.ProductionOrders .Where(x => x.productionOrderNumber == productionOrderNumber) .FirstOrDefaultAsync(); if (produtionOrder == null) { return(null); } var productionOrderType = await _context.ProductionOrderTypes .Where(x => x.productionOrderTypeId == produtionOrder.productionOrderTypeId) .Include(x => x.stateConfiguration) .ThenInclude(x => x.states) .FirstOrDefaultAsync(); var curState = productionOrderType.stateConfiguration.states .Where(x => x.state == produtionOrder.currentStatus.ToString()).FirstOrDefault(); if (curState == null) { return(null); } if (curState.possibleNextStates.Contains(newState.ToString())) { string url = productionOrderType.stateConfiguration.states .Where(x => x.state == newState.ToString()).FirstOrDefault().url; produtionOrder.currentStatus = newState.ToString(); _context.Entry(produtionOrder).State = EntityState.Modified; await _context.SaveChangesAsync(); if (!string.IsNullOrEmpty(url)) { postAfterChangedState(url, produtionOrder); } return(produtionOrder); } return(null); }
private void buttonAddEdge_Click(object sender, EventArgs e) { stateOfForm = stateEnum.stateEdgeAdding; infoUpdate("InfoTextDefaultS"); }