Coder Social home page Coder Social logo

gemstone-gbs-examples's Introduction

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: '[email protected]#netldi:50400!gemnetobject';
		yourself).

Example of a remote stone:

GBSM addParameters: (GbsSessionParameters new
		gemStoneName: 'gs64stone';
		username: 'DataCurator';
		password: 'swordfish';
		rememberPassword: true;
		gemService: '[email protected]#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

gemstone-gbs-examples's People

Contributors

marianopeck avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.