Skip to content

tmtsoftware/tcs-vslice-0.4

Repository files navigation

TCS Vertical Slice Demo

This project contains demo CSW assemblies and test client code based on the TCS API as defined the the ICD Database.

It makes use of the Scala based CSW framework, and also links with native C/C++ code (using JNR - Java Native Runtime). For example, the pk (Pointing Kernel) assembly receives a SlewToTarget command and then makes a call to C/C++ code that calls TPK routines to set a target and then posts events using the CSW C API.

You can subscribe to those events for test purposes using the tcs-client command line subproject, which just prints out the events received on stdout.

Also the CSW Event Monitor uses the ESW gateway to subscribe to events and can be used to display tables and charts based on the event values.

Note: In order to test this project with the CSW Event Monitor, you will currently need to run the icdwebserver on localhost and import a slightly modified version of the TCS-Model-Files repository (branch: tcs-vslice-04-test). The branch has been modified to use the CSW altAzCoord type instead of separate parameters for alt and az, etc. The assemblies provided here assumes the use of the altAzCoord type and posts events using it.

Dependencies

Note: For Ubuntu, install these packages:

sudo apt install build-essential
sudo apt-get install -y openjdk-21-jdk

Currently, this project requires that a number of shared libraries are installed in a known location (default: /usr/local/lib), which must also be included the LD_LIBRARY_PATH environment variable (On Linux).

Run make; sudo make install in the following projects (Note: In these projects the Makefile calls cmake to do the actual build). First follow the instructions in the csw-c README to install the required C libraries (libhiredis, libcbor, libuuid). You can also use make PREFIX=/my/dir to change the installation directory.

MacOS-12 (Monterey, Intel) Homebrew installation of shared library dependencies

In order to make it easier to test under MacOS, a Homebrew installation of the necessary shared libraries for the TCS pk assembly is now available for MacOS-12 (Intel CPU). Note that these libraries are precompiled, since the TPK dependency is from a private GitHub repo, making it impossible to build on a user's system without the necessary permissions. The brew-zip.sh script is used to build the zip file used by the brew tap, but requires that all the sources are available (in ../csw- and ../../TPK).

To install the shared library dependencies, run:

  brew tap abrighton/tcs-vslice
  brew install tcs-vslice

After that, you should be able to run the pk assembly or containers using it as described below.

Making a release dir: install.sh (For Linux)

The install.sh script creates an OS specific directory with all of the JVM and native dependencies. It assumes that the native shared libs for TPK and csw-c are already installed in /usr/local/lib and copies them to install/tcs-vslice-04/lib/uname, where uname is Darwin for MacOS, or Linux.

This was tested on Ubuntu-21.04 and MacOS-12 (Due to security issues, it is recommended to use the brew install on Macs).

Running the pk assembly

Note that by setting the environment variable TPK_USE_FAKE_SYSTEM_CLOCK you can force the internal clock used by the assembly's C code to start at MDJ = midnight, Jan 1, 2022, making tests more reproducible. In this case coordinates with RA near zero should be above the horizon, and thus produce position events.

To run the assemblies, run:

csw-services start  # Note: Make sure you are using the version of csw used in this and dependent projects

sbt stage

export TPK_USE_FAKE_SYSTEM_CLOCK=1
./target/universal/stage/bin/tcs-deploy --local ./tcs-deploy/src/main/resources/McsEncPkContainer.conf

To send a command to the pk assembly, you can use the tcs-client command line application:

tcs-client 0.12.0
Usage: tcs-client [options]

  -c, --command <command>  The command to send to the pk assembly (One of: SlewToTarget, SetOffset. Default: SlewToTarget)
  -r, --ra <RA>            The RA coordinate for the command in the format hh:mm:ss.sss
  -d, --dec <Dec>          The Dec coordinate for the command in the format dd:mm:ss.sss
  -f, --frame <frame>      The frame of refererence for RA, Dec: (default: ICRS)
  --pmx <pmx>              The primary motion x value: (default: 0.0)
  --pmy <pmy>              The primary motion y value: (default: 0.0)
  -x, --x <x>              The x offset in arcsec: (default: 0.0)
  -y, --y <y>              The y offset in arcsec: (default: 0.0)
  -o, --obsId <id>         The observation id: (default: None)
  -s, --subscribe <value>  Subscribe to all events published here
  -r, --rate <milliseconds>
                           Limit the receiving rate for subscribed events (in ms): Default: no limit
  -e, --events prefix.name,...
                           List of events (prefix.name) to subscribe to (default: TCS.MCSAssembly.MountPosition, TCS.PointingKernelAssembly.EnclosureDemandPosition, TCS.PointingKernelAssembly.MountDemandPosition, TCS.PointingKernelAssembly.M3DemandPosition, TCS.ENCAssembly.CurrentPosition)
  --convertRaDec           Interprets --ra and --dec as microarcseconds (uas) and prints them as hh:mm:ss, dd:mm:ss
  --help
  --version

Example:

./target/universal/stage/bin/tcs-client -c SlewToTarget --ra 00:11:12 --dec 15:21:22
./target/universal/stage/bin/tcs-client -c SlewToTarget --ra 00:10:01 --dec 13:21:22

To see the events being fired from the C/C++ code, you can run the tcs-client with the --subscribe true option, which causes it to subscribes to events and displays them on stdout.

Or, for a more user-friendly view, you can run the CSW Event Monitor and display the event values in tables or charts. This requires also running the following services:

  • esw-services start (from esw)
  • icdwebserver (from icd) - with slightly modified version of the TCS-Model-Files repository (branch: tcs-vslice-04-test) imported manually

In the current version these events are published:

  • TCS.PointingKernelAssembly.M3DemandPosition
  • TCS.PointingKernelAssembly.EnclosureDemandPosition
  • TCS.PointingKernelAssembly.MountDemandPosition
  • TCS.MCSAssembly.MountPosition
  • TCS.ENCAssembly.CurrentPosition

The event prefixes and names are based on the TCS API as defined in the above TCS-Model-Files repo.

About

Example CSW assemblies and HCDs based on TCS APIs, including native C/C++ code

Resources

License

Stars

Watchers

Forks

Packages

No packages published