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

Delay block? #18

Closed
pjadzinsky opened this issue Jan 8, 2019 · 2 comments
Closed

Delay block? #18

pjadzinsky opened this issue Jan 8, 2019 · 2 comments

Comments

@pjadzinsky
Copy link

Hi, I just discovered BMS and I'm trying to figure out if this (which looks great) will be useful to me as is.
I would need a 'delay' block. For example if I have signal A and B, I want to sum them but the 'sum' is actually summarizing a real process that actually tokes some time (is not like adding two electrical currents but actually doing some work). Therefore I would like to 'delay' the sum.

As I see it one option is to add a 'delay' block. Another approach is to just add a 'delay' option to some basic blocks (which might default to 0). What are your ideas? Maybe I'm missing something and this is already implemented? If not, if you suggest best approach that fits your philosophy I might be able to submit a PR.

Thanks

@masfaraud
Copy link
Owner

masfaraud commented Jan 14, 2019

Hi,

I think the best idea is to implement a delay block with one input and one output.
First you need to create your DelayBlock by subclassing the Block class, you will need to redefine some methods (see some examples https://github.com/masfaraud/BMSpy/blob/master/bms/blocks/continuous.py), in particular the Evaluate method that give output values of the block at a given iteration it with timestep ts.
In the Gain block, the Evaluate method calls the InputValues method. You should not use it for your block because it will give you only a fixed number of previous values of the input variable. You should take them manually in the attribute _values of your input variable.
Maybe you'll miss a method in the Variable to have the value of a variable at a given time (an interpolation of the _values attribute vector). I have implemented it in DynamicSystem.VariableValues, there is maybe something to rethink there.

Don't hesitate if you have further questions. I am waiting for the PR then :)

@masfaraud
Copy link
Owner

Merge the PR #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants