public IPCValue RegisterAddress(string address, string group, bool persistent = false) { IPCValue value = null; try { if (!IPCTools.IsReadAddress(address)) { Log.Logger.Error($"RegisterValue: Not an Read-Address! [{address}]"); return(value); } if (currentValues.ContainsKey(address)) { value = currentValues[address]; currentRegistrations[address]++; Log.Logger.Debug($"RegisterValue: Added Registration for Address {address}, Registrations: {currentRegistrations[address]}"); } else { if (IPCTools.rxOffset.IsMatch(address)) { value = new IPCValueOffset(address, group); } else { value = new IPCValueLvar(address); } currentValues.Add(address, value); currentRegistrations.Add(address, 1); if (persistent) { persistentValues.Add(address); } Log.Logger.Debug($"RegisterValue: Added Address {address}, Persistent: {persistent}"); } } catch { Log.Logger.Error($"RegisterValue: Exception while registering Address {address}"); } if (value == null) { Log.Logger.Error($"RegisterValue: Null Reference for Address {address}"); } return(value); }
protected bool UpdateIPC(string id, string newAddress) { if (managedValues[id].Key != newAddress) { ipcManager.DeregisterAddress(managedValues[id].Key); IPCValue value = ipcManager.RegisterAddress(newAddress, AppSettings.groupStringRead); if (value != null) { Log.Logger.Debug($"UpdateIPC: Updated Variable {id} with new Address {newAddress}. (Old: {managedValues[id].Key}"); managedValues[id] = new ValuePair(newAddress, value); return(true); } else { Log.Logger.Error($"UpdateIPC: Udapte for Variable {id} failed! The new Address {newAddress} could not be registered!"); } } return(false); }
public bool RegisterValue(string id, string address) { IPCValue value = ipcManager.RegisterAddress(address, AppSettings.groupStringRead); if (value != null) { if (!managedValues.ContainsKey(id)) { managedValues.Add(id, new ValuePair(address, value)); return(true); } else { Log.Logger.Error($"RegisterValue: Variable {id} already exists!"); } } else { Log.Logger.Error($"RegisterValue: Could not Register Address {address} for Variable {id}!"); } return(false); }