Re: Class/structure/something else in class



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
.



Relevant Pages

  • [PATCH 1/1] mxser, remove it
    ... -static int calloutmajor = MXSERCUMAJOR; ... * This routine is called whenever a serial port is opened. ... * enables interrupts for a serial port, linking in its async structure into ... * async structure from the interrupt chain if necessary, ...
    (Linux-Kernel)
  • RS232 Redirector Program in C using Linux
    ... developing linux aps as well as in the serial port), ... failed to get current settings ... the int handler ... nbytes = write; ...
    (comp.os.linux.development.apps)
  • [PATCH 5/6] Char: mxser_new, code upside down
    ... static int CheckIsMoxaMust ... * This routine is called to set the UART divisor registers to match ... * the specified baud rate for a serial port. ... * They enable or disable transmitter interrupts, ...
    (Linux-Kernel)
  • Re: Serial port cominication problem in linux
    ... I am having problem comunication with serial port in linux. ... I'm not sure what "HSM" means... ... int main ... Or you can disable the timer entirely, ...
    (comp.os.linux.development.apps)
  • Re: Missing Data in Cube / MDX Question
    ... It is probably more likely that the hierarchy should be the other way ... It sounds like your dimension records possibly start out in a parent ... EquipHierarchyKey int not null, ...
    (microsoft.public.sqlserver.olap)