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

Fix attribute datatypes in TIFF plugin #520

Merged
merged 4 commits into from
Nov 18, 2024
Merged

Fix attribute datatypes in TIFF plugin #520

merged 4 commits into from
Nov 18, 2024

Conversation

MarkRivers
Copy link
Member

This PR does 2 things:

  • Modifies myAttributeFunctions.cpp to generate attributes of all numeric datatypes. This allows thorough testing of the TIFF plugin and other applications that handle NDAttributes.
  • Fixes the TIFF plugin to handle all numeric attribute datatypes correctly. Signed and unsigned integers are handled separately. All integer types are converted to 64-bits before being converted to ASCII.

A new attribute XML file was added to simDetector to generate an instance of each attribute numeric datatype.
https://github.com/areaDetector/ADSimDetector/blob/master/iocs/simDetectorIOC/iocBoot/iocSimDetector/testAttributeDataTypes.xml

I tested ADSimDetector using that XML file.

I printed out the values of the NDArray attributes:

epics> asynReport 20 SIM1
SIM1 multiDevice:No canBlock:No autoConnect:Yes
    enabled:Yes connected:Yes numberConnects 1
    nDevices 0 nQueued 0 blocked:No
    asynManagerLock:No synchronousLock:No
    exceptionActive:No exceptionUsers 1 exceptionNotifys 0
    traceMask:0x1 traceIOMask:0x2 traceInfoMask:0x1
    interposeInterfaceList
        asynOctet pinterface 0x1827b20 drvPvt 0x38e6130
    interfaceList
        asynCommon pinterface 0x18262d0 drvPvt 0x38e2ec0
        asynDrvUser pinterface 0x1826060 drvPvt 0x38e2ec0
        asynOctet pinterface 0x18261a0 drvPvt 0x38e2ec0
        asynInt32 pinterface 0x18262a0 drvPvt 0x38e2ec0
        asynFloat64 pinterface 0x1826200 drvPvt 0x38e2ec0
        asynInt32Array pinterface 0x1826140 drvPvt 0x38e2ec0
        asynGenericPointer pinterface 0x18260c0 drvPvt 0x38e2ec0
Simulation detector SIM1
  NX, NY:            1920  1080
  Data type:         0
Port: SIM1
  Timestamp: 2024/11/14 17:27:36.075
  Input EOS[0]:
  Output EOS[0]:
Parameter list 0
Number of parameters is: 130
Parameter 0 type=string, name=PORT_NAME_SELF, value=SIM1, status=0
Parameter 1 type=string, name=ADCORE_VERSION, value=3.13.0, status=0
Parameter 2 type=string, name=DRIVER_VERSION, value=2.11.0, status=0
Parameter 3 type=string, name=MANUFACTURER, value=Simulated detector, status=0
...
SIM1: pArrays[0] report

NDArray  Array address=0x7f0140003810:
  ndims=2 dims=[1920 1080 ]
  dataType=0, dataSize=2073600, pData=0x7f013b41e010
  uniqueId=0, timeStamp=0.000000, epicsTS.secPastEpoch=0, epicsTS.nsec=0
  referenceCount=1
  number of attributes=11

NDAttributeList: address=0x7f01400039b0:
  number of attributes=11

NDAttribute, address=0x7f0140003a40:
  name=ColorMode
  description=Color mode
  source type=0
  source type string=NDAttrSourceDriver
  source=Driver
  dataType=NDAttrInt32
  value=0

NDAttribute, address=0x7f0140002540:
  name=Int8
  description=Int8 attribute
  source type=3
  source type string=NDAttrSourceFunct
  source=myAttrFunct1
  dataType=NDAttrInt8
  value=-8
  functAttribute
    functParam=INT8
    pFunction=0x702a50
    functionPvt=0x6557940

NDAttribute, address=0x7f01400023c0:
  name=UInt8
  description=UInt8 attribute
  source type=3
  source type string=NDAttrSourceFunct
  source=myAttrFunct1
  dataType=NDAttrUInt8
  value=8
  functAttribute
    functParam=UINT8
    pFunction=0x702a50
    functionPvt=0x6557960

NDAttribute, address=0x7f0140002240:
  name=Int16
  description=Int16 attribute
  source type=3
  source type string=NDAttrSourceFunct
  source=myAttrFunct1
  dataType=NDAttrInt16
  value=-16
  functAttribute
    functParam=INT16
    pFunction=0x702a50
    functionPvt=0x6557980

NDAttribute, address=0x7f0140003b70:
  name=UInt16
  description=UInt16 attribute
  source type=3
  source type string=NDAttrSourceFunct
  source=myAttrFunct1
  dataType=NDAttrUInt16
  value=16
  functAttribute
    functParam=UINT16
    pFunction=0x702a50
    functionPvt=0x65579a0

NDAttribute, address=0x7f0140003c70:
  name=Int32
  description=Int32 attribute
  source type=3
  source type string=NDAttrSourceFunct
  source=myAttrFunct1
  dataType=NDAttrInt32
  value=-32
  functAttribute
    functParam=INT32
    pFunction=0x702a50
    functionPvt=0x65579c0

NDAttribute, address=0x7f0140003d70:
  name=UInt32
  description=UInt32 attribute
  source type=3
  source type string=NDAttrSourceFunct
  source=myAttrFunct1
  dataType=NDAttrUInt32
  value=32
  functAttribute
    functParam=UINT32
    pFunction=0x702a50
    functionPvt=0x65579e0

NDAttribute, address=0x7f0140003e90:
  name=Int64
  description=Int64 attribute
  source type=3
  source type string=NDAttrSourceFunct
  source=myAttrFunct1
  dataType=NDAttrInt64
  value=-64
  functAttribute
    functParam=INT64
    pFunction=0x702a50
    functionPvt=0x6557a00

NDAttribute, address=0x7f0140003fb0:
  name=UInt64
  description=UInt64 attribute
  source type=3
  source type string=NDAttrSourceFunct
  source=myAttrFunct1
  dataType=NDAttrUInt64
  value=64
  functAttribute
    functParam=UINT64
    pFunction=0x702a50
    functionPvt=0x6557a20

NDAttribute, address=0x7f0140004100:
  name=Float32
  description=Float32 attribute
  source type=3
  source type string=NDAttrSourceFunct
  source=myAttrFunct1
  dataType=NDAttrFloat32
  value=32.000000
  functAttribute
    functParam=FLOAT32
    pFunction=0x702a50
    functionPvt=0x6557a40

NDAttribute, address=0x7f0140004280:
  name=Float64
  description=Float64 attribute
  source type=3
  source type string=NDAttrSourceFunct
  source=myAttrFunct1
  dataType=NDAttrFloat64
  value=64.000000
  functAttribute
    functParam=FLOAT64
    pFunction=0x702a50
    functionPvt=0x6557a60

The numeric attributes with names like Int8, UInt8, ... Float64 all have the correct data types and values.

I then saved a TIFF file, and ran tiffinfo on it:

(base) [epics@corvette data]$ tiffinfo test_006.tif
TIFFReadDirectory: Warning, Unknown field with tag 65000 (0xfde8) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65001 (0xfde9) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65002 (0xfdea) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65003 (0xfdeb) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65010 (0xfdf2) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65011 (0xfdf3) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65012 (0xfdf4) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65013 (0xfdf5) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65014 (0xfdf6) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65015 (0xfdf7) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65016 (0xfdf8) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65017 (0xfdf9) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65018 (0xfdfa) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65019 (0xfdfb) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 65020 (0xfdfc) encountered.
TIFF Directory at offset 0x1fa408 (2073608)
  Image Width: 1920 Image Length: 1080
  Bits/Sample: 8
  Sample Format: signed integer
  Compression Scheme: None
  Photometric Interpretation: min-is-black
  Samples/Pixel: 1
  Rows/Strip: 1080
  Planar Configuration: single image plane
  Make: Unknown
  Model: Unknown
  Software: EPICS areaDetector
  Tag 65000: 1100473830.931446
  Tag 65001: 35
  Tag 65002: 1100473830
  Tag 65003: 931445520
  Tag 65010: ColorMode:0
  Tag 65011: Int8:-8
  Tag 65012: UInt8:8
  Tag 65013: Int16:-16
  Tag 65014: UInt16:16
  Tag 65015: Int32:-32
  Tag 65016: UInt32:32
  Tag 65017: Int64:-64
  Tag 65018: UInt64:64
  Tag 65019: Float32:32.000000
  Tag 65020: Float64:64.000000

The values of all the numeric attribute datatypes are correct.

@MarkRivers
Copy link
Member Author

I suggest we use this PR rather than #518

@mp49
Copy link
Contributor

mp49 commented Nov 18, 2024

Hi Mark, thanks! I can test this today or tomorrow, and I'll post the results here.

@mp49
Copy link
Contributor

mp49 commented Nov 18, 2024

I've tested the patch and it seems to work.

Using the unpatched master branch I could reliably reproduce the problem in #519 (although strangely the first TIFF file written after an IOC reboot was always ok), and when I switched to this patched branch the issue was fixed.

@mp49
Copy link
Contributor

mp49 commented Nov 18, 2024

I'll delete my pull request

@MarkRivers MarkRivers merged commit 5b71539 into master Nov 18, 2024
14 checks passed
@MarkRivers MarkRivers deleted the fix_tiff_plugin branch November 18, 2024 20:47
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

Successfully merging this pull request may close these issues.

2 participants