Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Digital weighing machine
Message
From
22/08/2006 09:19:37
 
 
To
21/08/2006 22:55:34
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01147189
Message ID:
01147544
Views:
23
Hi,

I dropped the oleControl object on my form and called it oleComm. I have a table called Balance which I use to easily put/change the settings I want to use. The CommPort field stores which comm port the scale is plugged into, the settings field stores the baud rate, parity and so on that the scale has been set to, the Handshak field stores the handshake setting used by the scale and the Output field stores the command that gets sent to the scale to print the output, in my case this was "P" for print. The scale I have used is an Ohaus Adventurer Pro.

In it's Init() method I have:
	WITH this 
		TRY 
			.CommPort = Balance.Commport	&&1
			.Settings = Balance.Settings	&&"2400,n,7,2"
			.handshaking = Balance.HandShak	&&0
			.PortOpen  = .T.
		CATCH
			m.llInitOK = .F.
		ENDTRY 
	ENDWITH 

	_vfp.AutoYield = .F.
Then when I want to read the value from the scale:
TRY
	WITH THIS.oleComm
		* for some reason I seem to need to run this twice to get the value
		FOR lnCount = 1 TO Balance.NumTimes
			.OUTPUT = Balance.OUTPUT	&&"P" + CHR(13) + CHR(10)
			DOEVENTS

			lnStart = SECONDS()

			WAIT WINDOW NOWAIT "Reading weight from scale..."
			DO WHILE SECONDS() - lnStart <= Balance.WaitInt
				DOEVENTS
			ENDDO

			lnBufferCount = .inBufferCount
			lcString = .INPUT
			IF lnBufferCount > 0
				WAIT WINDOW NOWAIT "Weight from scale..."+'[' + lcString +']'
			ENDIF

			WAIT CLEAR
		ENDFOR
	ENDWITH
CATCH

ENDTRY

RETURN VAL(CHRTRAN(UPPER(lcString), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", ""))
Hope this helps.

>Something like this :
>
>IF !THISFORM.oleControl1.portOpen
> thisform.oleControl1.portOpen = .T.
>ENDIF
>mtest = THISFORM.oleControl1.input
>
>Or I need to send request code to the machine in order to get feedback?
>How I know the data from Scale Machine is start, and end? What is the string format?
>
>My Client Machine is Teraoka DS-480c. I go to Teraoka Web Site, but can't get the information.
>
>Do you mind to share your code, or any web site can tell more about this.
>
>Thanks.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Reply
Map
View

Click here to load this message in the networking platform