private void ExportSignalMenuItem_Click(object sender, RoutedEventArgs e) { System.Windows.Controls.MenuItem tv = sender as System.Windows.Controls.MenuItem; SignalViewModel signal = tv.DataContext as SignalViewModel; if (signal != null) { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.DefaultExt = ".txt"; // Default file extension dlg.Filter = "Text files|*.txt"; // Filter files by extension dlg.FileName = signal.Title; dlg.AddExtension = true; // Show open file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { Sample[] data = signal.GetData(); using (StreamWriter sw = File.CreateText(dlg.FileName)) { CultureInfo invariantCulture = CultureInfo.InvariantCulture; for (int i = 0; i < data.GetLength(0); i++) { sw.WriteLine(data[i].Time.ToString(invariantCulture) + "," + data[i].Value.ToString(invariantCulture)); } } } } }
public async Task <IActionResult> SignalArrived(SignalInputModel inputModel) { //you can validate input here //then if the inputmodel is valid then you can save the signal var saveResult = await _signalService.SaveSignalAsync(inputModel); //if you can save the signal you can notify all clients by using SignalHub if (saveResult) { //you might think use a mapping tool? SignalViewModel signalViewModel = new SignalViewModel { Description = inputModel.Description, CustomerName = inputModel.CustomerName, Area = inputModel.Area, Zone = inputModel.Zone, SignalStamp = Guid.NewGuid().ToString() }; var user = signalViewModel.CustomerName; var message = signalViewModel.Description; var date = signalViewModel.SignalStamp; var zone = signalViewModel.Zone; await _hubContext.Clients.All.SendAsync("SignalMessageReceived", user, message, date, zone); // await _hubContext.Clients.All.SendAsync("SignalMessageReceived", signalViewModel); } return(StatusCode(200, saveResult)); }
private async Task <SignalViewModel> ProcessSignal(string fileName) { string fullPath = this.GetFileFullPath(fileName); ISignalProcessorService signalProcessor = _signalProcessorServiceFactory.Create(fullPath); SignalInfo signalInfo = await signalProcessor.ProcessFileAsync(); SignalViewModel signalViewModel = SignalViewModelBuilder.Create(signalInfo, fileName); return(signalViewModel); }
public Window_Signal(DataPathModel _DataPath) { InitializeComponent(); Data = new SignalViewModel(_DataPath); this.DataContext = Data; ////Default setting of the view items //Bus_CB.IsChecked = false; //MSB_TB.IsReadOnly = true; //LSB_TB.IsReadOnly = true; }
private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { System.Windows.Controls.StackPanel tv = sender as System.Windows.Controls.StackPanel; SignalViewModel item = tv.DataContext as SignalViewModel; if (item != null && e.LeftButton == MouseButtonState.Pressed) { try { DragDrop.DoDragDrop(this.treeView, new DataObject("Signal", item), System.Windows.DragDropEffects.Copy); } catch { } } }
public override void RemoveSignal(SignalViewModel signal) { if (_model is Filter) { InputChannels.Remove(signal); OutputChannels.Remove(signal); } else {//need to remove the output signal depends on type of customization switch (Name) { case "Subtraction": break; default: break; } } }
public async Task <IActionResult> SignalArrived(SignalInputModel signalInputModel) { var saveResult = await this._signalService.SavesSignalAsync(signalInputModel); if (saveResult) { var signalViewModel = new SignalViewModel { Description = signalInputModel.Description, CustomerName = signalInputModel.CustomerName, Area = signalInputModel.Area, Zone = signalInputModel.Zone, SignalStamp = Guid.NewGuid().ToString(), }; await this._hubContext.Clients.All.SendAsync("SignalMessageReceived", signalViewModel); } return(StatusCode(200, saveResult)); }
public async Task <IActionResult> SignalArrived(SignalInputModel inputModel) { //you can validate input here //then if the inputModel is valid then you can save the signal var saveResult = await _signalService.SaveSignalAsync(inputModel); if (saveResult) { SignalViewModel signalViewModel = new SignalViewModel { Description = inputModel.Description, CustomerName = inputModel.CustomerName, Area = inputModel.Area, Zone = inputModel.Zone, SignalStamp = Guid.NewGuid().ToString(), }; //notify all clients by using SignalHub await _hubContext.Clients.All.SendAsync("SignalMessageReceived", signalViewModel); } return(StatusCode(200, saveResult)); }
public override void AddSignal(SignalViewModel signal) { if (_model is Filter) { InputChannels.Add(signal); // Override baseclass function OutputChannels.Add(signal); } else { switch (Name) { //case "Status Flags": //case "Zeros": //case "Missing": //case "Nominal Voltage": //case "Nominal Frequency": // break; case "Subtraction": // Set parameter SetFocusedTextBox(signal); // if step is a customization, need to make up the output signal from input signal depends on type of customizaion break; } } }
/// <summary> /// Returns the Views for the ID and/or group type. /// TODO: Implement Username /// </summary> /// <param name="deviceID"></param> /// <param name="groupType"></param> /// <returns></returns> public SignalViewModels Get([FromUri] string deviceID, [FromUri] string groupType = null) { SignalViewModels returnObjs = new SignalViewModels(); //returnObjs.UserName = RequestContext.Principal.Identity.Name; string filter = string.Empty; if (!string.IsNullOrWhiteSpace(groupType)) { filter = ", @TypeIDByValue = '" + groupType + "'"; } string query = "EXEC rGetSignalViewByDevice @DeviceID = '" + deviceID + "'" + filter; using (DataTable tblData = sqlObject.QuerySQL(query, ref sqlStatus)) { if (tblData != null && tblData.Rows.Count > 0) { foreach (DataRow item in tblData.Rows) { SignalViewModel newObj = new SignalViewModel(); newObj.SignalID = item["SignalID"].ToString(); newObj.InputSource = item["InputSource"].ToString(); newObj.OutputSource = item["OutputSource"].ToString(); newObj.TagName = item["TagName"].ToString(); newObj.DisplayName = item["DisplayName"].ToString(); newObj.ViewDisplayName = item["ViewDisplayName"].ToString(); newObj.TimeStamp = item["TimeStamp"].ToString(); newObj.RawValue = item["RawValue"].ToString(); newObj.Source = item["Source"].ToString(); newObj.Enabled = item["Enabled"].ToString(); newObj.ItemDataType = item["ItemDataType"].ToString(); newObj.CommChannel = item["CommChannel"].ToString(); newObj.EnableScaling = item["EnableScaling"].ToString(); newObj.EU_Min = item["EU_Min"].ToString(); newObj.EU_Max = item["EU_Max"].ToString(); newObj.RawMin = item["RawMin"].ToString(); newObj.RawMax = item["RawMax"].ToString(); newObj.MinValue = item["MinValue"].ToString(); newObj.MaxValue = item["MaxValue"].ToString(); newObj.Precision = item["Precision"].ToString(); newObj.Quality = item["Quality"].ToString(); newObj.Units = item["Units"].ToString(); newObj.WriteSecurityLevel = item["WriteSecurityLevel"].ToString(); newObj.EnumLookupValue = item["EnumLookupValue"].ToString(); if (!string.IsNullOrWhiteSpace(newObj.EnumLookupValue)) { query = "SELECT Value, Text FROM cfgTblIdentifiers WHERE ID_Type = '" + newObj.EnumLookupValue + "'"; DataTable tblEnums = sqlObject.QuerySQL(query, ref sqlStatus); if (tblEnums != null && tblEnums.Rows.Count > 0) { foreach (DataRow dRow in tblEnums.Rows) { newObj.EnumValues.Add(new EnumVal(dRow["Value"].ToString().ToLower(), dRow["Text"].ToString())); } } } returnObjs.SignalViews.Add(newObj); } } } return(returnObjs); }
public virtual void AddSignal(SignalViewModel signal) { InputChannels.Add(signal); }
public virtual void RemoveSignal(SignalViewModel signal) { InputChannels.Remove(signal); }
internal bool SetFocusedTextBox(SignalViewModel signal) { if (CurrentCursor == "") { //No textbox selected throw new Exception("Error! Please select a valid text box for this input signal!"); } else if (CurrentCursor == "Minuend") { // Subtraction if (signal.IsChecked) { // Check to make sure subtrahend and minuend aren't the same signal if (Subtrahend != null && Subtrahend == signal) { throw new Exception("Minuend cannot be the same as the subtrahend!"); } else // Set this as the minuend { Minuend = signal; Minuend.IsChecked = false; } } else { // Check box unchecked, want to delete content in box if (signal == Minuend) { Minuend = new SignalViewModel(); // Set as blank value } } CurrentCursor = ""; return(true); } else if (CurrentCursor == "Subtrahend") { // Subtraction if (signal.IsChecked) { // Check to make sure subtrahend and minuend aren't the same signal if (Minuend != null && Minuend == signal) { throw new Exception("Subtrahend cannot be the same as the minuend!"); } else // Set this as the minuend { Subtrahend = signal; Subtrahend.IsChecked = false; } } else { // Check box unchecked, want to delete content in box if (signal == Minuend) { Subtrahend = new SignalViewModel(); // Set as blank value } } CurrentCursor = ""; return(true); } return(false); }
//constructor that accepts a DatapathModel object to be used in the combo Boxes public Window_Signal(DataPathModel _DataPath) { InitializeComponent(); _Data = new SignalViewModel(_DataPath); //creates an instance of the SignalViewModel and passes the datapath data from the window to the viewmodel this.DataContext = _Data; //Sets the Window DataContext to that of the SignalViewModel to allow for binding }