yangcli-gw Examples

Note

  • This section is preliminary.

  • More examples will be added in the future.

The 'yangcli-gw-apps' directory contains some simple example programs to demonstrate the usage of the yangcli-gw program.

An application is required to perform the following operations:

  • Connect to the correct ZeroMQ socket(s)

  • Send ZeroMQ Multi-part messages

  • Receive ZeroMQ Multi-part messages

yangcli-gw-app File Locations

The 'yangcli-gw-apps' folder contains the example applications.

  • This is a top level folder in the source code distribution.

  • This is located in the following folder in the Advanced SDK binary packages:

    • /usr/share/yumapro/src/yangcli-gw-apps

Python3 Examples

The Python examples require Python3 to be installed and used. They are located within the 'Python3' sub-folder.

Refer to the yangcli-gw Getting Started section for details on installing the pyzmq library.

The following files are included in this directory:

  • pyclient.py: simple command channel example

  • pyclient2.py: simple command and event channel combined example

  • pycollect.py: simple event channel example

These simple programs hard-wire the ZMQAPI endpoints used. They must be changed if non-default endpoint values are used in the yangcli-gw program.

Java Examples

The Java examples require the following to be installed:

  • Java Runtime Environment (JRE)

It's recommended to use IntelliJ IDEA IDE to work with these examples.

The Java examples are organized into controller-app and subscriber-app folders, each containing console and gui subfolders with project examples.

Controller Application

Simple command channel example

  1. Console Example : Command-line interface (CLI) application

    • Located in controller-app/console/

  2. GUI Example : Graphical User Interface (GUI) application

    • Located in controller-app/gui/

Subscriber Application

Demonstrates basic event channel usage

  1. Console Example : Command-line interface (CLI) application

    • Located in subscriber-app/console/

  2. GUI Example : Graphical User Interface (GUI) application

    • Located in subscriber-app/gui/

Setup and Run Java GUI Controller Application with IntelliJ IDEA

Prerequisites

  1. Java Development Kit (JDK): Ensure you have JDK installed. You can download it from Oracle JDK Downloads.

  2. IntelliJ IDEA: Download and install IntelliJ IDEA from JetBrains IntelliJ IDEA Downloads.

Steps to Run the Application

  1. Open IntelliJ IDEA:

    • Launch IntelliJ IDEA from your desktop or start menu.

  2. Import the Maven Project:

    • Click on Open from the welcome screen.

    • Navigate to the directory containing your pom.xml file (Java/controller-app/gui) and select the pom.xml file.

    • IntelliJ IDEA will automatically detect the Maven project and import it. Click Open as Project.

  3. Ensure Dependencies are Downloaded:

    • IntelliJ should automatically download the dependencies specified in your pom.xml file. You can check the progress in the bottom status bar.

    • If the dependencies are not downloaded automatically, right-click on the project root in the Project view and select Maven -> Reimport.

  4. Build the Project:

    • Click on Build in the menu bar and select Build Project to compile the project and resolve any dependencies.

  5. Run the Application:

    • Right-click on the Main class file in the Project view.

    • Select Run 'Main.main()'.

    • The application should start, and you will see the GUI window.

Running Other Java Applications Examples

You can use the same steps to run other Java applications with IntelliJ IDEA. Simply follow the instructions above to set up the project, ensure dependencies are resolved, and run the application from within the IDE.

NodeJS Examples

The NodeJS examples are organized into controller-app and subscriber-app folders, each containing console and gui subfolders with project examples.

NodeJS Examples Dependencies

The NodeJS examples require the following to be installed:

  1. Node.js

    You need to have Node.js installed on your system. Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. You can download and install Node.js from the official Node.js website.

  2. npm (Node Package Manager)

    npm is included with Node.js installation. It is used to install the required packages and dependencies for the Node.js examples.

Running NodeJS Examples

Once the required packages are installed, you can run the Node.js examples as follows:

  1. Install Dependencies:

    • Navigate to the example directory in your terminal.

    • Before running the examples, make sure to install all necessary dependencies by running:

    npm install
    
  2. Console Example:

    Run the example using Node.js:

    node [example_name].js
    
  3. Electron GUI Example:

    Start the Electron app by running:

    npm start
    

Go Examples

The Go examples are organized into controller-app and subscriber-app folders, each containing console and gui subfolders with project examples.

Go Examples Dependencies

The Go examples require the following to be installed:

  1. Go

    You need to have Go installed on your system. Go is a statically typed, compiled programming language designed at Google. You can download and install Go from the official Go website.

  2. Go Modules

    Go Modules is the dependency management system for Go. It is included with the Go installation and is used to install the required packages and dependencies for the Go examples.

  3. Fyne (For GUI Examples)

    Fyne is a cross-platform GUI toolkit for Go. The GUI examples require Fyne to be installed. You can install Fyne by running:

    go get fyne.io/fyne/v2
    

Running Go Examples

Once the required packages are installed, you can run the Go examples as follows:

  1. Install Dependencies:

    • Navigate to the example directory in your terminal.

    • Before running the examples, make sure to install all necessary dependencies by running:

    go mod tidy
    
  2. Console Example:

    Run the example using Go:

    go run [example_name].go
    
  3. Fyne GUI Example:

    Start the GUI application by running:

    go run [example_name].go