private void _rpc_OnSystemVariableUpdated(RPCController sender, SystemVariable value) { if (_disposing) { return; } if (!SystemVariables.ContainsKey(value.Name)) { System.Diagnostics.Debug.Write("Position 1"); ReloadRequired?.Invoke(this, ReloadType.SystemVariables); return; } SystemVariable variable = SystemVariables[value.Name]; variable.SetValue(value); SystemVariableUpdated?.Invoke(this, variable); }
private void _rpc_InitCompleted(RPCController sender) { if (_disposing) { return; } if (Devices.Count == 0) { Reload(); } else { bool devicesDeleted = false; bool newDevices = false; List <Variable> updatedVariables = Devices.UpdateVariables(_rpc.GetAllValues(), out devicesDeleted, out newDevices); foreach (Variable variable in updatedVariables) { if (!Devices.ContainsKey(variable.PeerID)) { continue; } Device device = Devices[variable.PeerID]; if (!device.Channels.ContainsKey(variable.Channel)) { continue; } DeviceVariableUpdated?.Invoke(this, device, device.Channels[variable.Channel], variable, "HomegearLib.NET"); } bool systemVariablesAdded = false; bool systemVariablesDeleted = false; List <SystemVariable> updatedSystemVariables = SystemVariables.Update(out systemVariablesDeleted, out systemVariablesAdded); foreach (SystemVariable variable in updatedSystemVariables) { SystemVariableUpdated?.Invoke(this, variable); } if ((devicesDeleted || newDevices) && ReloadRequired != null) { ReloadRequired(this, ReloadType.Full); } else { if ((systemVariablesAdded || systemVariablesDeleted) && ReloadRequired != null) { System.Diagnostics.Debug.Write("Position 3"); ReloadRequired(this, ReloadType.SystemVariables); } foreach (KeyValuePair <long, Device> devicePair in Devices) { if (devicePair.Value.MetadataRequested) { bool variablesAdded = false; bool variablesDeleted = false; List <MetadataVariable> updatedMetadata = devicePair.Value.Metadata.Update(out variablesDeleted, out variablesAdded); foreach (MetadataVariable variable in updatedMetadata) { MetadataUpdated?.Invoke(this, devicePair.Value, variable); } if (variablesAdded || variablesDeleted) { DeviceReloadRequired?.Invoke(this, devicePair.Value, null, DeviceReloadType.Metadata); } } } } } }