René Jensen wrote:
What i need is a class containing
connect()
Disconnect()
measurecurrent(channel as int)
measurevoltage(channel as int)
..... (there is about 10 meassure)
scanaddcurrent(channel as int)
scanaddvoltage(channel as int)
.....(there is the same 10 as measure)
trigger()
and i can easily create this
but the below makes more sense i think
so what i want is to somehow create
connect()
Disconnect()
measure.voltage(channel as int)
measure.amp(channel as int)
measere.(the 10 others)
scanadd.amp(channel as int)
scanadd.(the rest of the possebilities)
trigger()
the options (voltage, amp, etc.) are the same for measure and scan
as the first class(acq) know the serial port it can easily do the
measureamp as this is just send a textstring to the serial port.
But measure.amp the second class containg the measure options will not
know the serial port and can't send the data there by
did that make sense
I'n very new to OOP
Create a class for the Measure and ScanAdd properties, and make their
constructors take either a reference to the serial port object or the
parent object.
Example:
Public Class Serial
'command class for Measure
Public Class MeasureCommands
'reference to parent
Private _parent As Serial
Public Sub MeasureCommands(parent As Serial)
_parent = parent
End Sub
Public Function Voltage(channel As Integer) As Integer
'uses _parent to access serial port
End Function
End Class
'command class for ScanAdd
Public Class ScanAddCommands
'reference to parent
Private _parent As Serial
Public Sub ScanAddCommands(parent As Serial)
_parent = parent
End Sub
Public Sub Amp(channel as Integer)
'uses _parent to access serial port
End Sub
End Class
'local variables for command objects
Private _measure As MeasureCommands
Private _scanAdd As ScanAddCommands
Public Sub Serial()
'create commands objects
_measure = New MeasureCommands(Me)
_scanAdd = New ScanAddCommands(Me)
End Sub
Public Property Measure() As MeasureCommands
Get
Return _measure
End Get
End Property
Public Property ScanAdd() As ScanAddCommands
Get
Return _scanAdd
End Get
End Property
End Class
--
Göran Andersson
_____
http://www.guffa.com