Visual Studio MFC

This is just an auto-generated demo (new application) using Visual Studio/MFC. I use Visual Studio Community so you can download this and try for yourself. I switched from DOS to Windows back in early 90’s using Windows SDK and C at first – I remember the day I got my hands on Visual C++ 1.0 and the first version of MFC – it was a big difference. The best part was the debugger that set a new standard.

The content of the views about are demos – not functional, but the components are very real. You see a TreeView at left and a very good Property Editor at left + what you don’t see is a very good docking system. The app mimic an earlier version of Visual Studio.

Graphics in MFC is GDI by default, but you can use GDI+ with a trick – meaning modern precentation graphics through CPU.

Comparing MFC to Qt I would chose MFC any day, but Visual Studio only have C#/WPF that can compete with Qt/QML.

And as for MFC – I have used this for years as a Windows GUI developer, but it is few that uses this today – firstly it has a steep learning curve so few know it. But, Microsoft don’t focus on this anymore sot it is more or less abandoned. It does not receive the wealth of new components and infrastructure as .NET does.

Comparing Qt/QML to .NET/Core + WPF – I don’t know. C# is much easier to develop with than QML, but I have never dug into the WPF side. The reason I currently work on QML is the access to the GPU’s. QML is easy to work with on graphics, but bindings to C++ makes it difficult unless you want to develope everything in JavaScript. The main drawback with QML is that you don’t get a flying start as the one above – but, that will change soon.

MFC brings back many good memories about things that worked as expected – I will not claim that it is easy to code in, but it is no worse than Qt to be gentle.

The challenge however is that this is Windows Desctop only and for that it is great – but, applications these days needs to be precent on Web, Windows, Linux, iMac, tablets and phones – and it will be interesting to see if Qt/QML delivers on those.

The demo above have some important learnings – Wizards & Templates to get started is worth a few days, but their not the ones getting the job done as you work day by day, month after month on a system. The Property Editor is a good source for ideas, but not everything is perfect. I will do better. As for docking system – Wait & See.

ST/STM32 SW Quality

I have written about this issue before, but ST never fail to suprice me on their SW quality – crap that don’t work: Bugs, bugs and bugs!

I updated STM32CubeIDE to version 1.6.0 yesterday and discovered that the IDE fail to load the images – I had to default to STM32-Link Utility to be able to load the image. Reading on other peoples work I see that I now need to download OpenOCD.

I wanted to test a USBCAN created with STM32F105RB and auto-created a project using the newest HAL driver from ST – guess what – it does not compile, so I tried 1.8.2 and it does not compile, but finally 1.8.1 compiled out of the box – this is serious crap!

The third error is the USB. USB work straight up on other MCU’s, but not on STM32F105fRB – I can’t rule out that this is a HW fault yet, but I have this working on STM32F405RG so I think the answer is that I ditch STM32F105 from my designs.

Don’t take me wrong – I am a big fan of ST MCU’s, but I am a bigger fan of things that actually works out of the box and it’s been far to many critical issues with ST’s software quality over the years. This is not exacly the first entry I make about ST and their SW quality. They are not at the lever they need to be on!

STM32CubeIDE is great – they had one of the best debuggers I have seen. I use OpenOCD on different projects, so it will be interesting to see how this works out – but, ST’s debugger seemed to work much better with debugging on multiple projects – that was before they screwed it up. I actually re-installed from scratch yesterday as well. I will dig into OpenOCD latar,

BSA – Color Palettes

Setting up all the colors needed for controls is actually a bit of job because you need a set of colors for (1) Normal display, (2) Mouse Hover, (3) different states. In this case I show a button so I need Pressed. And for each set I need background, text and border etc. So, if you see only a few properties now – just wait.

I need all the properties available, but at the same time I don’t want to fiddle with them. So, what I will do is to set up a Palette system where you chose the value “Palette” meaning that colors are preset in a global paletter that support global themes. So if you want to change a color you can either change the Palette – in which case you change it for all objects, or you can set the color directly as shown above. In the later case you change it for “this” control only. But, at the end of the day I just want to drop in controls and not worry about fiddly details like colors – I just chose a theme for my application.

BSA – Text Edit 2

My previous entry raised the issue about how to edit multi-line text. The illustrations below show one possibility.

In this case I illustrate a description – something I want on every object. This is a normal property, but since it is a multi-line text it servers little purpose to display it on a few characters like a normal property. A possible solution is shown below.

As you expand the property to edit it I can pop out a small mini-editor to make it easier to edit this exact property type. As editing is done we collapse it back in. The only drawback is that we now need to expand the text field every time we want to read it – which make it less available/readable. But, it’s an idea.

BSA – Text Edit

This shows the Note – the Note is a tool allowing you to write text with a Note border around it and it can be linked to obkects with lines etc – a handy way to make comments.

However – how do we edit the note? (1) display the full note, while (2) display the property editor version – ok it will look better once I allow multi-line text in the editor, but that is not the point – how should we edit the content of that note?

The answer is straight forward – directly in (1)! Double click on the node and you go into inline edit mode. This is one example where editing in the Property Editor makes no sense because an inline editor will be so more awesome. And even better is that while we edit we can as well show specialized text tools and even capabilities to add images inside text etc.

BSA – Property Editor

Don’t worry – you will hear a lot about the Property Editor. The one you see above is yet a simple one. I am still using string edit for colors, but it works fine due to the nature of JavaScript. JavaScript accept colors in string format by name or #xxxxxxxx. (ARGB format). I will add a proper dialog option for that later – but guess what – I wait for BSA to generate that dialog for me 😊.

The top 3 lines for each HMI object will be standard – a display of what control this is, the local name and the full name – currently you see the full name only. The name of the control is β€œedit1”, but since this is located on β€œform1” you get β€œForm1.edit1” – or more correctly β€œFrom1…” since I have a spelling error 😊.

I currently lack a lot of properties here like x,y,width,height etc. I will also need options to expand category trees and sort properties. And well – I did mention specialized edit dialogs.

One of the most wanted is actually a multi-line text editor. I want this to expand using the full width so you get a mini editor and optionally expand into a full window if needed. Adding comments and having proper tools to do so is important.

The Property Editor is important because it enable me to easily and uniformly edit all details of a diagram. The alternative would have been to create dialogs for everything and use double-click etc. With a property editor you only select the component and change properties watching the changes apply as you change them. A Property Editor is however not ideal for every property – descriptions etc is one of them, but you also have information that needs a table presentation. Forms itself need a hierarchy tree so you can see a list of content and control appearance if controls are located on top of each other.

The options I have is to (1) use trees, (2) use pages and (3) use edit buttons where you pop into a specialized dialog. One of the pages I probably need is the event list and bindings for it – not sure – I actually plan an event selector as part of some diagrams, but every form and component are a source of events + how do I handle this before the diagrams are in place etc – I need to think about that one.

BSA – Dialog Design

I am reaching a point where my illustrations regarding BSA are more and more the real thing. Property Editor is now real so I can start edit the components and add properties. I have a few days work setting up correct properties and then I will deal with saving and loading projects and a few other outstanding issues before I am on to generating code. Or well – don’t worry – I have plenty of work left yet.

Keep in mind that BSA uses Universal Diagrams, so unlike other design tools you can draw multiple things on the same diagram. In the illustration above I have drawn multiple dialogs. Each dialog has a Name, each component have an unique name within that dialog. Each dialog only cares about the component located on top of itself – so it is perfectly legal and beneficial to draw multiple dialogs on the same diagram as I have illustrated above.

Only basic components will be build in as the next, big feature is component libraries created by BSA itself. For example standard dialog boxes, gauges etc – I did decide to use a HMI solution fuled by GPU’s for a reason.

I used to design HMI solutions as a profession some 25 years ago, but never jumped on to the web thing. Watching over Web developers making HMI’s I was stunned about how limited their tools was as I have never understood why web developement needed to be worse than classic desktop development. Since the illustration above is a specification I can easily generate it as a Web page, desktop or tablet design at my chosing – without the developer needing to worry to much about the details except one – screen resolution if you use tablets/phones as target.

Qt will deal with execution on multiple platforms, but I do get an extra challenge using Qt – Print Preview and Printing is far from strate forward with that framework, but I will deal with that later.

BSA – DataSource

A critical component for a HMI Frontend is “Data Source”, meaning where is data loaded and saver. HMI alone is worthless unless it is actually connected to something. This can be a remote Modbus device, a database, simple memory structure, file structures etc. BSA will provide the component, but the user must add the source behind this API in ordinary code. This means that if your GUI display the value of a memory variable you need to put this inside a data source so that the GUI is updated every time you change that variable. This also means that updating the GUI now becomes as easy as setting a variable.

Modbus (as an example) is just as easy – you bind a modbus variable to the HMI and as the HMI write you write to the device and as the device update a variable the GUI is updated automatically.

The only difference between the pure HMI version and the later versions is that PLD can use data sources and process data. For now that needs to be done in source code. But, this is still a close to no-code system once you deal with the protocols.

BSA – Sub-diagrams

Yet Another Fake Diagram. The symbols are real, but the links between the symbols are fakes yet… give me a few days. But, the fun is that I have reached a point where it is easier to make illustrations using BSA than Powerpoint.

The illustration show a classic sub-diagram – you have a state symbol that also is a diagram and some tools allow you to see the sub-diagram directly. I can do this, but I am a bit undesided on wherever I want to or not – or the details because it makes no sence to me unless you connect the input and exit points to the diagram edge as illustrated below:

This last version makes it clear what output is used where and make more sence for me since the first one actually could be misleading. I also used the smaller exit symbols in this case to save space, but thats details for later discussions. The actual drawing inside the sub-diagram would have to be scaled – and if I do this it will be an option to display description or this.

I will leave this as an idea for now because I also need to take readability of executable logic into mind. The challenge with diagrams versus actual code is that executable details tends to be hidden and making it more difficult to read/debug logic. I have an idea of how to counter that, but that will be for a later entry.

Update: I have to admit that I don’t see the purpose of displaying sub-diagrams as illustrated above. The reason is because I expect them to be far more complicated than ilustrated here + you can double click and jump to them anyway. As you use a building block you should either trust it or jump in and review/debug it. But, diagrams using a building block should abstract and tell you what it does, not dig into the details of how it does it – this is the exact same way you work if you make a function call in source code.

Navigation between diagrams will be important. KiCad have a nice feature where you can click yoursef into a sub-diagram and use a tool in the toolbar to click yourself back – I think a version of that might be usefully to mavigate between diagrams – or maybe the option to set bookmarks or have a outline tree etc.

BSA – Merging PLD and UML State Diagrams

I have 2 different diagram techniques that overlap PLD and UML State Diagrams. In reality I could merge the two to one and then let it up to the user how detailed the diagrams needs to be. A possible hybrid diagram is shown below.

This diagram is obviously a fake, but I just wanted to illustrate the outcome. The fork and join symbols are excellent for visualizing parallell processing. I am not sure I would keep both UML State and PLD Call symbols because they basically do the same things.

UML State Diagrams are typically drawn horizontally while PLD is drawn vertically. PLD is better at visualizing high level logic, while UML State Diagrams are better at visualizing signal flow in a system. As UML State Diagrams have no logic you will sooner or later need to use something else for that purpose anyway. A diagram in PLD can be a sub-diagram in UML State Diagram and vise versa – in fact PLD only lack the Join and Fork components to be able to draw diagrams that look like UML State Diagrams.

Readers new to PLD will probably be a bit alien to how Plain & PLD deals with signals – a function can have multiple entry points and multiple exit points (events). PLD can visualize events in two ways – one as a straight line since every line in this diagram is an event – or by using the event symbol in cases where you want to. The event symbols actually only visualize the events – they are not needed. Which is why you see them at bottom, but not in other parts of the diagram.

It will be a while before I work on this so I will let the idea rest a bit. If I do this then it basically will be up to the user if he want to stick to UML or draw hybrid diagrams. I never liked the terminals on UML State Diagrams, so making these hybrid terminal symbols make sence since PLD terminals lacked a clear, visual difference between start and exit signals. In reality I could keep the UML State Diagram terminals as internal connection points. This one need some thinking – fun for later.

I am not so fuzzed about wherever I am spot on some UML standard or not – this is not a drawing/modelling tool – it is a programming tool. Your one button away from executable code, and the objective is to create large systems faster and with better quality – the diagrams and symbols are only techniques to achieve that – and yes the demo above looks messy…