/// <summary> /// Инициализирует новый экземпляр класса /// </summary> /// <param name="View">Используемы параметр</param> public GraphicPanelParameter(Parameter View) : this() { if (View != null) { parameter = View; } }
/// <summary> /// Инициализирует новый экземпляр класса /// </summary> /// <param name="View">Параметр для отображения</param> /// <param name="gView">График который отображает параметр</param> public GraphicPanelParameter(Parameter View, Graphic gView) : this() { graphic = gView; parameter = View; InitializeGraphic(); }
/// <summary> /// добавить параметр в список /// </summary> /// <param name="parameter">Добавляемый параметр</param> private void InsertParameterToList(Parameter parameter) { int count = listViewParameters.Items.Count + 1; ListViewItem item = new ListViewItem(count.ToString()); ListViewItem.ListViewSubItem des = new ListViewItem.ListViewSubItem(item, parameter.Name); item.Tag = parameter; item.SubItems.Add(des); listViewParameters.Items.Add(item); }
private Parameter edited = null; // редактируемый параметр #endregion Fields #region Constructors public EditParameterForm(Parameter parameter) { InitializeComponent(); if (parameter != null) { edited = parameter; channel = edited.Channel; } else { MessageBox.Show("jnjnjnj"); this.Close(); } }
/// <summary> /// инициализирует новый экземпляр класса /// </summary> /// <param name="_tech">Технологическая примочка</param> /// <param name="_parameters">Список параметров системы</param> /// <param name="_buffer">Буфер в который сохраняются данные</param> public Commutator(Tech _tech, Parameter[] _parameters, RSliceBuffer _buffer) { if (_tech != null && _parameters != null && _buffer != null) { tech = _tech; buffer = _buffer; parameters = _parameters; tech.onCalculate += new EventHandler(tech_onCalculate); tech.onJop += new EventHandler(tech_onJop); DevManClient.onReceive += new ReceivedEventHandler(DevManClient_onReceive); } else ErrorHandler.WriteToLog(this, new ErrorArgs("Коммутатор не смог выполнить инициализацию", ErrorType.Fatal)); }
/// <summary> /// Выполнить копирование с учетеом технологии /// </summary> private void BackingUpDataTech(Parameter[] parameters) { if (parameters != null) { // ----------- копируем значения каналов в технологическую примочку --------------- if (tech_consumption.Index >= 0 && tech_consumption.Index < parameters.Length) { float Val = parameters[tech_consumption.Index].CurrentValue; if (!float.IsNaN(Val) && !float.IsInfinity(Val) && !float.IsNegativeInfinity(Val) && !float.IsPositiveInfinity(Val)) { tech_consumption.Value = Val; tech_consumption.FormattedValue = string.Format(tech_consumption.Format, Val); } else { tech_consumption.FormattedValue = "-----"; } } if (tech_volume.Index >= 0 && tech_volume.Index < parameters.Length) { float Val = parameters[tech_volume.Index].CurrentValue; if (!float.IsNaN(Val) && !float.IsInfinity(Val) && !float.IsNegativeInfinity(Val) && !float.IsPositiveInfinity(Val)) { tech_volume.Value = Val; tech_volume.FormattedValue = string.Format(tech_volume.Format, Val); } else { tech_volume.FormattedValue = "-----"; } } if (tech_density.Index >= 0 && tech_density.Index < parameters.Length) { float Val = parameters[tech_density.Index].CurrentValue; if (!float.IsNaN(Val) && !float.IsInfinity(Val) && !float.IsNegativeInfinity(Val) && !float.IsPositiveInfinity(Val)) { tech_density.Value = Val; tech_density.FormattedValue = string.Format(tech_density.Format, Val); } else { tech_density.FormattedValue = "-----"; } } if (tech_pressure.Index >= 0 && tech_pressure.Index < parameters.Length) { float Val = parameters[tech_pressure.Index].CurrentValue; if (!float.IsNaN(Val) && !float.IsInfinity(Val) && !float.IsNegativeInfinity(Val) && !float.IsPositiveInfinity(Val)) { tech_pressure.Value = Val; tech_pressure.FormattedValue = string.Format(tech_pressure.Format, Val); } else tech_pressure.FormattedValue = "-----"; } if (tech_temperature.Index >= 0 && tech_temperature.Index < parameters.Length) { float Val = parameters[tech_temperature.Index].CurrentValue; if (!float.IsNaN(Val) && !float.IsInfinity(Val) && !float.IsNegativeInfinity(Val) && !float.IsPositiveInfinity(Val)) { tech_temperature.Value = Val; tech_temperature.FormattedValue = string.Format(tech_temperature.Format, Val); } else tech_temperature.FormattedValue = "-----"; } // ---------- тестовое ---------- foreach (Rgr rgr in rgrs) { if (rgr.Volume.Index >= 0 && rgr.Volume.Index < parameters.Length) { float Val = parameters[rgr.Volume.Index].CurrentValue; if (!float.IsNaN(Val) && !float.IsInfinity(Val) && !float.IsNegativeInfinity(Val) && !float.IsPositiveInfinity(Val)) { rgr.Volume.Value = Val; } } if (rgr.Consumption.Index >= 0 && rgr.Consumption.Index < parameters.Length) { float Val = parameters[rgr.Consumption.Index].CurrentValue; if (!float.IsNaN(Val) && !float.IsInfinity(Val) && !float.IsNegativeInfinity(Val) && !float.IsPositiveInfinity(Val)) { rgr.Consumption.Value = Val; } } } // --------------------------------------------------------------------------------- TechStage current = Stages.Current; if (current != null) { is_finished = true; current.Calculate(rgrs); //rgr.Calculate(stages.CorrectionFactor, current.StateRGR); if (onCalculate != null) { onCalculate(this, EventArgs.Empty); } } else { if (!is_finished) { if (onJop != null) { onJop(this, EventArgs.Empty); } } } } }
/// <summary> /// Выполнить простое копирование данных /// </summary> private void BackingUpData(Parameter[] parameters) { if (parameters != null) { // ----------- копируем значения каналов в технологическую примочку --------------- if (tech_consumption.Index > 0 && tech_consumption.Index < parameters.Length) { float Val = parameters[tech_consumption.Index].CurrentValue; if (!float.IsNaN(Val) && !float.IsInfinity(Val) && !float.IsNegativeInfinity(Val) && !float.IsPositiveInfinity(Val)) { tech_consumption.Value = Val; } } if (tech_volume.Index > 0 && tech_volume.Index < parameters.Length) { float Val = parameters[tech_volume.Index].CurrentValue; if (!float.IsNaN(Val) && !float.IsInfinity(Val) && !float.IsNegativeInfinity(Val) && !float.IsPositiveInfinity(Val)) { tech_volume.Value = Val; } } if (tech_density.Index > 0 && tech_density.Index < parameters.Length) { float Val = parameters[tech_density.Index].CurrentValue; if (!float.IsNaN(Val) && !float.IsInfinity(Val) && !float.IsNegativeInfinity(Val) && !float.IsPositiveInfinity(Val)) { tech_density.Value = Val; } } if (tech_pressure.Index > 0 && tech_pressure.Index < parameters.Length) { float Val = parameters[tech_pressure.Index].CurrentValue; if (!float.IsNaN(Val) && !float.IsInfinity(Val) && !float.IsNegativeInfinity(Val) && !float.IsPositiveInfinity(Val)) { tech_pressure.Value = Val; } } if (tech_temperature.Index > 0 && tech_temperature.Index < parameters.Length) { float Val = parameters[tech_temperature.Index].CurrentValue; if (!float.IsNaN(Val) && !float.IsInfinity(Val) && !float.IsNegativeInfinity(Val) && !float.IsPositiveInfinity(Val)) { tech_temperature.Value = Val; } } if (onCalculate != null) { onCalculate(this, EventArgs.Empty); } // --------------------------------------------------------------------------------- } }
/// <summary> /// Данные были обновленны. /// Данная процедура не синхронизованна! /// </summary> public void Updated(Parameter[] parameters) { switch (mode) { case TechMode.Technology: BackingUpDataTech(parameters); break; case TechMode.Default: BackingUpData(parameters); break; default: break; } }
/// <summary> /// Загрузить настройки /// </summary> public void Load(XmlNode root) { try { if (root != null) { XmlNode root_node = root; if (root_node != null) { XmlNodeList childs = root_node.ChildNodes; if (childs != null) { foreach (XmlNode child in childs) { switch (child.Name) { case "parameter": Parameter parameter = new Parameter(-1); parameter.DeserializeFromXmlNode(child); if (parameter.SelfIndex > -1 && parameter.SelfIndex < parameters.Length) { parameters[parameter.SelfIndex] = parameter; } break; case Tech.TechRoot: tech.Load(child); break; default: break; } } } } } } catch { } }
/// <summary> /// Загрузить параметр панели из узела XML /// </summary> /// <param name="doc"></param> /// <returns></returns> public void DeSerializeToXmlNode(XmlNode root) { try { if (root != null) { if (root.HasChildNodes) { foreach (XmlNode child in root.ChildNodes) { switch (child.Name) { case minName: try { min = float.Parse(child.InnerText); } catch { } break; case maxName: try { max = float.Parse(child.InnerText); } catch { } break; case colorName: try { int argb = int.Parse(child.InnerText); color = System.Drawing.Color.FromArgb(argb); } catch { } break; case "parameter": try { if (parameter == null) { parameter = new Parameter(); } parameter.DeserializeFromXmlNode(child); } catch { parameter = null; } break; default: break; } } } } } catch { } }
protected Tech tech = null; // технологическая примочка #endregion Fields #region Constructors /// <summary> /// Инициализирует новый экземпляр класса /// </summary> protected Application() { try { ErrorHandler.InitializeErrorHandler(); ErrorHandler.OnExit += new EventHandler(ErrorHandler_OnExit); buffer = new RSliceBuffer(72000); manager = new DataBaseManager(); projects = new List<Project>(); commands = new List<BlockViewCommand>(); parameters = new Parameter[256]; for (int index = 0; index < parameters.Length; index++) { parameters[index] = new Parameter(index); parameters[index].Identifier = Identifiers.GetGuid(index); } tech = new Tech(); commutator = new Commutator(tech, parameters, buffer); panels = new List<ParametersViewPanel>(); // devManUri = new Uri("net.tcp://localhost:57000"); devManUri = new Uri("net.tcp://127.0.0.1:57000"); CheckRegistry(); LoadUri(); DevManClient.Uri = devManUri; DevManClient.Context.Mode = UserMode.Passive; DevManClient.Context.Role = Role.Common; client = new devTcpManager(); Ping ping = new Ping(); PingOptions options = new PingOptions(); try { PingReply reply = ping.Send(devManUri.Host); if (reply.Status == IPStatus.Success) { /*DevManClient.Uri = devManUri; DevManClient.Context.Mode = UserMode.Passive; DevManClient.Context.Role = Role.Common;*/ DevManClient.Connect(); // client = new devTcpManager(); string ip = System.Net.Dns.Resolve(devManUri.Host).AddressList[0].ToString(); //string ip = System.Net.Dns.GetHostEntry(devManUri.Host).AddressList[0].ToString(); client.Client.Host = ip; client.Client.Port = 56000; client.Client.Connect(); } else { /*try { client = null; } catch { }*/ } } catch { } } catch (Exception ex) { ErrorHandler.WriteToLog(this, new ErrorArgs(ex.Message, ErrorType.Fatal)); } }
/// <summary> /// настроить технологические графики /// </summary> public void UpdateTechGraphics() { try { if (_app.Commutator.Technology.Consumption.Index > -1 && _app.Commutator.Technology.Consumption.Index < _app.Commutator.Parameters.Length) { int c_index = _app.Commutator.Technology.Consumption.Index; Parameter p_consumption = _app.Commutator.Parameters[c_index]; if (p_consumption != null) { _app.Graphic_consumption.Description = p_consumption.Description; } } if (_app.Commutator.Technology.Volume.Index > -1 && _app.Commutator.Technology.Volume.Index < _app.Commutator.Parameters.Length) { int v_index = _app.Commutator.Technology.Volume.Index; Parameter p_volume = _app.Commutator.Parameters[v_index]; if (p_volume != null) { _app.Graphic_volume.Description = p_volume.Description; } } if (_app.Commutator.Technology.Density.Index > -1 && _app.Commutator.Technology.Density.Index < _app.Commutator.Parameters.Length) { int d_index = _app.Commutator.Technology.Density.Index; Parameter p_density = _app.Commutator.Parameters[d_index]; if (p_density != null) { _app.Graphic_density.Description = p_density.Description; } } if (_app.Commutator.Technology.Pressure.Index > -1 && _app.Commutator.Technology.Pressure.Index < _app.Commutator.Parameters.Length) { int pr_index = _app.Commutator.Technology.Pressure.Index; Parameter p_pressure = _app.Commutator.Parameters[pr_index]; if (p_pressure != null) { _app.Graphic_pressure.Description = p_pressure.Description; } } if (_app.Commutator.Technology.Temperature.Index > -1 && _app.Commutator.Technology.Temperature.Index < _app.Commutator.Parameters.Length) { int t_index = _app.Commutator.Technology.Temperature.Index; Parameter t_parameter = _app.Commutator.Parameters[t_index]; if (t_parameter != null) { _app.Graphic_temperature.Description = t_parameter.Description; _app.Graphic_temperature.Units = string.Format("[{0}]", t_parameter.Units); } } } catch { } }
protected bool autolocalhost = false; // автоматически подключаться к локальному серверу данных /// <summary> /// Инициализирует новый экземпляр класса /// </summary> protected Application() { try { ErrorHandler.InitializeErrorHandler(); ErrorHandler.OnExit += new EventHandler(ErrorHandler_OnExit); buffer = new RSliceBuffer(72000); manager = new DataBaseManager(); projects = new List <Project>(); commands = new List <BlockViewCommand>(); parameters = new Parameter[256]; for (int index = 0; index < parameters.Length; index++) { parameters[index] = new Parameter(index); parameters[index].Identifier = Identifiers.GetGuid(index); } tech = new Tech(); commutator = new Commutator(tech, parameters, buffer); panels = new List <ParametersViewPanel>(); // devManUri = new Uri("net.tcp://localhost:57000"); devManUri = new Uri("net.tcp://127.0.0.1:57000"); CheckRegistry(); LoadUri(); DevManClient.Uri = devManUri; DevManClient.Context.Mode = UserMode.Passive; DevManClient.Context.Role = Role.Common; client = new devTcpManager(); Ping ping = new Ping(); PingOptions options = new PingOptions(); try { PingReply reply = ping.Send(devManUri.Host); if (reply.Status == IPStatus.Success) { /*DevManClient.Uri = devManUri; * * DevManClient.Context.Mode = UserMode.Passive; * DevManClient.Context.Role = Role.Common;*/ DevManClient.Connect(); // client = new devTcpManager(); string ip = System.Net.Dns.Resolve(devManUri.Host).AddressList[0].ToString(); //string ip = System.Net.Dns.GetHostEntry(devManUri.Host).AddressList[0].ToString(); client.Client.Host = ip; client.Client.Port = 56000; client.Client.Connect(); } else { /*try * { * client = null; * } * catch { }*/ } } catch { } } catch (Exception ex) { ErrorHandler.WriteToLog(this, new ErrorArgs(ex.Message, ErrorType.Fatal)); } }