Take your chance to win a #ILoveDelphi Mug

Thursday, February 23, 2017

With the many positive responses on our Facebook post about #ILoveDelphi and thanks to the inspiration given by Szabó about ‘the cup and can’, we came up with the idea to bring the love between Delphi and TMS alive in a coffee cup!


Like the mug?

We're going to give away 5 coffee mugs. To make a chance on winning a mug, just add your star rating on our Facebook page together with your review! We will pick 5 winners on Thursday, March 2 and we will send a mug your way!


Good luck to all the participants and thank you in advance for your review! And while you’re at our Facebook page, we also like to invite you to like our Facebook company page if you’re not already following our latest news via this channel.

Nancy Lescouhier


This blog post has received 1 comment. Add a comment.

My Top 10 Aurelius Features - #3 Inheritance

Tuesday, February 21, 2017

How to talk about object-oriented programming and not consider inheritance? In my opinion is a basic "feature" of OOP. And how to talk about an ORM without supporting inheritance? I consider it so important that the simply fact that Aurelius supports it makes it my #3 of My Top 10 Aurelius Features.

It's really nice to be able to model classes and build a class hierarchy, reference classes in that hierarchy from other properties, have a true model that is not just a bunch of plain classes that map properties to database columns. Inheritance support allows you to really think in an OOP way when using an ORM.

TMS Aurelius supports two ways of persisting objects in a class hierarchy in the database:

Joined-tables strategy
Where data from each class is saved in a different database. This is the more normalized way.

Single-table strategy
Where data from all classes are saved in a single table. This is the simplest and often offers better performance.

Regardless of your choice, the facts is that Aurelius allows you to do so! Watch the video above to see how class inheritance works with TMS Aurelius, and if you want to get notified about upcoming videos, subscribe to our YouTube channel!

Wagner R. Landgraf


This blog post has not received any comments yet. Add a comment.

Cross platform messaging made easy with TMS MQTT

Tuesday, February 14, 2017

Last week we released a new product, TMS MQTT. MQTT is a standard lightweight machine 2 machine messaging protocol. This enables the instant exchange of binary or text messages between code running on various operating systems. To fully take advantage of this, we developed our TMS MQTT client to work in VCL Windows applications, FMX Windows, macOS, iOS and Android applications and also on Linux desktop or Linux variants such as Raspbian on Raspberry Pi via FPC/Lazarus.

On this 22th birthday of Delphi, I wanted to show you how our TMS MQTT component allows you to develop a messaging application in a real RAD way. I'll do this by implementing a chat application that allows you to chat between clients running on desktops or mobile devices. This effectively takes less than 40 lines of code using the TMS MQTT component of which 15 lines already go to inserting the chat text left and right in items of an FMX listbox and another +/- 10 lines detecting the origin of the chat text that is received to decide whether to show it left or right in the listbox. So, I'd say only about 15 lines of code effectively concern using the MQTT client to do the messaging.

For this demo, we use the Mosquitto MQTT test broker and connect to it with 2 lines of code:
  TMSMQTTClient1.BrokerHostName := 'test.mosquitto.org';

Upon connecting, we subscribe to the topic /tms/chat/ that is the topic that will be used to exchange chat text between multiple clients. This takes 2 lines of code from the TMQTTClient.OnConnectedStatusChanged() event:
procedure TForm1.TMSMQTTClient1ConnectedStatusChanged(ASender: TObject;
  const AConnected: Boolean);
  if AConnected then
To send a message, text entered in a memo control is published on this topic with one line of code:
  TMSMQTTClient1.Publish('/tms/chat/', TMSMQTTClient1.ClientID+'!'+ memo1.Lines.Text);
Here we add the unique ID of the app sending the chat text and the chat text itself.
Finally, incoming chat text on the subscribed topic is received via the TMQTTClient.OnPublishReceived() event. The unique client ID is retrieved to decide whether to put the chat text left or right of the message listbox and this is done via the code:
procedure TForm1.TMSMQTTClient1PublishReceived(ASender: TObject;
  APacketID: Word; ATopic: string; APayload: TArray);
  msg,orig: string;
  vp: integer;
  alright: boolean;
  msg := TEncoding.UTF8.GetString(APayload);

  vp := pos('!', msg);

  if vp > 0 then
    orig := copy(msg,1,vp-1);
    alright := orig <> TMSMQTTClient1.ClientID;

    msg := copy(msg, vp + 1, Length(msg));
    AddMessage(msg, alright);

And then comes the method to allows us to insert either left or right aligned text as items in an FMX listbox:
procedure TForm1.AddMessage(AMessage: string; AlignRight: boolean);
  li: Tlistboxitem;
  li := Tlistboxitem.Create(self);
  li.StyledSettings := li.StyledSettings - [TStyledSetting.ssOther];
  li.Text := AMessage;
  li.Height := 22;
    li.VertTextAlign := TTextAlign.taTrailing;

  if AlignRight then
    li.TextAlign := TTextAlign.taTrailing
    li.TextAlign := TTextAlign.taLeading;


Compile and run this application on your operating system of choice. In my case, I did setup a small chat between the client compiled for Windows and the client deployed on an iPhone:

You can download the full source code of this FireMonkey application here.

I invite you to explore the numerous exciting capabilities of machine 2 machine messaging. Note that there are JS libs that facilitate to do MQTT messaging via websockets from a webbrowser. The demo included in the TMS MQTT download is based on messaging between a desktop or mobile client app and a web page application. With the TMS MQTT client, you can also use machine 2 machine messaging from your Raspberry Pi and send this way various sensor data captured by the Raspberry Pi to desktop or mobile apps. In a follow-up blog, we'll explain and offer such sample project.

I look forward to hear about how you will use MQTT machine 2 machine messaging in your apps or IoT projects!

Bruno Fierens


This blog post has received 3 comments. Add a comment.

My Top 10 Aurelius Features - #4 Aurelius Dataset

Thursday, February 09, 2017

I consider Aurelius Dataset (TAureliusDataset) a hidden gem of TMS Aurelius. Well, not exactly "hidden" because it's a significant part of it to deserve its own chapter in the Aurelius documentation, but in the sense that it's different from the normal ORM "core" which is update, insert, delete, select, query, etc.. And for that it's #4 of My Top 10 Aurelius Features.

The first misunderstanding about the TAureliusDataset is confusing its usage with the regular way we use Delphi datasets. I've been in discussions in forums with people that were blaming the usage of dataset, because it's not "good practice", because logic should be in the controller/model, etc., etc..

The point is Aurelius Dataset is for data binding. It's not about retrieving data. You will retrieve data the same way with or without the dataset. Your logic, controller and model will still be isolated. But when it comes to show or edit data of an entity in a visual form, you don't have to manually do things like this:
edCustomerName.Text := Customer.Name;
edCustomerCity.Text := Customer.City;
or even worse, to populate a grid or list (pseudo-code):
for Customer in Customers do
  CurrentRow := Grid.AddRow;
  Grid.Columns[0, CurrentRow] := Customer.Name;
  Grid.Columns[1, CurrentRow] := Customer.City;
that's tiresome, repetitive and not necessary with Aurelius Dataset. You just set the "data" of the dataset, which are your objects:
and you bind the dataset to data ware controls! Or to regular controls use live bindings. Or provide the dataset to some report tool.

The coolest thing about the Aurelius Dataset is that its minor features and high integration with Aurelius. It's not just a generic binder between Delphi objects and controls. But it handles smoothly a lot of specific Aurelius features like:

Nullable types
Associations and its sub-properties
Master-Detail (many-valued association as nested datasets)
Enumerated types

and provide the regular dataset mechanisms but adapted to the object-oriented approach, like:

Lookup fields
Calculated fields
Design-time support

And finally, it handles paging and fetching smoothly as well. You can have a criteria that is retrieved page by page on demand, avoiding all objects to be retrieved at once, and at the same time avoiding a cursor to be open to the database!

Watch the video above to see Aurelius Dataset in action, and if you want to get notified about upcoming videos, subscribe to our YouTube channel!

Wagner R. Landgraf


This blog post has not received any comments yet. Add a comment.

Previous  |  Next  |  Index