# Genie 2000 Programming Library

by dos
Tags: 2000, genie, library, programming
 P: 1 Hi everybody! I read in a document of Canberra saying that:" Genie 2000 Program Library allows a programmer to interact directly with Genie 2000 capabilities from a C++ language environment and also allows the addition of user-coded analysis engines to the Genie 2000 environment". If someone know about this issue, please help me!
 P: n/a I have used Genie's internal language to create reports, and used the REXX language to interface to Genie to do more things. Both options are very weak, limited and slow. Currently I interface to Genie executable modules using Java. This method provides great power, as much as is possible with the existing executables in the EXEFILES folder plus processing the data and reporting and inteface to Excel using Java. You could do just the same with C++. It is quite a bit of work however. I am not aware of any special custom interface techniques that Canberra has published concerning Genie with C++ however.
 P: 3 ChrisLeslie, You said you have written an interface in Java for Genie functions. This is exactly what I need now. Would you consider help in the project? So we can work together? I have 4 years experience in Java , see my project at radlab.sourceforge.net If you are finished, is your codes open source? Would you share them? Dagistan
P: 6

## Genie 2000 Programming Library

 Quote by dagistan You said you have written an interface in Java for Genie functions. This is exactly what I need now. Would you consider help in the project? So we can work together? I have 4 years experience in Java , see my project at radlab.sourceforge.net If you are finished, is your codes open source? Would you share them? Dagistan
What are you interested in doing? I have not done Java, but I have written some software in C++ to control a multi-channel analyzer through Genie 2000. It was for-pay contract, so I cannot show you the source, but I might be able to answer some questions. I started writing a document about programming the Genie 2000 in C++ for my own use at one point, but it is pretty incomplete. I can see if I can find it if you are interested...

It was a pain to get started, because all of the Canberra documentation assumes you are using Visual Basic and know COM pretty well. Figuring out which parameters to set and which calls set them was also a problem. If you are pretty familiar with the Genie 2000 software already, getting it to work might be easier for you.

Bill.
 P: 3 Hi Bill, Thank you very much for your reply. I am doing PhD at PSU. I am doing NAA analysis for wood rings. So I need to write a code to control the sample changer we have, save the spectrums and then make the analysis, and write the results into files. With lots o effort, because of Genie documentation, as you said, I have used C++ , and finally managed to save the spectrum and move the sample changer. However it seems like the analysis will take more time. By the way I started with the example provided in Genie 2000 3.1 I have still questions about current parts; 1-) I could not find any way to learn whether the spectrum is completed, 2-) No way to get info whether sample changer came to home position. 3-) No idea how to start the analysis part So I now C++, and can use it. But the Genie does not have a clear api, and documentation. I really need help with analysis. Energy calibration, peak search, nuclide identification, interference correction, efficiency correction and then calculate the mass of each isotope in the sample. Thank you again for your reply and help. We might together finish the documentation if you are interested in open source development. We can then put this into sourceforge.net . I have another project called RADlab at sourceforge.net , at http://radlab.sourceforge.net/ , which is open source. Dagistan
P: 6
Dagistan,

 Quote by dagistan I have still questions about current parts; 1-) I could not find any way to learn whether the spectrum is completed,
Assuming your device access object is called devAccess, then you can poll the device status like this:

HRESULT hr;
enum DeviceAcces::DeviceStatus status;
bool acquiring;

hr = devAccess->get_AnalyzerStatus(&status);
acquiring = ((status & DeviceAccess::aAcquiring) != 0);
The call to get_AnalyzerStatus, gets the current analyzer status. If the aAcquiring bit is set, the the acquisition is not complete. The bitwise AND of status and DeviceAccess::aAcquiring masks off the other bits, making acquiring true when the analyzer is still acquiring data and false when it is done.

The manual lists AnalyzerStatus as a property in the DeviceAccess chapter. Any of the properties can be read by prepending get_ to them.

 Quote by dagistan 2-) No way to get info whether sample changer came to home position.
I have not used the sample changer. If there is not a property for getting its status, the perhaps one of the hundreds of parameters listed in the CAM Files chapter will tell you the sample changer status. If there is a parameter, then you can use get_Param, much like get_AnalyzerStatus above.

The parameter descriptions are not really informative, but in most cases I have been able to narrow down the number of parameters to no more than about a dozen or so. Then I write a program that prints out their values to see which one is most likely to be the one I want. I realize this approach is less than ideal, but in many cases the documentation does not give enough information to sure you are looking at the right parameter without testing it first.

 Quote by dagistan 3-) No idea how to start the analysis part
I spent about long time trying to figure out how to do analysis using at least three different approaches. The only way I could get it to work is by using the SequenceAnalysis module. Basically, you have to create a .ASF file using the Gamma Analysis and Acquisition program or the Analysis Sequence Editor program. There is documentation on how to do this in the Genie Operations Manual, and you can test your sequence by running in the Gamma Analysis and Acquisition program to verify that it does what you want.

Once you have a .ASF file, you need to create a sequence analyzer object and call your sequence with it:

ISequenceAnalyzerPtr seqAn;

hr = seqAn.CreateInstance(__uuidof(SequenceAnalyzer));
/* check hr for failure */

short step = 0;
hr = seqAn->Analyze(dataAccess, &step, bsName, VARIANT_FALSE,
VARIANT_FALSE, VARIANT_FALSE, VARIANT_FALSE, NULL, NULL);
/* check hr for failure */
In my code dataAccess is a DataAccess object associated with a CAM file being analyzed. You might be able to directly pass in a DeviceAccess object, too, but I have not tried it. The bsName parameter is a BSTR object containing the name of the .ASF file to use.

After this code sequence, step will contain the step number of the last step executed, hopefully the last step in your sequence. You probably have to read some parameters with get_Param to read the right parameters to get the result you want.

 Quote by dagistan So I now C++, and can use it. But the Genie does not have a clear api, and documentation. I really need help with analysis. Energy calibration, peak search, nuclide identification, interference correction, efficiency correction and then calculate the mass of each isotope in the sample. Thank you again for your reply and help. We might together finish the documentation if you are interested in open source development. We can then put this into sourceforge.net . I have another project called RADlab at sourceforge.net , at http://radlab.sourceforge.net/ , which is open source. Dagistan
After looking at my documentation again, I am a little embarrassed to say that it is not quite as far a long as I had remembered. Basically, it is a bunch of notes that no one but me is likely to understand. I'll try to flesh out what I have and then maybe we can start adding different sections (and anyone else who might be out there is welcome to join).

I am probably not going to have a lot of time to work on it this week, though. Bug me in a few weeks if you have not heard anything from me. Or post a reply here sooner if you have questions on my replies above.

Bill.
 P: 1 Hi, I used to work for Canberra and can help you with cam parameters. I don't do java, you are on your own for that stuff. I need to do a simple procedure to do some acquisition and reports. I'll probably use rexx. I wanted to use vb and was looking for script information. I may try calling the exes, a good idea. I can launch them from vb. I've written a lot of command procedures with rexx and much more with the vms side of things, which, while different, shares the cam structure. Rich Hume
P: 6
Hello,

 Quote by RichHume Hi, I used to work for Canberra and can help you with cam parameters. I don't do java, you are on your own for that stuff.
I found the last set of CAM parameters I needed, but I'll definitely hit you up next time I get stuck.

 Quote by RichHume Hi, I need to do a simple procedure to do some acquisition and reports. I'll probably use rexx. I wanted to use vb and was looking for script information. I may try calling the exes, a good idea. I can launch them from vb. I've written a lot of command procedures with rexx and much more with the vms side of things, which, while different, shares the cam structure. Rich Hume
The Genie Programming Library manual gives all of its examples as Visual Basic. It might be easier to control the acquisition through a DeviceAccess object. OTOH, if you are already familiar with using the REXX commands that might be easier for you. According to the operations manual there is a way to use REXX under Windows, but I have never done it.

I have been doing all of my development in C++, so I don't any experience with VB or REXX.

Bill.
 P: 6 This is not really a question about CAM parameters, but do you know how to find the names of detectors that are loaded into the database (that is, the detectors that would appear in the Open Datasource... dialog)? I want to enumerate them for a detector selection widget I am building... Bill.
 P: 1 Hi, I also try to automate some calculations using the Programming Library. I managed to define and run an analysis sequences (I'm using the C# library by the way). However some parameters (i.e. the geometry) is depending on the user input. In other words, the efficiency correction has to be based upon a geometry which is constructed at runtime. Does anyone has experience with this? I tried to construct a .gis file dynamically and run the command winisocs to obtain the ecc file. However, the ISOCS efficiency correction step in the analysis sequence takes a .geo file. Kind regards
 P: 3 Hi Everybody, I was trying to change sample information from my code. did anybody found how to change sample buildup type? I could not find the CAM code for this one. Thanks Dagistan
 P: 1 Hello everybody! I have the following problem.... We have a ginie 2000 System that works great. We use an old samplechanger system that relies upon relays which are starting to act strange and unpredictable. So we dicided to get rid of the relays instead using a Labview environment to control the actuators. So I need some advice how to implement the genie 2000 system into Labview, meaning that labview should tell Genie when to start a measurement and genie to send the information that it has finished the measurement back. An API would be useful, but as I understood it there is no such thing or something compareable to use in Labview... Please Help!!! Does anyone have a suggestion or maybe have already solved a similar problem? Sincerly, Einphysiker
 P: 3 Hi, Who can give information about the file structure of CAM-files. I can read spectral data, live time, realtime and some ascii parameters from the file, but I cannot find the energy calibration values (float, double or any other format ???). I really tried hard to find the addresses of these values in then cnf-file with an Hex editor but there was no success.
 P: 4 Hi RSachse, can you please tell me, where did you get real-time and live-time values? I have found some values in cnf file that might be them. I know decimal values of numbers that i'm looking for, but they are completly different :(
 P: 4 Nevermind, i just figured out how to get them :D Now i'm trying to find calibration values... i'll tell you if i'll find something useful :D
 P: 3 Hi 0x0000eWan, sorry I am late, but I was on hollydays here my VBA-code for reading CNF-files (Alpha-Analyst spectra): ******** Sub ReadCNF(sfile as string) dim spek(1024) as long Dim c8 As Currency '8 byte with LSB first Dim dreal As Double Dim dlive As Double Dim dpreset As Double Dim inchan As Integer Dim sUnit As String * 64 Dim sDet As String * 20 Dim sChTitel As String Dim ssample As String Dim fr as integer Dim r As Single Dim rzero As Single Dim rx As Single Dim rx2 As Single Dim rx3 As Single Dim sampletitle As String * 16 Dim sampleID As String * 16 Dim sample As String * 16 Dim sdescr As String * 64 fr=4000 'factor for calibration values ??? fi = FreeFile Open sfile For Binary As fi Get #fi, 2256, c8: dpreset = ((Not c8) + 1) / 1000: Cells(11, 2) = dpreset Get #fi, 2904, r: rzero = r / fr: If rzero <= 0 Then rzero = 2.5 Cells(13, 2) = rzero Get #fi, , r: rx = r / fr: Cells(13, 3) = rx Get #fi, , r: rx2 = r / fr: Cells(13, 4) = rx2 Get #fi, , r: rx3 = r / fr: Cells(13, 5) = rx3 Get #fi, 2622, c8: dlive = ((Not c8) + 1) / 1000: Cells(9, 2) = dlive 'livetime in msec Get #fi, 2630, c8: dreal = ((Not c8) + 1) / 1000: Cells(10, 2) = dreal 'realtime in msec Get #fi, 2930, sUnit 'MeV Get #fi, 2951, inchan 'channels Get #fi, 3102, sDet: Cells(7, 2) = sDet 'detector name Get #fi, 21553, sampletitle: Cells(5, 6) = sampletitle 'title Get #fi, 21617, sampleID: Cells(6, 6) = sampleID 'sample ID Get #fi, 22382, sample: Cells(7, 6) = sample 'sample Get #fi, 22447, sdescr: Cells(8, 6) = sdescr 'sample description 1 Get #fi, 22511, sdescr: Cells(9, 6) = sdescr 'sample description 2 Get #fi, 22575, sdescr: Cells(10, 6) = sdescr 'sample description 3 Seek #fi, 30209 'offset Spectrum data Get #fi, , spek Close fi For i = 1 To 1024 'insert in cells ze = 15 + i Cells(ze, 1) = i 'kanal Cells(ze, 2) = rzero + i * rx + i * rx2 ^ 2 'MeV Cells(ze, 3) = spek(i) 'l4 'counts Next i end sub ************ if you send me one of your specs I can have a look on it. best regards
P: 4
Hi,
I've finished processing cnf files. It's working fine for new version cnf files, but in old version ones, there are issues with realtime, livetime, dates and calibration values. It's easy to change code to work with old cnf files, but i wanna my app to be universal and can be used for both kinds of cnf files. I didn't figured out how to clearly determine which file is old and which is new, but I'm working on it ;) I'm sending you my code written in Delphi. It's quite messy because i used it only for testing and then rewrote it to another app, but i hope it will help you. I'll send updated version when I complete it.
Attached Files
 cnf.zip (6.0 KB, 25 views)
P: 2
 Quote by 0x0000eWan Hi, I've finished processing cnf files. It's working fine for new version cnf files, but in old version ones, there are issues with realtime, livetime, dates and calibration values. It's easy to change code to work with old cnf files, but i wanna my app to be universal and can be used for both kinds of cnf files. I didn't figured out how to clearly determine which file is old and which is new, but I'm working on it ;) I'm sending you my code written in Delphi. It's quite messy because i used it only for testing and then rewrote it to another app, but i hope it will help you. I'll send updated version when I complete it.
There are no "old" and "new" versions of the CAM (cnf) file format, there is only one and it is quite old. What is happening is that you are relying on fixed offsets to read parameters, spectral data, etc. and CAM files are much more complex than that. They have a filesystem-like structure, with "directories" to locate parameters, spectral (or any other) data, as well as an allocation bitmap and some other stuff. Neither the spectrum nor the parameters are at a fixed address, and neither they have to be contiguous inside the file (most of the time, for example, the spectrum is not!) All that was inherited from VMS (where Genie originated), which supports files with complex structure, unlike Windows. I don't think even CANBERRA has today the complete description of the CAM format...

A newer version of Genie might seem to generate a different "version" of the CAM file, simply because is saving a different number of parameters or in a different order. If you create the CAM file in VB using the CANBERRA SDK, chances are that you will not be able to read them back with your code. Even when using the same version of Genie, changing something as the detector type or a setting somewhere can cause your code to fail.

The best way to read the CAM files is by using the CANBERRA libraries, otherwise you'll be reinventing the wheel (and believe me, is a complicated one). CANBERRA has an SDK consisting of a set of COM components and C libraries that can be used with VB or C++. IIRC, the pcam.dll in the EXEFILES directory is the one that does all the low-level access. There should be also a sad.dll file or similar that can be called from C to access files and devices. The documentation is available from CANBERRA (usually comes with the Genie distribution).

 Related Discussions Computing & Technology 10 Nuclear Engineering 1 General Discussion 9 General Discussion 33 General Discussion 9