⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 ccp
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "CANape COM Client"
   ClientHeight    =   7815
   ClientLeft      =   3900
   ClientTop       =   1920
   ClientWidth     =   7935
   LinkTopic       =   "Form1"
   ScaleHeight     =   7815
   ScaleWidth      =   7935
   Begin VB.CommandButton SendService 
      Caption         =   "Send Service"
      Height          =   615
      Left            =   120
      TabIndex        =   29
      Top             =   5040
      Width           =   1695
   End
   Begin VB.TextBox ChannelField 
      Height          =   285
      Left            =   6240
      TabIndex        =   27
      Text            =   "1"
      Top             =   2520
      Width           =   495
   End
   Begin VB.TextBox DriverTypeField 
      Height          =   285
      Left            =   3960
      TabIndex        =   26
      Text            =   "CCP"
      Top             =   2520
      Width           =   2055
   End
   Begin VB.CommandButton WriteMemory 
      Caption         =   "Write Memory"
      Height          =   615
      Left            =   2040
      TabIndex        =   25
      Top             =   3360
      Width           =   1695
   End
   Begin VB.TextBox ObjectValueField 
      Height          =   285
      Left            =   3960
      TabIndex        =   22
      Top             =   4560
      Width           =   1335
   End
   Begin VB.CommandButton WriteObject 
      Caption         =   "Write Object"
      Height          =   615
      Left            =   2040
      TabIndex        =   21
      Top             =   4200
      Width           =   1695
   End
   Begin VB.TextBox ObjectNameField 
      Height          =   285
      Left            =   3960
      TabIndex        =   20
      Text            =   "ampl"
      Top             =   4200
      Width           =   1335
   End
   Begin VB.CommandButton ReadObject 
      Caption         =   "Read Object"
      Height          =   615
      Left            =   120
      TabIndex        =   19
      Top             =   4200
      Width           =   1695
   End
   Begin VB.TextBox WorkingDir 
      Height          =   285
      Left            =   2040
      TabIndex        =   18
      Text            =   "c:\programme\canape\com\vb"
      Top             =   360
      Width           =   5775
   End
   Begin VB.TextBox A2LFilename 
      Height          =   285
      Left            =   3960
      TabIndex        =   16
      Text            =   "c:\programme\canape\ccpsim\ccpsim.a2l"
      Top             =   1800
      Width           =   3855
   End
   Begin VB.TextBox SCRFilename 
      Height          =   285
      Left            =   2040
      TabIndex        =   15
      Text            =   "c:\programme\canape\ccpsim\demo.scr"
      Top             =   1200
      Width           =   5775
   End
   Begin VB.TextBox DeviceNameField 
      Height          =   285
      Left            =   3960
      TabIndex        =   13
      Text            =   "CCPsim"
      Top             =   2160
      Width           =   2055
   End
   Begin VB.CommandButton Device 
      Caption         =   "Create Device"
      Height          =   615
      Left            =   120
      TabIndex        =   12
      Top             =   1800
      Width           =   1695
   End
   Begin VB.CommandButton ExecuteScript 
      Caption         =   "Execute Script"
      Height          =   615
      Left            =   120
      TabIndex        =   9
      Top             =   960
      Width           =   1695
   End
   Begin VB.CommandButton Start 
      Caption         =   "Start CANape in .."
      Height          =   615
      Left            =   120
      TabIndex        =   8
      Top             =   120
      Width           =   1695
   End
   Begin VB.CommandButton ReadMemory 
      Caption         =   "Read Memory"
      Height          =   615
      Left            =   120
      TabIndex        =   7
      Top             =   3360
      Width           =   1695
   End
   Begin VB.TextBox SizeField 
      Height          =   285
      Left            =   3960
      TabIndex        =   6
      Text            =   "8"
      Top             =   3360
      Width           =   1335
   End
   Begin VB.TextBox AddressField 
      Height          =   285
      Left            =   3960
      TabIndex        =   3
      Text            =   "270000"
      Top             =   3720
      Width           =   1335
   End
   Begin VB.CommandButton Stop 
      Caption         =   "Stop CANape"
      Height          =   615
      Left            =   120
      TabIndex        =   1
      Top             =   5880
      Width           =   1695
   End
   Begin VB.TextBox Text1 
      Height          =   735
      Left            =   120
      TabIndex        =   0
      Top             =   6960
      Width           =   7695
   End
   Begin VB.Label Label10 
      Caption         =   "Driver and Channel:"
      Height          =   255
      Left            =   2040
      TabIndex        =   28
      Top             =   2520
      Width           =   1695
   End
   Begin VB.Label Label9 
      Caption         =   "Value (Phys)"
      Height          =   255
      Left            =   5400
      TabIndex        =   24
      Top             =   4680
      Width           =   1215
   End
   Begin VB.Label Label8 
      Caption         =   "Name"
      Height          =   255
      Left            =   5400
      TabIndex        =   23
      Top             =   4320
      Width           =   1215
   End
   Begin VB.Label Label7 
      Caption         =   "Working Directory:"
      Height          =   255
      Left            =   2040
      TabIndex        =   17
      Top             =   120
      Width           =   1695
   End
   Begin VB.Label Label6 
      Caption         =   "Devicename:"
      Height          =   375
      Left            =   2040
      TabIndex        =   14
      Top             =   2160
      Width           =   1215
   End
   Begin VB.Label Label5 
      Caption         =   "ASAP2 Filename (*.A2L):"
      Height          =   255
      Left            =   2040
      TabIndex        =   11
      Top             =   1800
      Width           =   1935
   End
   Begin VB.Label Label4 
      Caption         =   "SCRIPT Filename (*.SCR):"
      Height          =   255
      Left            =   2040
      TabIndex        =   10
      Top             =   960
      Width           =   1935
   End
   Begin VB.Label Label3 
      Caption         =   "Bytes"
      Height          =   375
      Left            =   5400
      TabIndex        =   5
      Top             =   3480
      Width           =   615
   End
   Begin VB.Label Label2 
      Caption         =   "Address"
      Height          =   255
      Left            =   5400
      TabIndex        =   4
      Top             =   3840
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "Status:"
      Height          =   255
      Left            =   120
      TabIndex        =   2
      Top             =   6600
      Width           =   1575
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim gApplication As Application
Dim gDevice As Device


Private Sub Form_Load()

  Set gApplication = New CANAPELib.Application

End Sub

Private Sub Ramp_Click()
  On Error GoTo Fail
   
  Dim ampl As Object
  Set ampl = gDevice.CreateCalibrationObject("ampl")
  For v = 0 To 100
    ampl.Value = v
    Call ampl.Write
  Next
  
  Exit Sub
Fail:
  ShowError

End Sub

Private Sub Start_Click()
  On Error GoTo Fail
  Call gApplication.Init(WorkingDir.Text, 1)
  Text1.Text = "CANape started in " & WorkingDir.Text
  Exit Sub
Fail:
  ShowError
End Sub

Private Sub Stop_Click()
  On Error GoTo Fail
  Call gApplication.Exit
  Text1.Text = "CANape terminated"
  Exit Sub
Fail:
  ShowError
End Sub

Private Sub ExecuteScript_Click()
  On Error GoTo Fail
  Text1.Text = "Executing Script " & SCRFilename.Text
  Call gApplication.ExecuteScript(SCRFilename.Text)
  Exit Sub
Fail:
  ShowError
End Sub

Private Sub Device_Click()
  On Error GoTo Fail
  Set gDevice = gApplication.CreateDevice(DeviceNameField.Text, A2LFilename.Text, DriverTypeField.Text, Val(ChannelField.Text))
  Text1.Text = "Device " & DeviceNameField.Text & " created for " & A2LFilename.Text
  Exit Sub
Fail:
  ShowError
End Sub

Private Sub ReadMemory_Click()
  On Error GoTo Fail
  Addr = Val(AddressField.Text)
  Size = Val(SizeField.Text)
  Data = gDevice.ReadMemory(Addr, Size)
  ' Print the result
  Text1.Text = "ReadMemory(" & Addr & "," & Size & ") = {"
  For Each b In Data
    Text1.Text = Text1.Text & " " & b
  Next b
  Text1.Text = Text1.Text & " }"
  Exit Sub
Fail:
  ShowError
End Sub

Private Sub WriteMemory_Click()
  On Error GoTo Fail
  Addr = Val(AddressField.Text)
  Data = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
  Call gDevice.WriteMemory(Addr, Data)
  Exit Sub
Fail:
  ShowError
End Sub

Private Sub SendService_Click()
  On Error GoTo Fail
  Data = Array(1, 0, 0, 0, 0, 0, 0, 0)
  Call gDevice.SendService(Data, Result)
  ' Print the result
  Text1.Text = "Result = {"
  For Each b In Result
    Text1.Text = Text1.Text & " " & b
  Next b
  Text1.Text = Text1.Text & " }"
  Exit Sub
Fail:
  ShowError
End Sub

Private Sub PrintValue(v)
  Text1.Text = Text1.Text & "{"
  For Each b In v
    Text1.Text = Text1.Text & " " & b
  Next b
  Text1.Text = Text1.Text & " }"
End Sub

Private Sub ReadObject_Click()
  On Error GoTo Fail
  Set o = gDevice.CreateCalibrationObject(ObjectNameField.Text)
  If o.ValueType = 0 Then
    ObjectValueField.Text = o.Value
  Else
    ObjectValueField.Text = "Map/Curve"
    Text1.Text = o.Name & "(" & o.YDim & "," & o.XDim & ") = "
    Call PrintValue(o.Value)
  End If
  Set o = Nothing
  Exit Sub
Fail:
  ShowError
End Sub

Private Sub WriteObject_Click()
  On Error GoTo Fail
  Set gCalibrationObject = gDevice.CreateCalibrationObject(ObjectNameField.Text)
  gCalibrationObject.Value = (Val(ObjectValueField.Text))
  Call gCalibrationObject.Write
  Exit Sub
Fail:
  ShowError
End Sub

Sub ShowError()
  ErrMsg = "The object returned the following error: " & Chr(13) & Chr(13) & _
           "Code: 0x" & Hex(Err.Number) & Chr(13) & _
           "Source: " & Err.Source & Chr(13) & _
           "Description: " & Err.Description
  MsgBox ErrMsg, vbSystemModal + vbMsgBoxHelpButton, "Error", Err.HelpFile, Err.HelpContext
End Sub
  


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -