/********************************************************************************************** * discription: 构造函数 * * ***********************************************************************************************/ public TraceSetup() { xmlDb = AwDbFactory.CreateDBEngine(); motorInfo = new MotorInfo(); traceMethodList = new List <S_TraceMethod>(); lastActiveMethod = new S_TraceMethod(); platformPoint = new Coordinate(); maxPosition = new MaxMinCoordinate(); zZeroPoint = new Coordinate(); xmlDb.GetMotorInfo(ref motorInfo); xmlDb.GetActiveTraceMethod(ref lastActiveMethod); xmlDb.GetPlatformPoint(ref platformPoint); xmlDb.GetMaxPosition(ref maxPosition); xmlDb.GetZZeroPoint(ref zZeroPoint); isUpdated = false; }
// Methode, um alle Informationen aus der Cloud zu Synchronisieren mit der GUI und Daten in das GUI Fenster zu schreiben public void ReplaceMotorInfo(MotorInfo info, bool change) { SelectedMotorInfo.IsMotor = info.IsMotor; SelectedMotorInfo.IsPortalAxes = info.IsPortalAxes; SelectedMotorInfo.Parameter = info.Parameter; SelectedMotorInfo.MotorName = info.MotorName; SelectedMotorInfo.VisibleWindows = info.VisibleWindows; SelectedMotorInfo.MessageItems = info.MessageItems; LowInfoField.SetActive(true); if (change) { // Motor selektiert if (SelectedMotorInfo.IsMotor) { MotorInfoText.GetComponent <UnityEngine.UI.Text>().text = SelectedMotorInfo.MotorName + "\n" + SelectedMotorInfo.Parameter; MotorWindow.SetActive(true); foreach (Transform t in MotorWindow.transform.GetComponentInChildren <Transform>()) { if (t.parent == MotorWindow.transform) { int idx = t.GetSiblingIndex(); if (idx == 0) // Acceleration { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].GetInfoType() == "Acceleration") { if (SelectedMotorInfo.VisibleWindows[x].GetIsVisible()) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Acceleration"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Acceleration"; } break; } } } else if (idx == 1) // Velocity { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].GetInfoType() == "Velocity") { if (SelectedMotorInfo.VisibleWindows[x].GetIsVisible()) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Velocity"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Velocity"; } break; } } } else if (idx == 2) // Power { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].GetInfoType() == "Power") { if (SelectedMotorInfo.VisibleWindows[x].GetIsVisible()) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Power"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Power"; } break; } } } } } PortalWindow.SetActive(false); } // Linearachse selektiert else if (SelectedMotorInfo.IsPortalAxes) { MotorInfoText.GetComponent <UnityEngine.UI.Text>().text = SelectedMotorInfo.MotorName + "\n" + SelectedMotorInfo.Parameter; PortalWindow.SetActive(true); //Die Buttons richtig mit Hide/ Show beschriften foreach (Transform t in PortalWindow.transform.GetComponentInChildren <Transform>()) { if (t.parent == PortalWindow.transform) { int idx = t.GetSiblingIndex(); if (idx == 0) // Position { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].InfoType == "Position") { if (SelectedMotorInfo.VisibleWindows[x].IsVisible) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Position"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Position"; } break; } } } else if (idx == 1) // Speed { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].InfoType == "Speed") { if (SelectedMotorInfo.VisibleWindows[x].IsVisible) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Speed"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Speed"; } break; } } } else if (idx == 2) // Force { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].InfoType == "Force") { if (SelectedMotorInfo.VisibleWindows[x].IsVisible) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Force"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Force"; } break; } } } else if (idx == 3) // Current { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].InfoType == "Current") { if (SelectedMotorInfo.VisibleWindows[x].IsVisible) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Current"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Current"; } break; } } } else if (idx == 4) // Power { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].InfoType == "Power") { if (SelectedMotorInfo.VisibleWindows[x].IsVisible) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Power"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Power"; } break; } } } } } MotorWindow.SetActive(false); } int counter = 0; foreach (Transform item in ChatWindowContent.transform.GetComponentInChildren <Transform>()) { if (item.gameObject.name.Contains("Message")) { Destroy(item.gameObject); } } // Message Items anzeigen foreach (MessageItem item in SelectedMotorInfo.MessageItems) { counter++; GameObject go = GameObject.Instantiate(MessageItemTemplateObject, ChatWindowContent.transform); go.transform.Find("Text").GetComponent <UnityEngine.UI.Text>().text = item.MessageText; go.transform.Find("SignatureText").GetComponent <UnityEngine.UI.Text>().text = item.SignatureText; } // GUI_Debug("Found " + counter + " Items"); } else { // Neuer Motor angeklickt } }
// Methode, um alle Informationen aus der Cloud zu Synchronisieren mit der GUI und Daten in das GUI Fenster zu schreiben public void ReplaceMotorInfo(MotorInfo info) { SelectedMotorInfo.IsMotor = info.IsMotor; SelectedMotorInfo.IsPortalAxes = info.IsPortalAxes; SelectedMotorInfo.Parameter = info.Parameter; SelectedMotorInfo.MotorName = info.MotorName; SelectedMotorInfo.VisibleWindows = info.VisibleWindows; LowInfoField.SetActive(true); // Motor selektiert if (SelectedMotorInfo.IsMotor) { MotorInfoText.GetComponent <UnityEngine.UI.Text>().text = SelectedMotorInfo.MotorName + "\n" + SelectedMotorInfo.Parameter; MotorWindow.SetActive(true); foreach (Transform t in MotorWindow.transform.GetComponentInChildren <Transform>()) { if (t.parent == MotorWindow.transform) { int idx = t.GetSiblingIndex(); if (idx == 0) // Acceleration { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].GetInfoType() == "Acceleration") { if (SelectedMotorInfo.VisibleWindows[x].GetIsVisible()) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Acceleration"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Acceleration"; } break; } } } else if (idx == 1) // Velocity { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].GetInfoType() == "Velocity") { if (SelectedMotorInfo.VisibleWindows[x].GetIsVisible()) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Velocity"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Velocity"; } break; } } } else if (idx == 2) // Power { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].GetInfoType() == "Power") { if (SelectedMotorInfo.VisibleWindows[x].GetIsVisible()) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Power"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Power"; } break; } } } } } PortalWindow.SetActive(false); } // Linearachse selektiert else if (SelectedMotorInfo.IsPortalAxes) { MotorInfoText.GetComponent <UnityEngine.UI.Text>().text = SelectedMotorInfo.MotorName + "\n" + SelectedMotorInfo.Parameter; PortalWindow.SetActive(true); //Die Buttons richtig mit Hide/ Show beschriften foreach (Transform t in PortalWindow.transform.GetComponentInChildren <Transform>()) { if (t.parent == PortalWindow.transform) { int idx = t.GetSiblingIndex(); if (idx == 0) // Position { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].InfoType == "Position") { if (SelectedMotorInfo.VisibleWindows[x].IsVisible) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Position"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Position"; } break; } } } else if (idx == 1) // Speed { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].InfoType == "Speed") { if (SelectedMotorInfo.VisibleWindows[x].IsVisible) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Speed"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Speed"; } break; } } } else if (idx == 2) // Force { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].InfoType == "Force") { if (SelectedMotorInfo.VisibleWindows[x].IsVisible) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Force"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Force"; } break; } } } else if (idx == 3) // Current { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].InfoType == "Current") { if (SelectedMotorInfo.VisibleWindows[x].IsVisible) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Current"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Current"; } break; } } } else if (idx == 4) // Power { for (int x = 0; x < SelectedMotorInfo.VisibleWindows.Count; x++) { if (SelectedMotorInfo.VisibleWindows[x].InfoType == "Power") { if (SelectedMotorInfo.VisibleWindows[x].IsVisible) { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Hide Power"; } else { t.GetComponentInChildren <UnityEngine.UI.Text>().text = "Show Power"; } break; } } } } } MotorWindow.SetActive(false); } }
private void ParameterUpdate(MessageUpdater.UpdateTypes type, char address, object data) { switch (type) { case MessageUpdater.UpdateTypes.DeviceInfo: { DeviceID info = data as DeviceID; if ((info != null) && _deviceViewModels.ContainsKey(address)) { _dispatcher.BeginInvoke(() => _deviceViewModels[address].Description = info.Description()); } } break; case MessageUpdater.UpdateTypes.MotorInfo: { MotorInfo info = data as MotorInfo; if ((info != null) && _deviceViewModels.ContainsKey(address)) { ELLMotorViewModel first = _deviceViewModels[address].Motors.FirstOrDefault(motor => motor.MotorID == info.MotorID); if (first != null) { _dispatcher.BeginInvoke(() => first.UpdateInfo(info)); } } } break; case MessageUpdater.UpdateTypes.Status: { DeviceStatus status = data as DeviceStatus; if (status != null) { switch (status.Status) { case DeviceStatus.DeviceStatusValues.OK: break; case DeviceStatus.DeviceStatusValues.Busy: break; default: MessageBox.Show(string.Format("Device error: {0}", status.Status.GetStringValue()), "Device Error", MessageBoxButton.OK, MessageBoxImage.Error); break; } } } break; case MessageUpdater.UpdateTypes.Position: { try { decimal position = (decimal)data; if (_deviceViewModels.ContainsKey(address)) { _dispatcher.BeginInvoke(() => _deviceViewModels[address].UpdatePosition(position)); } } catch (Exception e) { MessageBox.Show(string.Format("Device error: status {0}", e.Message), "Device Error", MessageBoxButton.OK, MessageBoxImage.Error); } } break; case MessageUpdater.UpdateTypes.PolarizerPositions: { try { ELLPaddlePolariser.PolarizerPaddlePositions positions = (ELLPaddlePolariser.PolarizerPaddlePositions)data; if (_deviceViewModels.ContainsKey(address)) { ELLPaddlePolariserViewModel paddleViewModel = _deviceViewModels[address] as ELLPaddlePolariserViewModel; if (paddleViewModel != null) { _dispatcher.BeginInvoke(() => paddleViewModel.UpdatePaddlePosition(positions)); } } } catch (Exception e) { MessageBox.Show(string.Format("Device error: status {0}", e.Message), "Device Error", MessageBoxButton.OK, MessageBoxImage.Error); } } break; case MessageUpdater.UpdateTypes.PaddlePosition: { try { ELLPaddlePolariser.PaddlePosition position = (ELLPaddlePolariser.PaddlePosition)data; if (_deviceViewModels.ContainsKey(address)) { ELLPaddlePolariserViewModel paddleViewModel = _deviceViewModels[address] as ELLPaddlePolariserViewModel; if (paddleViewModel != null) { _dispatcher.BeginInvoke(() => paddleViewModel.UpdatePaddlePosition(position)); } } } catch (Exception e) { MessageBox.Show(string.Format("Device error: status {0}", e.Message), "Device Error", MessageBoxButton.OK, MessageBoxImage.Error); } } break; case MessageUpdater.UpdateTypes.HomeOffset: { try { decimal homeOffset = (decimal)data; if (_deviceViewModels.ContainsKey(address)) { _dispatcher.BeginInvoke(() => _deviceViewModels[address].UpdateHomeOffset(homeOffset)); } } catch (Exception e) { MessageBox.Show(string.Format("Device error: status {0}", e.Message), "Device Error", MessageBoxButton.OK, MessageBoxImage.Error); } } break; case MessageUpdater.UpdateTypes.JogstepSize: { try { decimal jogStep = (decimal)data; if (_deviceViewModels.ContainsKey(address)) { _dispatcher.BeginInvoke(() => _deviceViewModels[address].UpdateJogstepSize(jogStep)); } } catch (Exception e) { MessageBox.Show(string.Format("Device error: status {0}", e.Message), "Device Error", MessageBoxButton.OK, MessageBoxImage.Error); } } break; } }
/// <summary> Updates the information described by info. </summary> /// <param name="info"> The information. </param> public void UpdateInfo(MotorInfo info) { FwdPeriod = info.FwdFreq; RevPeriod = info.RevFreq; }