Saving Ostinato port config

3 minute read

Back in Feb, as I was telling yet another customer that the easy way to start with Ostinato Python API is not to write python script from scratch, but to save your streams as a python script from the GUI, I remembered that python code is generated only for streams, not for emulated devices or port settings.

High time I fixed that.

File Format infra

The infra is already there. I just need to do some code generation for port settings (Tx mode, port reservation, stream stats etc.) and device groups.

Easy Peasy.

As I started changing the code, I figured out that the infra has access only to the streams, not to port settings or device group config!

Of course, it’s a Save Streams As functionality. Duh!

We do export everything when you save a session, but that is across all ports of all port groups … overkill for what I wanted – an easy way to get customers to start with the Ostinato Python API.

What was needed was to implement a Save As for port configuration.

Like any lazy (read good) programmer, I created copies of streamfileformat.* files into portfilefileformat.* and started making changes.

But soon my conscience kicked in.

We already have infra code duplication between session and streams for open/save. Port open/save was adding to this duplication!

It’s Refactoring time!

I refactored StreamFileFormat and SessionFileFormat classes to use a newly created template class. Some manual testing later, I was confident this was working (and hopefully not causing a regression).

Post the refactoring, I created PortFileFormat abstract and concrete classes and the infra for saving port configuration as a native file format extendable to save as Python script (which is a different save format).

The code was done - but there was no way to invoke it without adding menu items to the GUI.

Frontend

So, I did that next. Plus, the main code to aggregate port settings, all the streams and device groups into a single PortContent structure that will be passed to the file format infra which will in turn write to file.

With all that code done, it was time to test stuff out. It was already late Friday evening, but I couldn’t resist the temptation to try it out.

💥 CRASH!

And that’s where I left it for the weekend.

Came in Monday morning and fixed the crash and things were working fine!

UX Improvement time

Time for some UX enhancements related to this feature.

First, warn the user about overwriting existing configuration when opening a port file.

Open Port File warning

Next up - add code to enable drag-drop of Ostinato port files (.oprt)

Drag and drop to open a port file

Let’s add some icons to the Port open/save.

Icons for Open/save port profile menu actions

For good measure I added some icons to the existing Open/Save of Session and Streams which till now didn’t have any icons

Icons for existing Open/Save session and Stream actions

Next, I extracted the port related actions into a new top-level menu.

New "Ports" menu in the main menu bar

and added a prompt/warning when saving streams.

Warning when saving streams

Consistent Terminology

After these changes, the phrase Port Configuration now includes streams and device groups also. So renamed a few things in the UI - the erstwhile Port Configuration is now Port Settings to avoid confusion.

Port Configuration menu action is now Port Settings

Port settings dialog also updated to use Settings instead of Configuration

Post the renaming in the software, updated the user facing documentation as well.

User Guide updated to use consistent Port Settings and Port Configuration terminology

Save port config as Python

Finally, with the save port config infra now available, migrated the Save streams as python script to Save port config as python script by adding port settings and device groups to the code generation.

Save port as Python now generates code for port settings and device groups too

Documentation

Added a port save/open page to the user guide.

User guide updates for Open/Save Port configuration

And updated the API guide to use Save port as Python option instead of Save streams as Python.

API guide now recommends using Save Port Configuration as Python script

Updated internal developer documentation for future reference

Internal design documentation for the file format infra

And with that, it’s a wrap for this feature!

Leave a Comment