public CageUnit(ConfigurationUnit configurationUnit) { if (configurationUnit.Type == ConfigurationUnitType.Cage) { Position = new Point(); foreach (KeyValuePair <string, string> param in configurationUnit.Parameters) { string value = param.Value; string tmpVal; double dbValue; switch (param.Key.ToUpper()) { case "ИДЕНТИФИКАТОР": Uid = Convert.ToInt32(value); break; case "ИМЯ": Name = value; break; case "КООРДИНАТА": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); Position.PosX = dbValue; break; case "ПРИБЛИЗИТЕЛЬНЫЙКОЭФФИЦИЕНТОПЕРЕЖЕНИЯ": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); AdvanceRatio = dbValue; break; case "ПРИБЛИЗИТЕЛЬНЫЙКОЭФФИЦИЕНТОТСТАВАНИЯ": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); LagRatio = dbValue; break; case "ТИПКЛЕТИ": CagesType tmpType = getCageType(value); CageType = tmpType; break; case "ИДЕНТИФИКАТОРСИГНАЛАКЛЕТЬВРАБОТЕ": SignalInWork = Convert.ToInt32(value); break; case "ИДЕНТИФИКАТОРСИГНАЛАСКОРОСТЬ": SignalSpeed = Convert.ToInt32(value); break; case "НОМЕРНИТИ": ThreadNumber = Convert.ToInt32(value); break; } } } }
public ThreadUnit(ConfigurationUnit confConfigurationUnit) { if (confConfigurationUnit.Type == ConfigurationUnitType.Thread) { StartPos = new Point(); FinishPos = new Point(); foreach (KeyValuePair <string, string> param in confConfigurationUnit.Parameters) { string value = param.Value; string tmpVal; double dbValue; switch (param.Key.ToUpper()) { case "ИДЕНТИФИКАТОР": Uid = Convert.ToInt32(value); break; case "ИМЯ": Name = value; break; case "КООРДИНАТАНАЧАЛА": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); StartPos.PosX = dbValue; break; case "КООРДИНАТАЗАВЕРШЕНИЯ": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); FinishPos.PosX = dbValue; break; case "НАПРАВЛЕНИЕ": ThreadDirection direction = getThreadDirection(value); Direction = direction; break; case "ПРЕДЫДУЩАЯНИТЬ": PrevThread = Convert.ToInt32(value); break; case "СЛЕДУЮЩАЯНИТЬ": NextThread = Convert.ToInt32(value); break; case "НОМЕРНИТИ": ThreadNumber = Convert.ToInt32(value); break; case "ОСТАНАВЛИВАТЬНАКОНЦАХНИТИ": int tmpValue = Convert.ToInt32(value); StopOnEnds = tmpValue > 0; break; } } } }
public AggregateUnit(ConfigurationUnit configurationUnit) { if (configurationUnit.Type == ConfigurationUnitType.Aggregate) { foreach (KeyValuePair <string, string> param in configurationUnit.Parameters) { string value = param.Value; switch (param.Key.ToUpper()) { case "ИДЕНТИФИКАТОР": Uid = Convert.ToInt32(value); break; case "ИМЯ": Name = value; break; case "ПРЕФИКС": Prefix = value; break; case "ЧАСТОТАЗАПИСИСИГНАЛОВ": WriteSignalsPeriod = Convert.ToInt32(value); break; } } } }
public LabelUnit(ConfigurationUnit configurationUnit) { if (configurationUnit.Type == ConfigurationUnitType.Label) { Position = new Point(); foreach (KeyValuePair <string, string> param in configurationUnit.Parameters) { string value = param.Value; string tmpVal; double dbValue; switch (param.Key.ToUpper()) { case "КООРДИНАТА": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); Position.PosX = dbValue; break; case "НОМЕРНИТИ": ThreadNumber = Convert.ToInt32(value); break; case "ТЕКСТ": Text = value; break; case "ВЫРАВНИВАНИЕ": AlignmentType type = getAlignmentType(value); Alignment = type; break; } } } }
public SignalUnit(ConfigurationUnit confConfigurationUnit) { if (confConfigurationUnit.Type == ConfigurationUnitType.Signal) { foreach (KeyValuePair <string, string> param in confConfigurationUnit.Parameters) { string value = param.Value; switch (param.Key.ToUpper()) { case "ИДЕНТИФИКАТОР": Uid = Convert.ToInt32(value); break; case "ИМЯ": Name = value; break; case "ИМЯСЕРВЕР": ServerName = value; break; case "ТИП": SignalType type = getSignalsTypes(value); Type = type; break; case "ИДЕНТИФИКАТОРБЛОКАДАННЫХ": DataBlockUid = Convert.ToInt32(value); break; case "БАЙТ": Byte = Convert.ToInt32(value); break; case "БИТ": Bit = Convert.ToInt32(value); break; case "ЗНАЧЕНИЕВИРТУАЛЬНОГОСИГНАЛА": VirtualValue = Convert.ToDouble(value.Replace(".", ",")); break; case "СОСТАВНОЙСИГНАЛ": CompoundSignalType tmpType = getCompoundSignalsTypes(value); CompoundSignal = tmpType; break; case "ЗАПИСЬКЛИЕНТАМИ": int tmpValue = Convert.ToInt32(value); UserWrite = tmpValue > 0; break; case "МИНИМАЛЬНЫЙУРОВЕНЬАНАЛОГОВОГОСИГНАЛА": MinAnalogLevel = Convert.ToInt32(value); break; } } } }
public DataBlockUnit(ConfigurationUnit confConfigurationUnit) { if (confConfigurationUnit.Type == ConfigurationUnitType.DataBlock) { foreach (KeyValuePair <string, string> param in confConfigurationUnit.Parameters) { string val = param.Value; switch (param.Key.ToUpper()) { case "ИДЕНТИФИКАТОРБЛОКАДАННЫХ": Uid = Convert.ToInt32(val); break; case "ИМЯБЛОКАДАННЫХ": Name = val; break; case "ТИПСВЯЗИ": DataBlockType type = getDataBlockTypes(val); Type = type; break; case "РАЗМЕРБЛОКАДАННЫХ": DataBlockSize = Convert.ToInt32(val); break; case "ПРИЗНАКПЕРЕСТАНОВКИБАЙТ": int intVal = Convert.ToInt32(val); Reversal = intVal > 0; break; case "ПОРТ": Port = Convert.ToInt32(val); break; case "ПОРТОТПРАВИТЕЛЯ": SenderPort = Convert.ToInt32(val); break; case "IPАДРЕСОТПРАВИТЕЛЯ": SenderHost = val; break; case "ЗАГОЛОВОК": int tmpVal = Convert.ToInt32(val); HasHead = tmpVal > 0; break; case "СЕРВЕР": ServerName = val; break; case "ПУТЬДОСТУПА": ServerPath = val; break; } } } }
public RollgangUnit(ConfigurationUnit confConfigurationUnit) { if (confConfigurationUnit.Type == ConfigurationUnitType.Rollgang) { StartPos = new Point(); FinishPos = new Point(); foreach (KeyValuePair <string, string> param in confConfigurationUnit.Parameters) { string value = param.Value; string tmpVal; double dbValue; switch (param.Key.ToUpper()) { case "ИДЕНТИФИКАТОР": Uid = Convert.ToInt32(value); break; case "ИМЯ": Name = value; break; case "КООРДИНАТАНАЧАЛА": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); StartPos.PosX = dbValue; break; case "КООРДИНАТАЗАВЕРШЕНИЯ": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); FinishPos.PosX = dbValue; break; case "ИДЕНТИФИКАТОРСИГНАЛАСКОРОСТЬ": SignalSpeed = Convert.ToInt32(value); break; case "НОМЕРНИТИ": ThreadNumber = Convert.ToInt32(value); break; case "КОНСТАНТАСКОРОСТИ": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); SpeedValue = dbValue; break; } } } }
public LinearDisplacementUnit(ConfigurationUnit configurationUnit) { if (configurationUnit.Type == ConfigurationUnitType.LinearMoving) { StartPos = new Point(); FinishPos = new Point(); foreach (KeyValuePair <string, string> param in configurationUnit.Parameters) { string value = param.Value; string tmpVal; double dbValue; switch (param.Key.ToUpper()) { case "ИДЕНТИФИКАТОР": Uid = Convert.ToInt32(value); break; case "ИМЯ": Name = value; break; case "КООРДИНАТАНАЧАЛА": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); StartPos.PosX = dbValue; break; case "КООРДИНАТАЗАВЕРШЕНИЯ": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); FinishPos.PosX = dbValue; break; case "СИГНАЛВЕЛИЧИНЫДВИЖЕНИЯ": StepSizeSignalUid = Convert.ToInt32(value); break; case "СИГНАЛФАКТАДВИЖЕНИЯ": StartMovingSignalUid = Convert.ToInt32(value); break; case "НОМЕРНИТИ": ThreadNumber = Convert.ToInt32(value); break; } } } }
public DeleterUnit(ConfigurationUnit configurationUnit) { if (configurationUnit.Type == ConfigurationUnitType.Deleter) { StartPos = new Point(); FinishPos = new Point(); foreach (KeyValuePair <string, string> param in configurationUnit.Parameters) { string value = param.Value; string tmpVal; double dbValue; switch (param.Key.ToUpper()) { case "ИДЕНТИФИКАТОР": Uid = Convert.ToInt32(value); break; case "ИМЯ": Name = value; break; case "НОМЕРНИТИ": ThreadNumber = Convert.ToInt32(value); break; case "КООРДИНАТАНАЧАЛА": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); StartPos.PosX = dbValue; break; case "КООРДИНАТАЗАВЕРШЕНИЯ": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); FinishPos.PosX = dbValue; break; case "ВРЕМЯУДАЛЕНИЯ": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); DeletingTime = dbValue; break; } } } }
public SubscriptionsUnit(ConfigurationUnit confConfigurationUnit) { if (confConfigurationUnit.Type == ConfigurationUnitType.Subscription) { foreach (KeyValuePair <string, string> param in confConfigurationUnit.Parameters) { switch (param.Key.ToUpper()) { case "ПОТОКИ": Threads = Convert.ToInt32(param.Value); break; } } SubObjects = confConfigurationUnit.SubObjects.Count > 0 ? confConfigurationUnit.SubObjects : new List <ConfigurationUnit>(); } }
public SensorUnit(ConfigurationUnit configurationUnit) { if (configurationUnit.Type == ConfigurationUnitType.Sensor) { Position = new Point(); foreach (KeyValuePair <string, string> param in configurationUnit.Parameters) { string value = param.Value; string tmpVal; double dbValue; switch (param.Key.ToUpper()) { case "ИДЕНТИФИКАТОР": Uid = Convert.ToInt32(value); break; case "ИМЯ": Name = value; break; case "КООРДИНАТА": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); Position.PosX = dbValue; break; case "ИДЕНТИФИКАТОРСИГНАЛАСДАТЧИКА": SignalUid = Convert.ToInt32(value); break; case "НОМЕРНИТИ": ThreadNumber = Convert.ToInt32(value); break; case "РАЗРЕШЕНИЕ": Resolution = Convert.ToInt32(value); break; } } } }
public IngotParametersUnit(ConfigurationUnit configurationUnit) { if (configurationUnit.Type == ConfigurationUnitType.IngotParams) { foreach (KeyValuePair <string, string> param in configurationUnit.Parameters) { string value = param.Value; string tmpVal; double dbValue; int intVal; switch (param.Key.ToUpper()) { case "ИДЕНТИФИКАТОР": Uid = Convert.ToInt32(value); break; case "ИМЯ": Name = value; break; case "ТИП": IngotParameterType type = getIngotParameterType(value); Type = type; break; case "ЗНАЧЕНИЕЧИСЛО": tmpVal = value.Replace(".", ","); dbValue = Convert.ToDouble(tmpVal); Value = dbValue; break; case "ЛОГИРОВАНИЕЗАПИСИ": intVal = Convert.ToInt32(value); Logging = intVal > 0; break; } } } }
/// <summary> /// Конструктор из объекта Objects /// </summary> /// <param name="confConfigurationUnit">Экземпляр объекта Objects</param> public MillConfigUnit(ConfigurationUnit confConfigurationUnit) { if (confConfigurationUnit.Type == ConfigurationUnitType.MillConfig) { foreach (KeyValuePair <string, string> param in confConfigurationUnit.Parameters) { string val = param.Value; switch (param.Key.ToUpper()) { case "IPАДРЕССЕРВЕРАВИЗУАЛИЗАЦИИСЛЕЖЕНИЯ": VisualHost = val; break; case "ПОРТСЕРВЕРАВИЗУАЛИЗАЦИИСЛЕЖЕНИЯ": VisualPort = Convert.ToInt32(val); break; case "ПЕРИОДНАКОПЛЕНИЯДАННЫХ": PeriodAccumulation = Convert.ToInt32(val); break; case "ПЕРИОДЗАПИСИДАННЫХ": PeriodRecording = Convert.ToInt32(val); break; case "РАЗМЕРФАЙЛАБУФЕРА": BufferSize = Convert.ToInt64(val); break; case "ИМЯ": Name = val; break; case "КОММЕНТАРИЙ": Comment = val; break; case "ФАЙЛТЕГОВАРХИВА": ArchiveFile = val; break; case "IPАДРЕССЕРВЕРААРХИВОВ": ArchiveHost = val; break; case "ПОРТСЕРВЕРААРХИВОВ": ArchivePort = Convert.ToInt32(val); break; case "МАКСИМАЛЬНАЯСКОРОСТЬОБЪЕКТА": val = val.Replace(".", ","); MaxObjectSpeed = Convert.ToDouble(val); break; case "УСКОРЕНИЕОБЪЕКТА": val = val.Replace(".", ","); ObjectAcceleration = Convert.ToDouble(val); break; case "ОКРЕСТНОСТЬЗАКЛЕТЬЮ": val = val.Replace(".", ","); CageNeighborhood = Convert.ToDouble(val); break; case "ОКРЕСТНОСТЬДАТЧИКАГОЛОВА": val = val.Replace(".", ","); HeadNeighborhood = Convert.ToDouble(val); break; case "ОКРЕСТНОСТЬДАТЧИКАХВОСТ": val = val.Replace(".", ","); TailNeighborhood = Convert.ToDouble(val); break; case "МАКСИМАЛЬНОЕКОЛИЧЕСТВОЕДИНИЦ": MaxUnitsCount = Convert.ToInt32(val); break; case "СУММАРНЫЙРАЗМЕРФАЙЛОВБУФЕРА": MaxFileSize = Convert.ToInt64(val); break; } } } }
public ConnectionStringUnit(ConfigurationUnit configurationUnit) { if (configurationUnit.Type == ConfigurationUnitType.Connection) { foreach (KeyValuePair <string, string> param in configurationUnit.Parameters) { switch (param.Key.ToUpper()) { case "СТРОКАСОЕДИНЕНИЯ": ConnectionString = param.Value; break; } } } string[] pars = ConnectionString.Split(";"); foreach (string par in pars) { if (!string.IsNullOrEmpty(par)) { int posEq = par.IndexOf('='); string key = par.Substring(0, posEq); string val = par.Substring(posEq + 1); switch (key.ToUpper()) { case "HOST": Host = val; break; case "PORT": try { Port = int.Parse(val); } catch { Port = 0; } break; case "DATABASE": Database = val; break; case "USERNAME": UserName = val; break; case "PASSWORD": UserPassword = val; break; case "SSLMODE": SslMode = val; break; case "TRUST SERVER CERTIFICATE": try { TrustServer = bool.Parse(val); } catch { TrustServer = true; } break; } } } }