private void _rpc_OnEventDeleted(RPCController sender, string id, EventType type, long peerId, long channelIndex, string variable) { if (type == EventType.Timed) { if (ReloadRequired != null) { ReloadRequired(this, ReloadType.Events); } } else { if (!Devices.ContainsKey(peerId)) { return; } Device device = Devices[peerId]; if (!device.Channels.ContainsKey(channelIndex)) { return; } Channel channel = device.Channels[channelIndex]; DeviceReloadRequired?.Invoke(this, device, channel, DeviceReloadType.Events); } }
private void _rpc_OnUpdateDevice(RPCController sender, long peerId, long channelIndex, RPCUpdateDeviceFlags flags) { if (!Devices.ContainsKey(peerId)) { return; } Device device = Devices[peerId]; if (!device.Channels.ContainsKey(channelIndex)) { return; } Channel channel = device.Channels[channelIndex]; if (flags == RPCUpdateDeviceFlags.rpcConfig) { List <ConfigParameter> changedParameters = channel.Config.Reload(); foreach (ConfigParameter parameter in changedParameters) { if (DeviceConfigParameterUpdated != null) { DeviceConfigParameterUpdated(this, device, channel, parameter); } } foreach (KeyValuePair <long, ReadOnlyDictionary <long, Link> > remotePeer in channel.Links) { foreach (KeyValuePair <long, Link> linkPair in remotePeer.Value) { changedParameters = linkPair.Value.Config.Reload(); foreach (ConfigParameter parameter in changedParameters) { if (DeviceLinkConfigParameterUpdated != null) { DeviceLinkConfigParameterUpdated(this, device, channel, linkPair.Value, parameter); } } } } } else if (flags == RPCUpdateDeviceFlags.rpcTeam) { DeviceReloadRequired?.Invoke(this, device, channel, DeviceReloadType.Team); } else { DeviceReloadRequired?.Invoke(this, device, channel, DeviceReloadType.Links); } }
private void _rpc_OnMetadataDeleted(RPCController sender, long peerId) { if (_disposing) { return; } if (!Devices.ContainsKey(peerId)) { return; } Device device = Devices[peerId]; DeviceReloadRequired?.Invoke(this, device, null, DeviceReloadType.Metadata); }
private void _rpc_OnMetadataUpdated(RPCController sender, long peerId, MetadataVariable value) { if (_disposing) { return; } if (!Devices.ContainsKey(peerId)) { ReloadRequired?.Invoke(this, ReloadType.Full); return; } Device device = Devices[peerId]; if (!device.Metadata.ContainsKey(value.Name)) { DeviceReloadRequired?.Invoke(this, device, null, DeviceReloadType.Metadata); return; } MetadataVariable variable = device.Metadata[value.Name]; variable.SetValue(value); MetadataUpdated?.Invoke(this, device, 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); } } } } } }