Skip to content

vast-community-hub/gemstone-gbs-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GemStone GBS Examples for VA Smalltalk

GemStone GBS Examples for VA Smalltalk
Report a defect | Request feature

A collection of GemStone GBS Examples for VA Smalltalk

License

  • The code is licensed under MIT.
  • The documentation is licensed under CC BY-SA 4.0.

Installation

  1. Install VA Smalltalk 9.2.1 or newer.
  2. Install Tonel support in your development image following this guide.
  3. Clone this repository.
  4. The easiest and recommended approach is to install it via a script:
| loader path |
path := (CfsPath named: '<insert path to root gemstone-gbs-examples local repo here>').
loader := TonelLoader readFromPath: path.
loader
	beUnattended; "do not prompt and use all defaults"
	useGitVersion.
loader loadAllMapsWithRequiredMaps.

Or you can load the Configuration Map GemStoneGBSExamples from the context menu of the Configuration Maps Browser: "Import" -> "Load Configuration Maps from Tonel repository..." -> select path to root gemstone-gbs-examples local repo. This will open a dialog and will use convenient defaults for the load. Refer to its documentation for more details.

Setting up GBS

  1. Install GemStone GBS for VA Smalltalk following the Installation Guide from here. As a result, you should have the map GBSGemBuilder loaded and a libgcirpc-xxx shared library findable by VA Smalltalk.
  2. Set the library path. For example:
GbsConfiguration current libraryName: 'z:\Common\Development\VAST\9.2x86-b427\libgcirpc-3.4.3-32.dll
  1. (Optional) Create a stone using GsDevKit_home. Example:
createStone -f -G gs_343_gbs 3.4.3

Note that the -G is because tODE cannot easily coexist with GBS.

  1. Create the GemStone session parameters. Example for a local stone:
GBSM addParameters: (GbsSessionParameters new
		gemStoneName: 'gs_343_gbs';
		username: 'SystemUser';
		password: 'swordfish';
		rememberPassword: true;
		gemService: '!@vm-mint64.local#netldi:50400!gemnetobject';
		yourself).

Example of a remote stone:

GBSM addParameters: (GbsSessionParameters new
		gemStoneName: 'gs64stone';
		username: 'DataCurator';
		password: 'swordfish';
		rememberPassword: true;
		gemService: '!@157.230.4.236#netldi:50377#task!gemnetobject';
		yourself).
  1. From the Transcript main menu GemStone -> Sessions you should see the registered session parameter and you should also be able to Login RPC. Example:

gbsSessions

Running Temperatures Example

  1. First thing is to connect to a GemStone session (Login RPC) as we did before during GBS setup.
  2. Then we must “copy” the definition of RjsTemperatureSensorReading from VA Smalltalk to GemStone. For that, we just browse the class, right click, then Create in GS.

createInGemStone

  1. Now that the class also exists on GemStone, here is the final magic:
"GemStone Set Up:
    1) Go to GBS and open a session into the stone.
    2) Use GBS to push the class RjsTemperatureSensorReading to the server (right click -> 'Compile in GS'.
    3) Commit.
    4) Execute below lines
"   

| session connector measures |

"initialize the class variable in VAST."
RjsTemperatureSensorReading clearReadings.

session := GBSM currentSession.
connector := GbsClassVarConnector
        stName: #RjsTemperatureSensorReading
        gsName: #RjsTemperatureSensorReading
        cvarName: #Readings.
connector updateSTOnConnect.
connector connectInSession: session.

"initialize the class variable in GemStone."
session evaluate: 'RjsTemperatureSensorReading clearReadings.'.

measures := OrderedCollection new.
measures add: 20 -> DateTime now.
(Delay forSeconds: 2) wait.
measures add: 25 -> DateTime now.
(Delay forSeconds: 2) wait.
measures add: 30 -> DateTime now.

measures do: [:each |
    (RjsTemperatureSensorReading newTemperature: each key asOf: each value) recordSample.
].

((session evaluate: '
    RjsTemperatureSensorReading sampleReport')
        copyReplacing: Character cr withObject: Character lf)
            inspect.
session commitTransaction.  

RjsTemperatureSensorReading sampleReport inspect.

That code basically tells GemStone to map the class variable Readings from the client Smalltalk (VAST) to itself. Then I hardcoded some temperatures values (in the real example these numbers are replaced with a real temperature sensor and a TestOneWireDS18B20ThermometerDevice fetchTemperature), reify a measure object, store the object into the collection, wait 2 seconds, start again. And like that 3 times. Then I commit to GemStone and finally, I make both, VA Smalltalk and GemStone print a report on the class variable Readings.

The results, as you expect, are that both Smalltalks have their Readings variable correctly and transparently updated:

temperatureResults

You can see the 3 measures, at what time they were recorded and what temperature that was (in Celsius).

Note that each report string was generated in two different Smalltalks and how the collection was in sync automatically. It’s funny to see that VA Smalltalk prints dates as MM/DD/YYYY while GemStone does DD/MM/YYYY.

Blog posts and other media

Acknowledgments

Contributing

Check the Contribution Guidelines