Option Explicit
Public Function ShowStatusValueStrings(m_DP5_Status As Stat) As String
Dim strConfig As String
Dim strTemp As String
Dim strIntPart As String
Dim strFracPart As String
strConfig = "Device Type: " & m_DP5_Status.strDeviceID & vbNewLine
strTemp = "Serial Number: " & CStr(m_DP5_Status.SerialNumber) & vbNewLine 'SerialNumber
strConfig = strConfig & strTemp
strTemp = "Firmware: " + VersionToStr(m_DP5_Status.Firmware) & vbNewLine
strConfig = strConfig & strTemp
strTemp = "FPGA: " + VersionToStr(m_DP5_Status.FPGA) & vbNewLine
strConfig = strConfig & strTemp
strTemp = "Fast Count: " & CStr(CDbl(m_DP5_Status.FastCount)) & vbNewLine 'FastCount
strConfig = strConfig & strTemp
strTemp = "Slow Count: " & CStr(CDbl(m_DP5_Status.SlowCount)) & vbNewLine 'FastCount
strConfig = strConfig & strTemp
strTemp = "Accumulation Time: " & CStr(m_DP5_Status.AccumulationTime) '& vbNewLine 'AccumulationTime
strConfig = strConfig & strTemp
ShowStatusValueStrings = strConfig
End Function
Public Function ProcessSpectrumCfgForFile(strCfgIn As String, Dp5CmdList As Collection) As String
Dim cstrRawCfgIn As String
Dim cstrCmdD As String
Dim cstrDisplayCfgOut As String
Dim idxCfg As Long
Dim varCmd As Variant
Dim strSpectrumCfg As String
ProcessSpectrumCfgForFile = ""
cstrRawCfgIn = ""
For idxCfg = 1 To Len(strCfgIn)
cstrRawCfgIn = cstrRawCfgIn + Mid(strCfgIn, idxCfg, 1)
If (Mid(strCfgIn, idxCfg, 1) = ";") Then
cstrRawCfgIn = cstrRawCfgIn + vbNewLine
End If
Next
cstrDisplayCfgOut = cstrRawCfgIn
For Each varCmd In Dp5CmdList
cstrCmdD = CStr(varCmd)
If (Len(cstrCmdD) > 0) Then
cstrDisplayCfgOut = AppendCmdDesc(cstrCmdD, cstrDisplayCfgOut)
End If
Next
strSpectrumCfg = cstrDisplayCfgOut
'remove a vbnewline to display correctly
If (Right(strSpectrumCfg, 2) = vbNewLine) Then
strSpectrumCfg = Left(strSpectrumCfg, Len(strSpectrumCfg) - 2)
End If
ProcessSpectrumCfgForFile = strSpectrumCfg
End Function
Public Function GetSpectrumFilename(ByRef strFilename As String, cmnDlg As CommonDialog) As Boolean
GetSpectrumFilename = False
If (dlgSave(cmnDlg, dlgMCA_Filter)) Then
strFilename = cmnDlg.filename
GetSpectrumFilename = True
End If
End Function
Public Sub SaveSpectrum(strFilename As String, SPECTRUM As Spec, strCfg As String, STATUS As Stat, strTag As String, strDescription As String, dateStart As Date)
Dim idxData As Long
Dim iFile As Integer
Dim strDate As String
Dim strStatus As String
iFile = FreeFile
Open strFilename For Output As #iFile
If (Len(strTag) = 0) Then strTag = "live_data"
Print #iFile, "<<PMCA SPECTRUM>>"
Print #iFile, "TAG - " & strTag
Print #iFile, "DESCRIPTION - " & strDescription
Print #iFile, "<gen>"
Print #iFile, "<sys>"
Print #iFile, "<not>"
Select Case SPECTRUM.Channels
Case 256
Print #iFile, "GAIN - 0"
Case 512
Print #iFile, "GAIN - 1"
Case 1024
Print #iFile, "GAIN - 2"
Case 2048
Print #iFile, "GAIN - 3"
Case 4096
Print #iFile, "GAIN - 4"
Case 8192
Print #iFile, "GAIN - 5"
Case Else
Print #iFile, "GAIN - 2"
End Select
'Print #iFile, "THRESHOLD - 0"
Print #iFile, "LIVE_MODE - 0"
Print #iFile, "PRESET_TIME - 0"
Print #iFile, "LIVE_TIME - 0"
Print #iFile, "REAL_TIME -"; STATUS.AccumulationTime
'Print #iFile, "START_TIME - "; Date & " " & Time 'MM/DD/YYYY HH:MM:SS
strDate = Format(dateStart, "MM/DD/YYYY HH:MM:SS")
Print #iFile, "START_TIME - "; Date & " " & Time 'MM/DD/YYYY HH:MM:SS
Print #iFile, "SERIAL_NUMBER -"; STATUS.SerialNumber
Print #iFile, "<<DATA>>"
For idxData = 0 To SPECTRUM.Channels - 1
Print #iFile, SPECTRUM.DATA(idxData)
Next idxData
Print #iFile, "<<END>>"
Print #iFile, "<<DP5 CONFIGURATION>>"
Print #iFile, strCfg
Print #iFile, "<<DP5 CONFIGURATION END>>"
Print #iFile, "<<DPP STATUS>>"
strStatus = ShowStatusValueStrings(STATUS)
If (strStatus = "") Then
Print #iFile, "Device Type: DP5"
Print #iFile, "Serial Number: 0"
Else
Print #iFile, strStatus
End If
Print #iFile, "<<DPP STATUS END>>"
Close #iFile
End Sub
Public Sub LogEvent(strEvent As String, Optional bOverWrite As Boolean = False)
Dim FileNumber As Integer
Dim strMsg As String
strMsg = Now & "," & strEvent,
FileNumber = FreeFile
If (bOverWrite) Then
Open "EventLog.txt" For Output As #FileNumber
Else
Open "EventLog.txt" For Append As #FileNumber
End If
Print #FileNumber, strMsg
Close #FileNumber
End Sub