473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Class/structure/something else in class

Hello

I got a problem with a class i'm trying to create.

the problem is that i would like to use the dot when i access some
parametes in the class

like.

Connect()
measure.current(10)
trigger()
disconnect()

the class access some hardware

connect opens the serialport
disconnect close it again

trigger sendst a command to the serialport to start measure.

and measure.current i want to send a command to the same serialport
but how? can onyone paste a few lines of code how do to this.

Thanks in advance

René

Mar 7 '07 #1
4 1024
René Jensen wrote:
Hello

I got a problem with a class i'm trying to create.

the problem is that i would like to use the dot when i access some
parametes in the class

like.

Connect()
measure.current(10)
trigger()
disconnect()

the class access some hardware

connect opens the serialport
disconnect close it again

trigger sendst a command to the serialport to start measure.

and measure.current i want to send a command to the same serialport
but how? can onyone paste a few lines of code how do to this.

Thanks in advance

René
Which class is it that you are trying to create? Is it the class that
contains these methods, or the class of the measure property?

Why is it that you want to use a period? What is it that you want to
accomplish?

--
Göran Andersson
_____
http://www.guffa.com
Mar 7 '07 #2
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

Mar 7 '07 #3
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
Mar 7 '07 #4
Thank you very much

Rene

Mar 15 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: clintonG | last post by:
I'd like to know about application(s) or the name by which the following process is referred which would allow a business analyst to enter the following statements which when submitted would result...
17
by: Aguilar, James | last post by:
My previous example used the concept of a Shape class heirarchy, so I will continue with that. Suppose I have something like fifty different shapes, and I am trying to instantiate one of them. ...
21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
1
by: Christopher A. Kelly | last post by:
I need to figure out how to control any 3rd party application by simulating mouse click and key presses. I need to take a partial window title and get the handle then be able to send the necessary...
3
by: Jim Langston | last post by:
I am attempting to map the variables in a class or structure to use with MySQL. I got something to work but I'm not happy with it. Here is a snippet showing what I'm not happy with: class...
3
by: antred | last post by:
Hello everyone, While working on a program I encountered a situation where I'd construct a largish data structure (a tree) from parsing a host of files and would end up having to throw away...
4
by: MikeJ | last post by:
make a While loop ofs = TextFileServer("somefile") string srow while (ofs=false) { srow=ofs.getRow(); Console.Writeline(srow); }
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
10
by: Jim Langston | last post by:
I use a game engine using MSVC++ .net 2003 and have no problems. Some users of DevC++ who use the same engine crash at times when a copy of this structure is the return variable. I don't have...
4
by: Steven Simpson | last post by:
Stefan Ram wrote (in "More than one language in a page"): Is this a new trend of user-agent writers (Microformats, and now Google) staking claims on the @class namespace? I'm surely not the only...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.