Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equipment transformation templates. #392

Open
vhirtham opened this issue Jul 5, 2021 · 4 comments
Open

Equipment transformation templates. #392

vhirtham opened this issue Jul 5, 2021 · 4 comments
Labels
feature new API features low priority low priority issues during ☕ measurements measurement and signal handling

Comments

@vhirtham
Copy link
Collaborator

vhirtham commented Jul 5, 2021

Let's say we have an AD converter with multiple connections and want to define it as MeasurementEquipment. We would have to create a separate DataTransformation for each connection, probably repeating a lot of code. Here is an example from the reference data repo:

current_AD_transform = msm.SignalTransformation(
    name="AD current conversion",
    func=current_AD_func,
    type_transformation="AD",
    error=msm.Error(Q_(0.01, "percent")),
)
voltage_AD_transform = msm.SignalTransformation(
    name="AD voltage conversion",
    func=voltage_AD_func,
    type_transformation="AD",
    error=msm.Error(Q_(0.01, "percent")),
)
BH_ELM = msm.MeasurementEquipment(
    name="Beckhoff ELM3002-0000",
    transformations=[current_AD_transform, voltage_AD_transform],
)

wouldn't it be nicer to have something like this:

AD_transform_template = SignalTransformationTemplate(
    func=current_AD_func,
    type_transformation="AD",
    error=msm.Error(Q_(0.01, "percent")),
)

BH_ELM = msm.MeasurementEquipment(
    name="Beckhoff ELM3002-0000",
    transformations=AD_transform_template.get(["AD current conversion", "AD voltage conversion"]),
)

However, there is still one little problem: Some pieces of equipment (like AD converters) can be used quite flexibly and are not tied to a current or voltage measurement. If we want to define our lab equipment just once in a database and just import the stuff we used in an experiment, it is probably better to store the template directly at the MeasurementEquipment and generate the DataTransformation dynamically when adding the equipment to the MeasurementChain.

The interfaces at the chain are already there. We just need to tweak the internals. So if we call:

welding_voltage_chain.add_transformation_from_equipment(
    equipment=BH_ELM, transformation_name="AD voltage conversion"
)

The measurement chain would see, that the BH_ELM has no transformation called "AD voltage conversion" and creates/adds it using the template. We might need to think of a solution if we have a more complex system, that can perform multiple operations and therefore can have multiple templates, but I think this is rare and for now, the current interfaces are sufficient.

@vhirtham vhirtham added feature new API features low priority low priority issues during ☕ measurements measurement and signal handling labels Jul 5, 2021
@marscher
Copy link
Collaborator

marscher commented Jul 5, 2021

This seems like a lot of effort for a use case which doesn't occur that often, right? I mean how often would you have exactly the same signal transformation setup?
I think if the setup code would be repetitive, one could just use a factory pattern to set it up.

@vhirtham
Copy link
Collaborator Author

vhirtham commented Jul 5, 2021

It is not that complicated and I guess it fits well with the approach of the subsystems in the CSM. The idea is to predefine all equipment and setups in your lab as much as possible so that writing an asdf file is mostly plug and play for the user.

@CagtayFabry
Copy link
Member

not sure if this is necessary

I am mostly concerned if identifying the transformations by name is a good approach, especially when merging multiple files
I would prefer linking to the objects (also for ASDF reasons)

@vhirtham
Copy link
Collaborator Author

vhirtham commented Jul 8, 2021

not sure if this is necessary

I am mostly concerned if identifying the transformations by name is a good approach, especially when merging multiple files
I would prefer linking to the objects (also for ASDF reasons)

Don't know if I understand your concerns correctly, but we are linking against objects, in asdf and python. You only need the transformations' name if you add it to the measurement chain from a piece of equipment that can have more than one transformation. The name is only used to link the objects inside the MeasurementChain by fetching the correct transformation from the MeasurementEquipment.

The point is to spare the user with writing 10 times the same transformation if he does 10 identical Temperature Measurements. Yes, he can write his own factory for this sort of thing but that doesn't work with pre-defined equipment except if he uses generic names like "AD conversion slot 01".

So what I am basically suggesting is, that the MeasurementEquipment can also get a factory for transformations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature new API features low priority low priority issues during ☕ measurements measurement and signal handling
Projects
None yet
Development

No branches or pull requests

3 participants