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

pvtools rework #129

Merged
merged 5 commits into from Oct 31, 2018
Merged

pvtools rework #129

merged 5 commits into from Oct 31, 2018

Conversation

mdavidsaver
Copy link
Member

@mdavidsaver mdavidsaver commented Oct 2, 2018

Companion to epics-base/pvDataCPP#58 with changes to pvget et al. This is almost a rewrite. Net delta is

11 files changed, 833 insertions(+), 3437 deletions(-)

An incomplete list of feature changes:

  • Output options determined by PVStructure::stream().
  • New executables: pvmonitor and pvcall
  • Many arguments now ignored. -f is an error (arguments from file no longer supported).
    ** pvget: -q, -t, -i, -n, -F
    ** pvput: -n, -s, -F, -t
  • eget has been removed to https://github.com/epics-base/eget
  • pvcall makes -s and -a optional.
  • default pvRequest is always "field()".

@kasemir
Copy link
Collaborator

kasemir commented Oct 3, 2018

This includes / obsoletes #125

@kasemir
Copy link
Collaborator

kasemir commented Oct 30, 2018

With the last commit, pvinfo works.
Having a pvmonitor to go with pvget also sounds good since it eases the transition from caget and camonitor.

Also good is that the request defaults to getting all, so just pvget neutrons for a custom structure again succeeds as it did in the older V4 code, instead of failing as in base 7.0.1.1.

So overall, if this was a democracy, I'd vote for merging this.

@kasemir
Copy link
Collaborator

kasemir commented Oct 30, 2018

Just comments on behaviour.. Given this data:

$ pvinfo training:ai1
training:ai1 epics:nt/NTScalar:1.0
    double value
    alarm_t alarm..
    time_t timeStamp..
    display_t display..
    control_t control..
    valueAlarm_t valueAlarm...

.. the old pvget allowed fetching selected pieces. Now I always get the complete structure:

$ pvget -r 'control' training:ai1
training:ai1 2018-10-30T08:14:43.558 1 MAJOR DEVICE LOLO 

$ pvget -r 'field(control)' training:ai1
training:ai1 2018-10-30T08:14:45.561 3 MINOR DEVICE LOW 

$ pvget -r 'field(control)' -M raw training:ai1
training:ai1 epics:nt/NTScalar:1.0 
    double value 8
    alarm_t alarm MAJOR DEVICE HIHI 
        int severity 2
..
    valueAlarm_t valueAlarm
..
       int highAlarmSeverity 0
        double hysteresis 0

Maybe that's not an issue with pvget but actually caused by qsrv, since it works as expected with a custom data source:

$ pvinfo neutrons
neutrons structure
    time_t timeStamp
        long secondsPastEpoch
        int nanoseconds
        int userTag
    epics:nt/NTScalar:1.0 proton_charge
        double value
    epics:nt/NTScalarArray:1.0 time_of_flight
        uint[] value
    epics:nt/NTScalarArray:1.0 pixel
        uint[] value

$ pvget -r pixel neutrons
neutrons structure 
    epics:nt/NTScalarArray:1.0 pixel
        uint[] value [352030,352030,352030,352030,352030,352030,352030,352030,352030,352030]

$ pvget -r 'time_of_flight, pixel' -M raw neutrons
neutrons structure 
    epics:nt/NTScalarArray:1.0 time_of_flight
        uint[] value [36329,36329,36329,36329,36329,36329,36329,36329,36329,36329]
    epics:nt/NTScalarArray:1.0 pixel
        uint[] value [363290,363290,363290,363290,363290,363290,363290,363290,363290,363290]

@anjohnson
Copy link
Member

I recommend reading this comment on the Github website to see the proper formatting.

Format comparisons

caget

tux$ ./bin/linux-x86_64/caget anj:BaseVersion
anj:BaseVersion                7.0.1.2-DEV
tux$ ./bin/linux-x86_64/caget -a anj:BaseVersion
anj:BaseVersion                2018-10-30 12:08:47.001625 7.0.1.2-DEV  
tux$ ./bin/linux-x86_64/caget -t anj:BaseVersion
7.0.1.2-DEV

When not in terse mode (-t) PV names are displayed with a fixed minimum width of ~30 characters, which makes it easier to read when fetching multiple PVs at once. The caget timestamp format uses a space instead of a T between the date and the time (for humans to read so not strictly ISO-8601) and it shows fractional seconds to 6 decimal places.

Original pvget

tux$ ./bin/linux-x86_64/pvget anj:BaseVersion
anj:BaseVersion                7.0.1.2-DEV
tux$ ./bin/linux-x86_64/pvget -t anj:BaseVersion
7.0.1.2-DEV NO_ALARM NO_STATUS NO_ALARM 2018-10-30T12:08:47.002 0 0 0 EPICS Base Version   0 0 0
tux$ ./bin/linux-x86_64/pvget -v anj:BaseVersion
anj:BaseVersion
epics:nt/NTScalar:1.0 
    string value 7.0.1.2-DEV
    alarm_t alarm NO_ALARM NO_STATUS NO_ALARM
    time_t timeStamp 2018-10-30T12:08:47.002 0
    display_t display
        double limitLow 0
        double limitHigh 0
        string description EPICS Base Version
        string format 
        string units 
    control_t control
        double limitLow 0
        double limitHigh 0
        double minStep 0


With no formatting options PV names are displayed with a fixed minimum width of ~30 characters, which makes it easier to read when fetching multiple PVs at once. The pvget timestamp format is ISO-8601 and shows fractional seconds to 3 decimal places.

Original pvget -p ca

tux$ ./bin/linux-x86_64/pvget -p ca anj:BaseVersion
anj:BaseVersion                7.0.1.2-DEV
tux$ ./bin/linux-x86_64/pvget -p ca -t anj:BaseVersion
7.0.1.2-DEV NO_ALARM NO_STATUS <no message> 2018-10-30T12:08:47.002 0
tux$ ./bin/linux-x86_64/pvget -p ca -v anj:BaseVersion
anj:BaseVersion
structure 
    string value 7.0.1.2-DEV
    alarm_t alarm NO_ALARM NO_STATUS <no message>
    time_t timeStamp 2018-10-30T12:08:47.002 0


A no-alarm message is different between the ca and pv providers, <no message> vs. NO_ALARM. This may be an issue with caProvider.

New pvget

tux$ ./bin/linux-x86_64/pvget anj:BaseVersion
anj:BaseVersion 2018-10-30T12:08:47.002 7.0.1.2-DEV 
tux$ ./bin/linux-x86_64/pvget -M json anj:BaseVersion
anj:BaseVersion {"value": "7.0.1.2-DEV","alarm": {"severity": 0,"status": 0,"message": "NO_ALARM"},"timeStamp": {"secondsPastEpoch": 1540919327,"nanoseconds": 1624623,"userTag": 0},"display": {"limitLow": 0,"limitHigh": 0,"description": "EPICS Base Version","format": "","units": ""},"control": {"limitLow": 0,"limitHigh": 0,"minStep": 0}}
tux$ ./bin/linux-x86_64/pvget -M raw anj:BaseVersion
anj:BaseVersion epics:nt/NTScalar:1.0 
    string value 7.0.1.2-DEV
    alarm_t alarm 
        int severity 0
        int status 0
        string message NO_ALARM
    time_t timeStamp 2018-10-30T12:08:47.002 
        long secondsPastEpoch 1540919327
        int nanoseconds 1624623
        int userTag 0
    display_t display
        double limitLow 0
        double limitHigh 0
        string description EPICS Base Version
        string format 
        string units 
    control_t control
        double limitLow 0
        double limitHigh 0
        double minStep 0

With no formatting options only one space separates the PV names from their values, so it's a bit harder to identify where the value starts when fetching many PVs at once. We always get a timestamp that wasn't present with the older tools (not a problem, just pointing out the difference). I like the new -M json option. The blank lines at the end of the 'raw' output format have been removed (good).

New pvget -p ca

tux$ ./bin/linux-x86_64/pvget -p ca anj:BaseVersion
Segmentation fault

Oops! I had built pvAccessCPP here by merging your branch into the latest 7.0. The seg-fault is in Marty's update to the caProvider so I will take a look at it.

@mdavidsaver
Copy link
Member Author

With no formatting options only one space separates the PV names from their values

Try with multiple PV names. Values are indented based on the longest PV name, rather than a fixed 30 characters. (I've had to deal with too many really long PV names)

so it's a bit harder to identify where the value starts

What would you have? 2 spaces? 4?

The caget timestamp format uses a space instead of a T between the date and the time

Doesn't bother me one way or the other. If you care enough, you can change this after epics-base/pvDataCPP#58 is merged (in printer.cpp).

@anjohnson
Copy link
Member

Try with multiple PV names.

My bad, yours is obviously an improvement, I should have actually tried it instead of assuming:

tux$ ./bin/linux-x86_64/pvget anj:BaseVersion anj:exit
anj:BaseVersion 2018-10-30T12:08:47.002 7.0.1.2-DEV 
anj:exit        <undefined> 0 INVALID DRIVER UDF 

How about using a fixed width for the timestamp field though? The values don't line up when an <undefined> timestamp is included. Something like this could be even easier on the eyes:

anj:BaseVersion 2018-10-30T12:08:47.002 7.0.1.2-DEV 
anj:exit                    <undefined> 0 INVALID DRIVER UDF 

The other thing that I would still like to see is some kind of terse mode, which for caget prints just the addressed field value with no decorations or metadata. If we don't provide something close to that our users are going to complain about having to strip off all this other stuff that they don't want (PV name, timestamp, alarm status etc.). At least the old pvget's terse mode outputs the value first so it's easily extracted.

There's only so much pushing that we can do to get users to write clients in higher level languages, and in the APS case our physicists will probably be writing tcl/tk for some time to come and thus calling out to someone's pvget client (I'd much rather they use ours than write their own).

@gregoryraymondwhite
Copy link

gregoryraymondwhite commented Oct 30, 2018 via email

@mdavidsaver
Copy link
Member Author

How about using a fixed width for the timestamp field though?

Can we move this thread over to epics-base/pvDataCPP#58 ? This is where the relevant code is anyway.

@anjohnson
Copy link
Member

@gregoryraymondwhite Re your point 9, would JSON be an acceptable syntax? Take a look at the Suggestions section towards the bottom of this document to see what it might look like. That we can do relatively easily, but making big changes to how pvRequest works would be a major undertaking that could require rewriting existing servers.

@mdavidsaver
Copy link
Member Author

In particular, what about "-a arg argvalue”? Would -a and RPC be integrated into pvget pvput?

Along with pvmonitor there is a new executable pvcall which takes over the core role of eget -s. Though both the -s and -a are now optional.

$ ./bin/linux-x86_64/pvcall -h

Usage: pvcall [options] <PV name> [<arg1>=<value>]...


options:
  -h: Help: Print this message
  -V: Print version and exit
  -s <service name>:   legacy form of PV name
  -a <service arg>:    legacy form of argument
  -r <pv request>:   Request, specifies what fields to return and options, default is ''
  -w <sec>:          Wait time, specifies timeout, default is 5.000000 seconds for get, inf. for monitor
  -p <provider>:     Set default provider name, default is 'pva'
  -M <raw|nt|json>:  Output mode.  default is 'nt'
  -v:                Show entire structure (implies Raw mode)
  -d:                Enable debug output
 deprecated options:
  -q, -t, -i, -n, -F: ignored
  -f <input file>:   errors

example: pvcall pv:name:add lhs=1 rhs=2

@mdavidsaver
Copy link
Member Author

In summary, we just need:

"just"?

What about direct addressing? Is that staying in the API?

No. Remember that I didn't even know this worked until Wednesday. These sort of features may be re-added in future along with test coverage!

  1. Fix pvlist. Make it so qSrv can list the pvs of an IOC trivially

This at least is already done.

Later in the financial year I can help fund this I think

I look forward to this. Right now though, I have to proceed on the basis of available funding ($0). With this level of support, I can only work on pvget et. al incidentally. This limits their scope to the low level troubleshooting tools I need them to be.

@mdavidsaver
Copy link
Member Author

@gregoryraymondwhite

I should also point out that, as with pvput, it will be possible to send arrays and structures as RPC arguments. Quoting will naturally be a pain in non-trivial situations, but hey there is only so much I can do.

pvcall pv:blah 'myarr=[1,2,3]' 'mystr={"sub":4}'

@mdavidsaver
Copy link
Member Author

I've merged epics-base/pvDataCPP#52 and created a new home for eget at https://github.com/epics-base/eget

I'm going to wait until tomorrow morning before a merging this PR.

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

Successfully merging this pull request may close these issues.

None yet

4 participants