Repository navigation
Feature/modulized generated devices parameters - #69
Draft
patrick-dmxc wants to merge 147 commits into
Draft
patrick-dmxc wants to merge 147 commits into
patrick-dmxc wants to merge 147 commits into
Conversation
Fix CHECK_TAG.json
Metadata - Load the built-in defines once (Lazy<Task>) and publish them only when complete, so the first parallel GetDefine no longer sees half-loaded metadata (DefineNotFoundException for DEVICE_INFO). - Build DefinedDataTreeObjects once via Lazy<>; the list was assigned empty and filled afterwards, so parallel first parses could not find their type. - Pass the exception as first argument to LogWarning/LogError (it was used as a format argument and got lost). - Add MetadataFactory.TryAddDefineFromJson: registers a define a device delivered as JSON. The JSON is untrusted: it has to fit the schema, the requested PID and the device's manufacturer, and the PID has to be manufacturer specific (0x8000-0xFFDF), so a device cannot redefine a standard parameter. A JSON define replaces one derived from PARAMETER_DESCRIPTION. METADATA_JSON - Add MetadataJsonModule (E1.37-5). Generated device: delivers its JSON defines. Remote device: registers the defines it receives in the MetadataFactory (also the ones the device model already holds) and requests the parameter once its define is known, because nothing requested it before. - Request METADATA_JSON for every manufacturer specific parameter in RDMDeviceModel (it was never requested). Stops when the device NACKs it. - Create the module in ModulesExtension. - Fix the title in RDMMetadataJson.ToString(). PeerToPeerProcess - Fail after 20 ACK_TIMER responses instead of polling QUEUED_MESSAGE forever (seen live: a node kept answering for UID 0000:00000000, more than 1000 requests in 3 minutes). Tests - Parallel first access of GetDefine, GetMetadataDefineVersions and GetDefinedDataTreeObjectType (fresh AssemblyLoadContext per round). - Bounded ACK_TIMER. - Runtime defines from PARAMETER_DESCRIPTION and JSON. - TestMetadataJsonModule (generated device and remote device). - PayloadTestTools.GetRequestData for GET requests with an index. - All manufacturer data in the new tests is invented (prototyping manufacturer 0x7FF0).
… transaction lock A request that gets no answer can mean two things: a device with a faulty implementation ignores a parameter it does not support (instead of a NACK with UNKNOWN_PID), or the device is too busy or not reachable. Both were handled the same way: a parameter without an answer in the first pass was never asked for again, and the model, which all devices of a model share, could be initialized without what it did not get. Requests without an answer - PeerToPeerProcess.TimedOut separates "no answer" from a NACK. - After a timeout the device is asked for DEVICE_INFO. An answer means the parameter is ignored: it is silent for this device. No answer means the device is not reachable or too busy: nothing is flagged, the request is asked for again after MissedRequestRetryInterval. - Only a parameter the device never answered can be silent. A parameter it answered before (an ACK or a NACK) is only missed after a lost answer, so one dropped request does not park a working parameter for 30 minutes. It is asked rarely after three misses in a row, and the model is told nothing. - SupportedParameterMetadata.IsSilent flags a parameter for the whole model, confirmed by a second device or by the same device the second time. Other devices of the model do not ask for it, and every device asks again now and then (SilentParameterRetryInterval). - The answer of any device withdraws what was reported about the parameter, not only the answer of the device that reported it. - An entry of a list that got no answer does not end the list any more; the model asks for it again a few times. Model initialization - The model is only initialized if SUPPORTED_PARAMETERS arrived (three attempts, then DEVICE_INFO decides: a device that answers it ignores the parameter and the model is initialized as before, one that does not answer leaves the model open for the next device). - Initialize uses the device that asks, not only the first one. Transaction lock - lockTransaktion returns whether the lock is held; a wait that timed out goes on without it and does not release it (that let two transactions run at once from then on). - The lock is released in a finally around the whole transaction. An exception of BeforeSendMessage or of the history handler left it held for good, every later request to the UID waited 7 s for it. - The semaphore of a UID is created with GetOrAdd. Tests - TestRemoteDeviceTimeouts, TestSilentParameters, TestTransactionLock, with GlobalTestSetup.DropRequest to simulate a device that does not answer and ShortTimeouts for short request timeouts.
…irst access PIDs without a define - A device can list an ESTA-range PID that has no define (a draft or reserved PID, seen on a real device: 0x7FD4). getDefine returned an InvalidOperationException for it, which GetDefine logged as an error. getDefine now returns null; GetDefine still throws a DefineNotFoundException for the ESTA range and returns null for a manufacturer specific PID without a define. - SupportedParametersExtension.TryGetParameterName and AbstractRemoteRDMDevice.requestParameter catch the DefineNotFoundException: the parameter gets its PID as name, and is treated as a parameter without a define instead of failing. - DataTreeBranch: a define without a C# type (e.g. a manufacturer define with several fields) returns no parsed object instead of throwing NotImplementedException internally; consumers fall back to the branch. ExtensionsManager - The instance is created with Lazy<T>, the first access can come from several threads at once (parallel device initialization). - The extensions (bytes parsers, supported parameters extensions, modules extensions) are loaded once under a lock, so other threads never see a partly filled dictionary. Tests - TestSupportedParameterMetadataLookup: an ESTA-range PID without a define gets metadata named after the PID. - TestDataTreeBranch: a define with several fields and no C# type is parsed without an internal exception.
…odules, add Slot.PrimarySlotId Value cache (AbstractRDMCache) - The value is stored first and one event is raised afterwards. Before, the events were raised inside the AddOrUpdate factories, which can run more than once when threads race, so an event could be raised twice or for a value that was not stored. - A parameter that is polled again with the same data is no change: no ParameterValueChanged. Before, every new object (a new boxed number, a new payload object, a new array) counted as a change, and an indexed value that was polled again without a change raised ParameterValueAdded. - ValuesEqual compares by value: payload objects by Equals, arrays and lists element by element. The check after a SET uses it as well (it compared references and could throw for an equal value). Modules - AbstractModule.ApplyCachedValues hands the values the device already has to ParameterChanged when the modules are created. A module is created after the device answered most of its parameters, and without this it only learned them when they changed. Slot - Slot.PrimarySlotId: the slot a secondary slot (fine, timing, ...) belongs to. For a secondary slot E1.20 SLOT_INFO puts the offset of its primary slot into the Slot Label ID field, not a category. Tests - TestParameterValueChangeDetection: same number, same payload object, same array and indexed values are no change; a new value is. - TestSlotPrimarySlot: the primary slot of a fine slot, parsed from SLOT_INFO data. - PayloadTestTools.GetResponseData builds GET response data with the parsers.
…that can not be built async void - An exception that escapes an async void method is rethrown on the thread pool and terminates the host application. The event handlers of the remote device (present timer, parameter update timer, device model initialized, parameter value added/changed) catch and log it now. - OnParentGeneratedDeviceChanged of CurveModule, LockModule, ModulationFrequencyModule, OutputResponseTimeModule, PresetsModule and PresetsModule_E1_37_1_2012 is no longer async void. The synchronous part (checking the configuration, setting the descriptions) runs at once, so a configuration error (e.g. a curve id used twice) reaches the code that creates the device instead of terminating the process. Only the setting of the initial value runs in the background, through the new AbstractModule.RunSafe, which logs an exception. - RealTimeClockModule sets the clock through RunSafe as well. Generated device - If the constructor fails, the device is unregistered from RequestReceivedEvent and its modules are disposed. Before, a device that could not be built stayed registered and answered requests (e.g. discovery). Remote device - When all data is pulled, the identity of the device is logged once (manufacturer, model, software, label, with model and software version ids), so a log entry with only the UID can be matched to a product. Tests - TestCurveModule: a curve id used twice throws at the caller.
…INT_RESPONDERS ACK Supported parameter metadata (ExtensionsManager) - A manufacturer extension only describes manufacturer specific parameters (0x8000 - 0xFFDF). Its name and update time are no longer used for an ESTA parameter: a default of a manufacturer extension replaced the update time of the standard (seen live: 10 min instead of 20 s for SENSOR_VALUE), depending on the order of a dictionary. - The extensions of a manufacturer are returned in a fixed order: the ESTA extensions first, then the others by key. The order of the dictionary is undefined, so which extension answered first could change between runs. Faulty responses that are still unambiguous - MetadataFactory.TryRepairPayload completes a faulty Payload from the request when its meaning is unambiguous; everything else that does not fit the define stays uninterpreted, as before. - E1.37-7 ENDPOINT_RESPONDERS: an ACK without Parameter Data (seen: a splitter for an endpoint without responders) is taken as "no responders" for the requested endpoint, with list change number 0. A truncated answer is still ignored. - PeerToPeerProcess tries the repair when the validation fails, and only for a response to its own request (not for a queued message); a repaired Payload is logged as debug instead of a warning. Tests - TestSupportedParameterMetadataPriority: an ESTA parameter keeps the update time of the standard (or none), a manufacturer specific one uses the extension, the ESTA extensions come first. - TestPeerToPeerProcessFaultyResponse: the empty ENDPOINT_RESPONDERS ACK is "no responders" of the requested endpoint, a truncated one stays ignored, the repair only applies to ENDPOINT_RESPONDERS with a request.
…ut a written module Generic modules (RDM/Device/Module/Generic) - GenericModuleFactory builds a module from the JSON define of a parameter if it is simple: a GET without request data and/or a SET, with one boolean, integer or string field. For an ESTA parameter only if no C# type is defined for it (then the device stores that object, not the raw value). Everything else (indexed, several fields, bytes, lists, a SET without data) still needs a module written for it. - GenericBooleanModule (with the labels for false and true), GenericNumericModule<T> (T is the type of the field, e.g. byte for uint8; minimum, maximum, unit, labels) and GenericStringModule (minimum and maximum length). An integer restricted to its labels becomes a GenericLabeledIntegerModule<T>, a choice; labels without the restriction only name special values of a number. - IGenericModule gives the parameter, the define and the supported command class, so an application can show the parameter and mark it as generic. - The module name holds manufacturer and PID (Generic_0x7FF0_0x9300): a manufacturer specific PID means something different for every manufacturer. Remote device - A generic module is added for every non-blueprint, not manufacturer internal supported parameter that no other module handles, when the modules are created and again when all data is pulled (a device can report parameters later, e.g. after its JSON defines arrived). The cached values are handed to the new modules. - Modules is a snapshot under a lock now: the list changes while the device is initialized. Tests - TestGenericModules: boolean, labeled integer, labels without the restriction, integer with a range, string, SET only, the defines that are not simple, ESTA parameters with and without a C# type. - TestMetadataJsonModule: a parameter described by METADATA_JSON gets a generic module with its value, a parameter with a written module does not.
…les by written ones Devices of one model share the model. While one device fills it, another device of the model can see an incomplete list of supported parameters and gets no modules for them (seen with two devices of the same model). Remote device - When all data is pulled, the modules are matched again and the missing ones are added. A module type the device already has is not created again, because a module can do something when it is created (e.g. send a SET). - A generic module is replaced by a written module that now handles its parameter; the generic one is disposed, the new modules get the cached values. Then the generic modules are added for what is still not covered. - The number of modules and supported parameters is logged as debug when the modules are created. ExtensionsManager - TryGetMatchingModules takes the module types that already exist and skips them. IGenericModule - DisplayName: the displayName of the define, else its name.
Add LSC Lighting Systems (Aust) Pty. Ltd. with manufacturer ID `0x4C73` to `EManufacturer`.
Add manufacturer identifiers to `EManufacturer` and update the LSC manufacturer description. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add manufacturer names and RDM identifiers to `EManufacturer`. Reorder existing entries without changing their identifiers or descriptions.
Probe device responsiveness after timeouts and stop retrying or querying manufacturer-specific parameters when ignored. - Track answered parameters and report silent ones. - Add regression coverage for ignored METADATA_JSON requests.
Several defines named their only or main field "state". The field name is what a generic module, a log and a DataTree show, so "state" said nothing about the value. The fields are named after their meaning now, and the C# types that are mapped to them by name follow: - IDENTIFY_DEVICE: identify - LAMP_STATE: lamp_state (ERDM_LampState) - POWER_STATE: power_state (ERDM_PowerState) - RESET_DEVICE: reset_type (ERDM_ResetType) - POWER_OFF_READY: ready - LOCK_STATE, LOCK_STATE_DESCRIPTION: lock_state (GetLockStateResponse, SetLockStateRequest, RDMLockStateDescription and the dependency of LOCK_STATE_DESCRIPTION on LOCK_STATE) - DISCOVERY_STATE: discovery_state (GetDiscoveryStateResponse, SetDiscoveryStateRequest) The Parameter Data does not change, only the names of the fields. Tests: the mock modules derive from AbstractParameterIDModule (renamed in the previous commit).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.