private bool RunDevice(DeviceRunContext context) { string path = GetDeviceConfigPath(context.DeviceName, context.Version); if (Directory.Exists(path)) { string deviceCfgFile = string.Format("{0}\\{1}", path, DeviceConfigFile); // TODO: Config file reading if (deviceCfgFile != null) { DeviceEntry entry = DeviceEntry.GetDeviceEntry(context.DeviceName, deviceCfgFile); this.CheckVirtualDevice(entry, deviceCfgFile); Device device = Load(entry); if (device != null) { context.Device = device; // Set thread-sync-context device.SynchronizationContext = context.SynchronizationContext; // Set data-received callback device.DataReceived += context.Callback; string address = this.GetCOMPort(entry); string deviceLoadedStr = string.Format("Device: '{0}' Loaded @ '{1}'", entry[DeviceEntry.Identity], address); RecordManager.DoSystemEventRecord(device, deviceLoadedStr); device.Start(address); return(true); } } } return(false); }
private void UpdateHpicThreshold() { string filePath = GetDeviceConfigFile("scada.hpic"); DeviceEntry entry = DeviceEntry.GetDeviceEntry("scada.hpic", filePath); Settings.Instance.HpicAlarm = (StringValue)entry["Alarm1"]; }
protected object Reset() { string deviceKey = this.GetDeviceKey(); Debug.Assert(deviceKey != null); string filePath = Program.GetDeviceConfigFile(deviceKey); DeviceEntry entry = DeviceEntry.GetDeviceEntry(deviceKey, filePath); object settings = this.BuildSettings(entry); this.UpdateSettings(settings); return(settings); }