protected override void DoInitialize() { logger.Info("Инициализация..."); var server = opcConnection.WaitConnection(); try { opcTags = new OpcValueImpl[parameters.Length]; for (var i = 0; i < parameters.Length; ++i) { opcTags[i] = new OpcValueImpl(server, parameters[i].OpcTag); opcTags[i].Activate(); } } finally { opcConnection.ReleaseConnection(); } logger.Info("Инициализация завершена."); }
public void Activate() { opcServer.Connect(SERVER_NAME, HOST); tag[DB601_NEW_BATCH_REQUEST] = new OpcValueImpl(opcServer, DB601_NEW_BATCH_REQUEST); tag[DB601_FURNACE_NUMBER] = new OpcValueImpl(opcServer, DB601_FURNACE_NUMBER); tag[DB600_NEW_BATCH_RECEIVED] = new OpcValueImpl(opcServer, DB600_NEW_BATCH_RECEIVED); tag[DB600_CAST_NUM] = new OpcValueImpl(opcServer, DB600_CAST_NUM); tag[DB600_FURNACE_NUM] = new OpcValueImpl(opcServer, DB600_FURNACE_NUM); tag[DB600_MELT_ID] = new OpcValueImpl(opcServer, DB600_MELT_ID); tag[DB600_PRODUCT_NAME] = new OpcValueImpl(opcServer, DB600_PRODUCT_NAME); tag[DB620_DATA_READY] = new OpcValueImpl(opcServer, DB620_DATA_READY); tag[DB620_WEIGHT] = new OpcValueImpl(opcServer, DB620_WEIGHT); tag[DB620_ITEM_NO] = new OpcValueImpl(opcServer, DB620_ITEM_NO); tag[DB620_CAST_NUM] = new OpcValueImpl(opcServer, DB620_CAST_NUM); tag[DB620_FURNACE_NUM] = new OpcValueImpl(opcServer, DB620_FURNACE_NUM); tag[DB620_MELT_ID] = new OpcValueImpl(opcServer, DB620_MELT_ID); tag[DB001] = new OpcValueImpl(opcServer, DB001); tag[DB601_NEW_BATCH_REQUEST].Activate(); tag[DB601_FURNACE_NUMBER].Activate(); tag[DB600_NEW_BATCH_RECEIVED].IsListenValueChanging = true; tag[DB600_NEW_BATCH_RECEIVED].SubscribeToValueChange(this); tag[DB600_NEW_BATCH_RECEIVED].Activate(); tag[DB600_CAST_NUM].Activate(); tag[DB600_FURNACE_NUM].Activate(); tag[DB600_MELT_ID].Activate(); tag[DB600_PRODUCT_NAME].Activate(); tag[DB620_DATA_READY].Activate(); tag[DB620_WEIGHT].Activate(); tag[DB620_ITEM_NO].Activate(); tag[DB620_CAST_NUM].Activate(); tag[DB620_FURNACE_NUM].Activate(); tag[DB620_MELT_ID].Activate(); tag[DB001].Activate(); db601Timer = new Timer(); db601Timer.Elapsed += ChangeDb601Tags; db601Timer.Interval = 2*1000; db601Timer.Start(); }
protected override void DoInitialize() { try { var opcServer = connectionHolder.WaitConnection(); var currentValues = configuration.GetCurrentValues(); foreach (var currentValue in currentValues) { opcTag[currentValue] = new OpcValueImpl(opcServer, currentValue.OpcItemName); opcTag[currentValue].Activate(); } readerTimer = new Timer(); readerTimer.Elapsed += ReadCurrentValues; readerTimer.Interval = configuration.ReadInterval*1000; } finally { connectionHolder.ReleaseConnection(); } }
protected override void DoInitialize() { if (server == null || server.ServerState != (int) OPCServerState.OPCRunning) { throw new ArgumentException("OPC Server не подключен."); } if (string.IsNullOrEmpty(tagName)) { throw new ArgumentException("Имя тега активации не задано."); } if (listener == null) { throw new ArgumentException("Слушатель активатора для DataProvider не задан."); } activationTag = new OpcValueImpl(server, tagName, OPCDataSource.OPCDevice, aUpdateRate: 25); activationTag.IsListenValueChanging = true; activationTag.SubscribeToValueChange(this); activationTag.Activate(); }
protected override void DoInitialize() { try { logger.Info("Инициализация..."); var opcServer = connectionHolder.WaitConnection(); tag[DB601_NEW_BATCH_REQUEST] = new OpcValueImpl(opcServer, opcTagsList[DB601_NEW_BATCH_REQUEST]); tag[DB601_FURNACE_NUMBER] = new OpcValueImpl(opcServer, opcTagsList[DB601_FURNACE_NUMBER]); tag[DB600_NEW_BATCH_RECEIVED] = new OpcValueImpl(opcServer, opcTagsList[DB600_NEW_BATCH_RECEIVED]); tag[DB600_FURNACE_NUM] = new OpcValueImpl(opcServer, opcTagsList[DB600_FURNACE_NUM]); tag[DB600_CAST_NUM] = new OpcValueImpl(opcServer, opcTagsList[DB600_CAST_NUM]); tag[DB600_MELT_ID] = new OpcValueImpl(opcServer, opcTagsList[DB600_MELT_ID]); tag[DB600_PRODUCT_NAME] = new OpcValueImpl(opcServer, opcTagsList[DB600_PRODUCT_NAME]); tag[DB620_DATA_READY] = new OpcValueImpl(opcServer, opcTagsList[DB620_DATA_READY]); tag[DB620_WEIGHT] = new OpcValueImpl(opcServer, opcTagsList[DB620_WEIGHT]); tag[DB620_ITEM_NO] = new OpcValueImpl(opcServer, opcTagsList[DB620_ITEM_NO]); tag[DB620_CAST_NUM] = new OpcValueImpl(opcServer, opcTagsList[DB620_CAST_NUM]); tag[DB620_FURNACE_NUM] = new OpcValueImpl(opcServer, opcTagsList[DB620_FURNACE_NUM]); tag[DB620_MELT_ID] = new OpcValueImpl(opcServer, opcTagsList[DB620_MELT_ID]); foreach (var opcValueImpl in tag.Values) { // два тега активируем после всех, чтобы не пропустить данные, // так как будет ошибка, если они будут активированы впред всех. if (!opcValueImpl.Name.Equals(opcTagsList[DB601_NEW_BATCH_REQUEST]) && !opcValueImpl.Name.Equals(opcTagsList[DB620_DATA_READY])) { opcValueImpl.Activate(); } } tag[DB601_NEW_BATCH_REQUEST].IsListenValueChanging = true; tag[DB601_NEW_BATCH_REQUEST].SubscribeToValueChange(this); //tag[DB620_DATA_READY].IsListenValueChanging = true; //tag[DB620_DATA_READY].SubscribeToValueChange(this); tag[DB601_NEW_BATCH_REQUEST].Activate(); tag[DB620_DATA_READY].Activate(); packetChecker = new Timer(); packetChecker.Elapsed += CheckNewPacket; packetChecker.Interval = 10 * 1000; packetChecker.Start(); logger.Info("Инициализация завершена."); } finally { connectionHolder.ReleaseConnection(); } }