I need to do two things:
- Write register value
To set the register value, do I do it by setting a Capture Object on the ProfileGenericObject?
Using the addCaptureObject method?
- Set capture period to a meter for the register value to be written
Setting the capture method is clear I think and I believe I have set it the correct way with the code above?
To save this, I need to use the Capture method, right?
I used the capture method in the last step (# save) but it seems not to have done the work.
As attribute I gave pg.client, but possibly I didn't do this the correct way?
"The capture method will generate a message that asks meter to save current values for the buffer."
Is this a physical message that needs to be accepted?
I have a Mac so I sadly dont seem to be able to run GXDLMSDirector.
You don't write the register value. The meter does it. If the capture period is greater than zero, the meter will start automatically updating values that are defined in Capture objects.
Capture is an invoke and if you call it the current values are saved to the buffer.
Make sure that you have enough access rights to invoke the Cature.
I strongly advise that you search a Windows and play with GXDLMSDirector. It will help you to understand the DLMS meters.
I am aware that I can't write the register value - I was not very clear in my previous post.
What I meant is the following; that I want to write the Register object value in the buffer of a ProfileGeneric object.
I found a windows and played around with GXDLMSDirector.
I created a profile generic object (configurable) with Logical Name: 0.0.99.1.0.255
I added two Capture Objects: Clock (0.0.1.0.0.255) and an Extended Register (0.1.24.2.1.255).
I specified the Period: 900
And clicked on 'Capture'
It gave me a message: "action accomplished'.
It seems to have worked, so now I know it is possible, thanks!
However, the actions I took through the gxdlmsdirector follow the same logic as I tried to implement in the code I showed before.
Now I understand how to create / initialize a ProfileGeneric object, and how to set a CapturePeriod.
What I don't understand is how do add a Capture Object correctly to this Profile Generic object.
I did the following, Is this the way to do it?
#Add Capture Object
pg.addCaptureObject('0.1.24.2.1.255', 2, 0) #(pg is a Profile Generic Object initialized at the start)
After adding the Capture Object, I want to capture the values of this object.
I tried to capture these values with the Capture function through:
pg.capture(gp.client)
It requires a 'Client' parameter (as see in the docs). But I am not certain that this is the way to access the client correctly.
Other than that, I need to make sure that the newly set capture objects are saved to the meter, not only saving the values of the capture objects on the moment of the capture.
I understand there is a 'write' operation involved here, however I can't seem to find out how to do it
I tried to implement it this way:
You are adding the capture object correctly and you write it to the meter as expected. If you want to capture object values right away you can use the capture method of the profile generic object like this:
gp.readDataBlock(pg.capture(gp.client))
CapturePeriod is usually set to save values periodically.
Hi,
Hi,
You need to save the values after you set them.
For example, if you set capture period you need to write it to the meter using attribute #4.
http://www.gurux.fi/Gurux.DLMS.Objects.GXDLMSProfileGeneric
The capture method will generate a message that asks meter to save current values for the buffer.
I'll propose that you create this with GXDLMSDirector first so you can get an idea of what to do.
BR,
Mikko
Thanks for your response.
Thanks for your response.
What is not clear to me yet is the following.
I need to do two things:
- Write register value
To set the register value, do I do it by setting a Capture Object on the ProfileGenericObject?
Using the addCaptureObject method?
- Set capture period to a meter for the register value to be written
Setting the capture method is clear I think and I believe I have set it the correct way with the code above?
To save this, I need to use the Capture method, right?
I used the capture method in the last step (# save) but it seems not to have done the work.
As attribute I gave pg.client, but possibly I didn't do this the correct way?
"The capture method will generate a message that asks meter to save current values for the buffer."
Is this a physical message that needs to be accepted?
I have a Mac so I sadly dont seem to be able to run GXDLMSDirector.
Thanks again for your initial response
Hi,
Hi,
You don't write the register value. The meter does it. If the capture period is greater than zero, the meter will start automatically updating values that are defined in Capture objects.
Capture is an invoke and if you call it the current values are saved to the buffer.
Make sure that you have enough access rights to invoke the Cature.
I strongly advise that you search a Windows and play with GXDLMSDirector. It will help you to understand the DLMS meters.
BR,
Mikko
Thank you for your response,
Thank you for your response,
I am aware that I can't write the register value - I was not very clear in my previous post.
What I meant is the following; that I want to write the Register object value in the buffer of a ProfileGeneric object.
I found a windows and played around with GXDLMSDirector.
I created a profile generic object (configurable) with Logical Name: 0.0.99.1.0.255
I added two Capture Objects: Clock (0.0.1.0.0.255) and an Extended Register (0.1.24.2.1.255).
I specified the Period: 900
And clicked on 'Capture'
It gave me a message: "action accomplished'.
It seems to have worked, so now I know it is possible, thanks!
However, the actions I took through the gxdlmsdirector follow the same logic as I tried to implement in the code I showed before.
Now I understand how to create / initialize a ProfileGeneric object, and how to set a CapturePeriod.
What I don't understand is how do add a Capture Object correctly to this Profile Generic object.
I did the following, Is this the way to do it?
#Add Capture Object
pg.addCaptureObject('0.1.24.2.1.255', 2, 0) #(pg is a Profile Generic Object initialized at the start)
After adding the Capture Object, I want to capture the values of this object.
I tried to capture these values with the Capture function through:
pg.capture(gp.client)
It requires a 'Client' parameter (as see in the docs). But I am not certain that this is the way to access the client correctly.
Other than that, I need to make sure that the newly set capture objects are saved to the meter, not only saving the values of the capture objects on the moment of the capture.
I understand there is a 'write' operation involved here, however I can't seem to find out how to do it
I tried to implement it this way:
# Write capture objects
gp.reader.write(pg.captureObjects, 3)
gp.reader.write(pg.capturePeriod, 4)
________________________________________________________________________________________
My full code is this:
# Connect with meter (Authentication: LOW)
gp = reader.connect(row)
# Create ProfileGeneric object (=configurable profile)
pg = GXDLMSProfileGeneric(ln = '0.0.99.1.0.255')
# Set capture Period (900) = 15min
pg.capturePeriod = 900
# Add capture object (values of register '0.1.24.2.1.255' should be captured every 15 mins)
pg.addCaptureObject('0.1.24.2.1.255',2, 0)
# Capture method saves the new params
# pg.capture(gp.client)
# Write capture objects to meter
gp.reader.write(pg.captureObjects, 3)
gp.reader.write(pg.capturePeriod, 4)
Kind regards,
Jean-Baptiste
Hi Jean-Baptiste,
Hi Jean-Baptiste,
You are adding the capture object correctly and you write it to the meter as expected. If you want to capture object values right away you can use the capture method of the profile generic object like this:
gp.readDataBlock(pg.capture(gp.client))
CapturePeriod is usually set to save values periodically.
BR,
Mikko
Dear Mikko,
Dear Mikko,
Thanks again for the response.
Sadly, writing to the meter doesn't seem to work.
Following code:
# Write capture objects to meter
gp.reader.write(pg.captureObjects, 3)
Gives following error:
AttributeError("'list' object has no attribute 'getValue'",)
Apparently it seeks for a 'getValue' attribute but I cannot seem to be successful in passing the correct parameter.
When printing out following pg.captureObjects; I get:
[('0.1.24.2.1.255', <gurux_dlms.objects....128091cf8>)]
A list of tuples with first tuple the logical name of the register, and second tuple the Capture Objects.
When passing only the Capture objects; eg: pg.captureObjects[0][1] to the write function, I get following code and error:
code:
gp.reader.write(pg.captureObjects[0][1], 3)
error:
AttributeError("'CaptureObjects' object has no attribute 'getValue'",)
Any idea on what I could be missing? I feel like this is just the last step in a correct implementation
Kind regards,
Jean-Baptiste
Hi Jean-Baptiste,
Hi Jean-Baptiste,
You need to give the COSEM object as a parameter and use it like this:
gp.reader.write(pg, 3)
BR,
Mikko
Dear Mikko,
Dear Mikko,
Thanks! I got it to work.
Full code that works:
pg = GXDLMSProfileGeneric(ln = '0.0.99.1.1.255')
extended_register = GXDLMSExtendedRegister(ln = '0.1.24.2.1.255')
clock = GXDLMSClock()
pg.capturePeriod = 900
pg.addCaptureObject(clock, 2, 0)
pg.addCaptureObject(extended_register,2, 0)
gp.reader.write(pg, 4)
gp.reader.write(pg, 3)
Thanks again.
Kind regards