代码拉取完成,页面将自动刷新
Attribute VB_Name = "IniFile"
Dim Read As New CIniFile '调用类模块
Dim FileName As String 'Ini文件名称
Sub Read_IniFile(ByVal ActiveIndex As Integer)
Call Read.Class_Initialize '初始化类
Call Read.SpecifyIni(Dialog_File(ActiveIndex)) '指定文件名,初始化Read
If ActiveIndex <> 1 Then Exit Sub '保存时,不读配置
Call ReadMyConf '读取配置
End Sub
Sub ReadMyConf()
Erase MyItemConf() '释放内存
If FileName = "" Then Exit Sub
Call SetMyTestConf
Call SetMyInstrConf
Call SetMyItemConf
End Sub
Function Dialog_File(ByVal ActiveIndex As Integer) As String '打开对话框,并初始化Ini变量
Dim MyDialog As New CommonDialog
MyDialog.Filter = "Ini文件(*.ini)| *.ini| " '文件类型过滤
MyDialog.Action = ActiveIndex '打开(1),保存(2)
FileName = MyDialog.FileName '给模块变量赋值
Dialog_File = MyDialog.FileName
End Function
Function Read_FileName() As String '读FileName
Read_FileName = FileName
End Function
Function Read_Mode() As Integer '读Mode
Read_Mode = Read.ReadInt("Setting", "Mode")
End Function
Function Read_StepNum() As Integer '读AllStep
Read_StepNum = Read.ReadInt("Setting", "AllStep")
End Function
Function Read_ItemNum() As Integer '读扫频点数
On Error GoTo Err
Dim ItemNum As Integer
ItemNum = 0
For i = 1 To Read_StepNum
ItemNum = ItemNum + Read.ReadInt("Step" & i, "StepNumber")
Next i
Read_ItemNum = ItemNum
Err:
End Function
Private Sub SetMyTestConf()
On Error Resume Next
With MyTestConf
.ProductSN = Trim(Read.ReadString("Header", "ProductSN", 100))
.Operater = Trim(Read.ReadString("Header", "Operater", 20))
.WorkTime = Trim(Read.ReadString("Header", "WorkTime", 20))
.ProductState = Trim(Read.ReadString("Header", "ProductState", 100))
.Supplier = Trim(Read.ReadString("Header", "Supplier", 200))
.DataPath = Trim(Read.ReadString("Header", "DataPath", 100))
.ProductName = Trim(Read.ReadString("Header", "ProductName", 100))
End With
End Sub
Private Sub SetMyInstrConf()
On Error Resume Next
With MyInstrConf
.Mode = Read.ReadInt("Setting", "Mode") '1/2/3
.AllStep = Read.ReadInt("Setting", "AllStep")
.PA1_Value = Read.ReadDouble("Setting", "PA1_Value")
.PA2_Value = Read.ReadDouble("Setting", "PA2_Value")
.Coupler_Value = Read.ReadDouble("Setting", "Coupler_Value")
.SpecSpan = Read.ReadDouble("Setting", "SpecSpan")
.BW = Read.ReadDouble("Setting", "BW")
.RefLevel = Read.ReadDouble("Setting", "RefLevel")
.RefLvlOffset = Read.ReadDouble("Setting", "RefLvlOffset")
'.SA_Alias = Trim(Read.ReadString("Setting", "SA_Alias", 20))
.PS_Alias = Trim(Read.ReadString("Setting", "PS_Alias", 20))
'.Sig1_Alias = Trim(Read.ReadString("Setting", "Sig1_Alias", 20))
'.Sig2_Alias = Trim(Read.ReadString("Setting", "Sig2_Alias", 20))
.SA_Alias = "SA"
.Sig1_Alias = "Sig1"
.Sig2_Alias = "Sig2"
End With
End Sub
Private Sub SetMyItemConf()
On Error Resume Next
Select Case Read_Mode
Case 1 '调试模式
SetMyItemConf_0
Case 2, 3 '扫频模式
SetMyItemConf_12
End Select
End Sub
Private Sub SetMyItemConf_0()
On Error Resume Next
ReDim MyItemConf(1 To Read_StepNum) As ItemConfig
For i = 1 To Read_StepNum
With MyItemConf(i)
.StepIndex = i
.PointIndex = 1
.Msg = Trim(Read.ReadString("Step" & i, "Msg", 100))
.Path = Read.ReadString("Step" & i, "Path", 10)
.Sig1Frequency = Read.ReadDouble("Step" & i, "Sig1Frequency")
.Sig2Frequency = Read.ReadDouble("Step" & i, "Sig2Frequency")
.Sig1Target = Read.ReadDouble("Step" & i, "Sig1Target")
.Sig2Target = Read.ReadDouble("Step" & i, "Sig2Target")
.Sig1Power = Read.ReadDouble("Step" & i, "Sig1Power")
.Sig2Power = Read.ReadDouble("Step" & i, "Sig2Power")
.Sig1Offset = Read.ReadDouble("Step" & i, "Sig1Offset")
.Sig2Offset = Read.ReadDouble("Step" & i, "Sig2Offset")
.PIMType = Read.ReadInt("Step" & i, "PIMType")
.PIMFrequency = Read.ReadDouble("Step" & i, "PIMFrequency")
.ReferenceValue = Read.ReadDouble("Step" & i, "ReferenceValue")
'.Fixed = Read.ReadInt("Step" & i, "Fixed")
'.StepValue = Read.ReadInt("Step" & i, "StepValue")
'.StepNumber = Read.ReadInt("Step" & i, "StepNumber")
End With
Next i
End Sub
Private Sub SetMyItemConf_12()
On Error Resume Next
ReDim MyItemConf(1 To Read_ItemNum) As ItemConfig
Dim SumItem As Integer
For i = 1 To Read_StepNum
For j = 1 To Read.ReadInt("Step" & i, "StepNumber")
k = SumItem + j
With MyItemConf(k)
.StepIndex = i
.PointIndex = j
.Msg = Trim(Read.ReadString("Step" & i, "Msg", 100))
.Path = Read.ReadString("Step" & i, "Path", 10)
.Sig1Target = Read.ReadDouble("Step" & i, "Sig1Target")
.Sig2Target = Read.ReadDouble("Step" & i, "Sig2Target")
.Sig1Power = Read.ReadDouble("Step" & i, "Sig1Power")
.Sig2Power = Read.ReadDouble("Step" & i, "Sig2Power")
.Sig1Offset = Read.ReadDouble(CStr(k), "Sig1Offset")
.Sig2Offset = Read.ReadDouble(CStr(k), "Sig2Offset")
.PIMType = Read.ReadInt("Step" & i, "PIMType")
.ReferenceValue = Read.ReadDouble("Step" & i, "ReferenceValue")
.Fixed = Read.ReadInt("Step" & i, "Fixed")
.StepValue = Read.ReadDouble("Step" & i, "StepValue")
.StepNumber = Read.ReadInt("Step" & i, "StepNumber")
Select Case .Fixed
Case 1
.Sig1Frequency = Read.ReadDouble("Step" & i, "Sig1Frequency")
.Sig2Frequency = Read.ReadDouble("Step" & i, "Sig2Frequency") + (.StepValue) * (j - 1)
Case 2
.Sig1Frequency = Read.ReadDouble("Step" & i, "Sig1Frequency") + (.StepValue) * (j - 1)
.Sig2Frequency = Read.ReadDouble("Step" & i, "Sig2Frequency")
End Select
.PIMFrequency = 0.5 * (.PIMType + 1) * .Sig1Frequency - 0.5 * (.PIMType - 1) * .Sig2Frequency
End With
Next j
SumItem = SumItem + Read.ReadInt("Step" & i, "StepNumber") '计算已配置数
Next i
End Sub
Sub WriterOffset(ByVal i As Integer, ByVal Key As String, ByVal OffsetValue As Double) '写Sig1Offset、Sig2Offset
Select Case Read_Mode
Case 1
temp = Read.WriteString("Step" & i, Key, OffsetValue)
With MyItemConf(i)
.Sig1Offset = Read.ReadDouble("Step" & i, "Sig1Offset")
.Sig2Offset = Read.ReadDouble("Step" & i, "Sig2Offset")
End With
Case 2, 3
temp = Read.WriteString(CStr(i), Key, OffsetValue)
With MyItemConf(i)
.Sig1Offset = Read.ReadDouble(CStr(i), "Sig1Offset")
.Sig2Offset = Read.ReadDouble(CStr(i), "Sig2Offset")
End With
End Select
End Sub
Function ReadOffset(ByVal i As Integer, ByVal Key As String) As Double
Select Case Read_Mode
Case 1
ReadOffset = Read.ReadDouble("Step" & i, Key)
Case 2, 3
ReadOffset = Read.ReadDouble(CStr(i), Key)
End Select
End Function
Sub WriteIni(ByVal Section As String, ByVal Key As String, ByVal Value As String) '写文件
temp = Read.WriteString(Section, Key, Value)
End Sub
Sub Write_TextFile(ByVal FileName As String, ByVal Str As String) '写Text文件
Open FileName For Output As #1
'MsgBox Str
Print #1, Str
Close #1
End Sub
Sub Write_Add(ByVal FileName As String, ByVal Str As String)
Open FileName For Append As #1
Print #1, Str
Close #1
End Sub
Function Read_TextFile(ByVal FileName As String) As String '读Text文件
On Error GoTo Err
Dim Buffer() As String
i = 0
Open FileName For Input As #1
Do While Not EOF(1)
ReDim Preserve Buffer(i) As String
Line Input #1, Buffer(i)
i = i + 1
Loop
Close #1
For i = LBound(Buffer()) + 1 To UBound(Buffer()) - 1
Read_TextFile = Read_TextFile & Buffer(i) & Chr(13)
Next i
Exit Function
Err:
Read_TextFile = ""
End Function
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。