3.1 General
The program contains 13 different classes:
- CAboutDlg - CChannelsDlg - CCrates
- CHistogramCtrl - CI2C_DebugApp - CI2C_DebugDoc - CI2C_DebugView - CMainFrame - CPatternDebug - CSetup
- CSingleDebug - CTestTrgLog - SingleDiscrim
The classes that were generated by the Class Wizard are CAboutDlg, CI2C_DebugApp, CI2C_DebugDoc, CI2C_DebugView and CMainFrame. Those are standard classes for a SDI application. Then Pawel Marciniewski had predefined the following classes,
CPatternDebug, CSingleDebug, CTestTrgLog and SingleDiscrim. The author modified the CSingleDebug, and the SingleDiscrim class. Hence the author created
CChannelsDlg, CCrates, CHistogramCtrl and CSetup. In the following sub chapters the classes will be explained. What they do and how they work. Classes not created by the author will be briefly explained.
3.2 CAboutDlg class
This class is generated by the class wizard when a SDI-application is created [4, 5]. It
only contains information for the ABOUT I2C_Debug dialog window. This is a pop-up
dialog window showing which version and who created the program.
3.3 CChannelsDlg class
The author created this class. It contains information about the dialog window for displaying low threshold checks, see figure 9. The class prepares the drawing area for displaying the graph the CHistogramCtrl class produces. Because the class needs to exchange information with the CHistogramCtrl class, there is a member variable of type CHistogramCtrl added to this class. This gives the CChannelsDlg class access to public members in the CHistogramCtrl class. The black rectangle in figure 10 is the drawing area where the graph is placed.
Figure 10. Drawing area for the graph fo the channels.
The program code for this class can be seen in appendix A.
3.4 CCrates class
The author created this class. It contains information about a GUI in form of a dialog
window, see figure 5. This dialog window shows the crates in the rack and give the user
two different options to choose from. One is to open a specific crate and the other is to
exit the program. The dialog window was created with a bitmap drawn by the user. The
bitmap is designed to look like crates in a rack. Then there is a couple of buttons added
for the different actions the user can do. The bitmap is placed on the buttons, letting the
user push the specific crate to open. If the user choose to open a crate, a new dialog
window is displayed showing the “inside” of the crate, see figure 6. If the user choose
Exit the program is terminated. The program code for this class can be seen in appendix
A.
3.5 CHistogramCtrl class
This class was first created by Ken C. Len, and then modified by the author to be used in this program [3]. At first this class showed a scrolling spike (right to left), with different amplitudes in a dialog window. Each time the DrawSpike function was called a new spike was drawn and the previous spike was moved one step to the left. The idea is to have each channel represented in a spike. So by deleting the timer function, setting the same amplitude for all spikes, and call DrawSpike 16 times 16 equally high spikes were produced in a chart form. When placing the chart in the drawing area that was prepared in CChannelsDlg, the result looked like figure 11.
Figure 11. Dialog window of 16 channels in a chart form.
Then every spike was divided into ten different segments, one segment for each
amplitude of the test pulse. The lowest amplitude was the bottom segment and the highest amplitude was the top segment. Each segment then was colored depending on if the channel had reacted on the test pulse. Red if it do not react and green if it react. The final result of this class when doing a run on a working discriminator board looks like figure 9.
The program code for this class can be seen in appendix A.
3.6 CI2C_DebugApp class
The Class Wizard generates this class when a SDI-application is created [4, 5]. It receives all event messages and then passes the message to the proper class.
3.7 CI2C_DebugDoc class
The Class Wizard generates this class when a SDI-application is created [4, 5]. It houses
the document, and is also responsible for saving and retrieving the document data from
files.
3.8 CI2C_DebugView class
The Class Wizard generates this class when a SDI-application is created [4, 5]. It displays a visual representation for the user. The class passes input information to the
CI2C_DebugDoc class and receives display information from the CI2C_DebugDoc class.
3.9 CMainFrame class
The Class Wizard generates this class when a SDI-application is created. It is the starting window frame. This window holds the menu; toolbar and other visual objects attached to the frame. See figure 12.
Figure 12. The first dialog window the user sees when launching the program.
This is the first window the user sees when launching the program. From here the user can launch different programs, and all other “classical” operations, i.e. open a file. The author has added a function for launching the program in the menu. The function code can be seen in appendix A.
3.10 CPatternDebug class
This class is a pattern generator used for testing.
3.11 CSetup class
The class is created by the author and contains a GUI of the crate inside, see figure 4. The
dialog window gives the user several different options to choose from. The class uses the
OnNrofcards function in the CSingleDebug class to retrieve the number of cards in the
crate. The GUI is only a true picture of what type and how many cards there are in the
crate not a true picture of how these cards are placed in the crate.
The program cannot tell in which slot the specific card is sitting. This is due to the fact that the crate does not have any ID number or address at each slot. All cards are just connected on the same bus waiting to be “called”, see figure 13.
a) b)
Crate CPU Crate CPU
Figure 13. A computer scans a crate for its contents.
a) Cards in order in the crate.
b) Cards not in order in the crate.
The program illustrates what type and how many cards there are in a crate, but not the cards geographical position. For testing of the 16-channels discriminator cards it makes no difference. The cards can be tested no matter where they are in a crate. But there is one important thing to mention, and that is that all the cards are set to different board addresses. If two cards have the same board address one of them is not “seen”.
Another option for the user is to launch the SingleDiscrim class. This class provides setup and testing of the 16-channel discriminator cards. When viewing the output from the setup and testing, the specific board address is chosen and the “graph-button” is clicked.
This provides the user with a graphical status of all the channels in a specific card, see figure 9. The program code for this class can be seen in appendix A.
3.12 CSingleDebug class
This class provides a GUI, and different functions. This class is used when finding the board address of a card. It can also be used when testing read/write to the cards. The author has added two functions that are used by the CSetup class. One is the function OnNrofcards that receives an array of integers from the CSetup class and then
manipulates it. By default the array is filled with zeros, symbolizing that there is no cards in the crate. The OnNrofcards function now calls the other member function, nextcard.
This function finds the board address of the card. In a while-loop this continues until there is no more valid address. Each new valid address found is saved in an array. The function nextcard is a modified copy of an already existing function OnNextaddr. The reason for this is because the CSingleDebug class is not intended to run as a program.
The object is to use some functions in the class without having to launch the whole class.
The already existing function was written to have its own dialog window, and to display information for the user. To avoid these dialogs the nextcard function was created. The program code for these functions can be seen in appendix A.
a a b b c
?
a,a,b,b,c b a c b a
? a,a,b,b,c
3.13 CTestTrgLog class
This class is used when testing the trigger logic cards.
3.14 SingleDiscrim class
This class contains a GUI and different options for setup and testing of the 16-channel discriminator cards. When a user in the CSetup dialog windows chooses the “setup and test” button a pop-up dialog window for the SingleDiscrim class is launched, see figure 7.
The author has added one function Crate. The author has also added code for already existing functions. The function Crate receives an array from the CSetup class, holding information about how many cards there are in the crate. The function copies the arra y into a new class global array for the SingleDiscrim class. This information is later used in a member function OnTest. In the beginning the class was able to setup and test a specific card which the user selected. But when there is 20 or some cards the program should provide a way for the user to test all cards. It is not possible to do the setup on all cards first, and then test them. A for-loop was created going through each card, performing the setup and test as the cards were looped through. In the GUI a checkbox was added for the option of setup and testing of all the cards, see figure 7. Before performing the setup and test the user could set low threshold, high threshold and pulse duration time.
In the OnRunSetup function the checkbox for setup and test of all cards is checked if been marked. If marked the program loops through all the cards performing setup and tests on all of them. Calling another member function OnTest that executes the test. The input to this function is the cards board address. If the checkbox is unmarked a setup and test is performed on the specified card. The program code for this class can be seen in appendix A.
3.15 Extra files
The program also includes three files that do not belong to any class. Those are
I2C_util.cpp, I2C_util.h and Global.h. The I2C_util.h and I2C_util.cpp are c++ files that are used for reading and writing with the I2C interface. Global.h defines some global variables for a more dynamic program. Global in the sense that all classes can access them. The Global.h file is included in the header- or source-files for the class using these variables.
The program uses a Windows NT driver called MapMemPlus. The driver allows the
program to access the IO-bus and access directly to all the busses. These operations are
normal unauthorized by the system.
In document
Visual C++ software for testing the discriminators in the WASA-experiment. a, b
(Page 10-16)