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

Is ObservableRegister broken? #82

Closed
pan-henryk opened this issue Jun 2, 2018 · 3 comments
Closed

Is ObservableRegister broken? #82

pan-henryk opened this issue Jun 2, 2018 · 3 comments

Comments

@pan-henryk
Copy link
Contributor

pan-henryk commented Jun 2, 2018

I am trying to detect changes in my slave image in a way similar to described here:
#64

My code looks like this:

`
SimpleProcessImage spi = new SimpleProcessImage(unitId);

               ObservableRegister or = new ObservableRegister();

                or.setValue(bb.getShort());

                or.addObserver(this);

                spi.setInputRegister(address,or);

`

I can read this register from master (so general setup is ok), but if I try to write to it, update method of observer is never called. At the message level slave receives write request and responds to it.
Is there a chance that slave refactoring broke it?

I am using Modbus TCP.

@steveohara
Copy link
Owner

Could well be.
Unfortunately we don't use this pattern at 4NG so it doesn't get a lot of love from us. If you could put together a unit test, I'll take a look at figuring out the problem.

@pan-henryk
Copy link
Contributor Author

pan-henryk commented Jun 8, 2018

After creating a simple test I was able to find the problem - it is a misleading naming inconsistency (probably be the same issue in my code).
In ProcessImage InputRegisters (F04) are added using addRegister function, while
HoldingRegisters (F03) are added using addInputRegister function.

Here is the test:
#85

@steveohara
Copy link
Owner

Test case added

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

No branches or pull requests

2 participants