Blog Options

Archive

<< June 2018 >>

Authors




Article & sample for how to use Embarcadero RAD server as server backend for TMS WEB Core applications

Bookmarks: 

Wednesday, May 30, 2018

TMS WEB Core is a framework for creating web client applications from the Delphi IDE in the Delphi language and using RAD component based development. TMS WEB Core is designed to be totally open in many ways, also with respect to binding to a server back-end. This binding to the server back-end is typically done using REST APIs. TMS software has its own high-performance, flexible and low-cost REST API framework TMS XData for accessing databases on a server but it is equally possible to use node.js, ASP.NET Core microservices, other technologies or also the Embarcadero RAD Server that comes with Delphi (there is now one free license included in the Delphi Enterprise or Architect editions) and that offers a powerful, fast & flexible creation of REST API endpoint servers.

  

Embarcadero MVP, famous speaker and writer of several Delphi books Bob Swart, was excited when he learned about TMS WEB Core and wanted to explore the capabilities of using Embarcadero RAD server as a backend for a TMS WEB Core web client application. Based on the results of his research and work, Bob Swart did the effort to create an article that explains and demonstrates how one can use Embarcadero RAD server with TMS WEB Core from start to finish. There is not only the article that Bob Swart makes available but also the sample source code.

Downloads

Article:

Source code:



Get started today: Technical previews of TMS WEB Core, TMS FNC UI web-enabled controls, web-enabled TMS XData, the first parts under the TMS RADical WEB umbrella are exclusively available now for all active TMS-ALL-ACCESS customers.

Bruno Fierens


Bookmarks: 

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



This was TMS RADical Web Day, May 24 at Klosterpforte, Germany

Bookmarks: 

Monday, May 28, 2018



Without a doubt, this was THE day our team looked forward to as well as many Delphi developers. The TMS RADical Web day was all about devoting a full day to the new web development tools being worked on by the tmssoftware team. We had chosen a place for this event in a peaceful green area of Germany, Klosterpforte, Germany. It would allow us to exchange the latest informations without any distractions from hectic & stressfull city life, away from busy & stressfull days company life typically brings.

With a group of about 40 persons, we not only presented the latest status of the developments of the TMS WEB Core framework, the web-enabled TMS FNC framework, TMS XData REST server technology, Flexcel reporting technology, Embarcadero RAD server technology, but we also listened closely to your needs, suggestions, concerns and questions. In short, we hope not only the attendees learned a lot, our team also learned a lot. In short, it was a very fruitful day. After the TMS RADical Web day, there was an even more in-depth day focused on TMS XData REST server technology. A group of about 10 Delphi developers intensively learned & discussed the many possibilities TMS XData REST server offers.

I especially want to thank for all the hard work delivered from the team present: Wagner Landgraf, Adrian Gallero, Pieter Scheldeman, Roman Kassebaum, Leon Kassebaum, Detlef Overbeek, Mattias Gärtner, Matthias Eissing.

If you missed this event, don't worry. Next, there will be a presentation about TMS Web Core at the Italian Delphi Day on June 7 in Piacenza and there is a meetup planned on June 12 in the offices of TMS software.

If you are hosting other events where you'd wish to see TMS WEB Core in action, please contact us and when feasible we'll consider coming to a place near you!

Meanwhile, the team is hammering out as much as possible the last niggles & issues and working feverishly to bring the first release as soon as possible.

Get started today: Technical previews of TMS WEB Core, TMS FNC UI web-enabled controls, web-enabled TMS XData, the first parts under the TMS RADical WEB umbrella are exclusively available now for all active TMS-ALL-ACCESS customers.

Bruno Fierens


Bookmarks: 

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



Real-time communications with WebSockets in TMS WEB Core applications

Bookmarks: 

Friday, May 18, 2018

TMS WEB Core promises easy, fast and RAD component based web application development. For fast, real-time updates on a web page with light-weight server-communications, WebSockets are an ideal mechanism.
That is why TMS WEB Core also comes with a WebSocket client:

This is a non-visual component that makes it very easy to start using WebSocket based communication. Drop this component on the form, configure the WebSocket hostname & port and call WebSocketClient.Connect. When a connection is established, the OnConnect event is triggered. From the moment of connection, data sent by the WebSocket server is received via the event OnDataReceived. The signature of this event is:

procedure OnDataReceived(Sender: TObject; Origin: string;  Data: TJSObject);

Origin is the WebSocket server sending the data and the data itself is sent as a JavaScript Object. This means it can be different types. Sending data is equally easy. Simply call
WebSocketClient1.Send(AMessage: String);

To create an online chat application using this WebSocket technology takes only a few configurations in the component to configure the WebSocket server and a couple of lines of code. There is the logic that performs the Connect & Disconnect:
procedure TWebForm1.Connect;
begin
  if FConnected then
  begin
    WebSocketClient1.Disconnect;
  end
  else
  begin
    if WebEdit1.Text = '' then
      ShowMessage('Please enter a name first')
    else
      WebSocketClient1.Connect;
  end;
end;

To send a message when connected, we simply send the message as color/sender/message pair via the WebSocketClient.Send() function. Each chat user can choose a color and messages from the user are displayed in his selected color:

procedure TWebForm1.SendMessage;
var
  s: string;
begin
  if FConnected and (WebEdit2.Text <> '') then
  begin
    s := TMSFNCColorPicker1.SelectedColor) + '~' + WebEdit1.Text + '~' + WebEdit2.Text;
    // limit message length
    s := Copy(s,1,256);
    WebSocketClient1.Send(TTMSFNCGraphics.ColorToHTML(s);
    WebEdit2.Text := '';
  end;
end;

To display the message, we use the web-enabled TTMSFNCListBox component from the TMS FNC UI Pack. With this control we can show the received messages in listbox items with banding and some HTML formatting per item to indicate the sender and the message. The message is received via WebSocketClient.OnDataReceived as text and therefore we can use Data.toString to get the JavaScript object as text:
procedure TWebForm1.WebSocketClient1DataReceived(Sender: TObject; Origin: string;
  Data: TJSObject);
var
  it: TTMSFNCListBoxItem;
  sl: TStringList;
  s: String;
  n: string;
  c: TTMSFNCGraphicsColor;
  v: string;
begin
  it := lst.Items.Add;
  s := Data.toString;
  sl := TStringList.Create;
  try
    TTMSFNCUtils.Split('~', s, sl);
    if sl.Count > 2 then
    begin
      c := TTMSFNCGraphics.HTMLToColor(sl[0]);
      n := ''+sl[1]+'';
      v := sl[2];
      it.Text := n + ' says:
' + v; it.TextColor := c; end; finally sl.Free; end; end;

There isn't much more to creating a chat application for your TMS WEB Core applications except of course to put a WebSocket server application on your server that can equally be written with Delphi. With TMS WEB Core we include a sample WebSocket server service application.
Thanks to TMS WEB Core, you can directly see the result of our demo in your favorite web browser, no need to install anything to explore! Head over to http://www.tmssoftware.biz/tmsweb/demos/tmsweb_chatclient/ to start chatting.

TMS WEB Core chat client application running in the Chrome browser

TMS WEB Core chat client application running in the Safari browser on iPhone


Get started today: Technical previews of TMS WEB Core, TMS FNC UI web-enabled controls, web-enabled TMS XData, the first parts under the TMS RADical WEB umbrella are exclusively available now for all active TMS-ALL-ACCESS customers.

Bruno Fierens


Bookmarks: 

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



Statistics extension for TMS Analytics & Physics developing library

Bookmarks:  TMS Analytics & Physics developing library includes many extensions for various mathematical applications: complex numbers, linear algebra, special functions, common fractions, numerical methods. New version 2.4 introduces package for statistical analysis. The extension allows evaluating base statistical properties of real data samples (mean value, median and others), generating sequences of special numbers (Fibonacci, prime numbers and many others), creating arithmetic, geometric and harmonic progressions, working with probability distributions.

It should be noted here, that as the Analytics library allows symbolic evaluations of very complicated formulae, some statistical problems can be solved without using the special package. For an example, the Linear Algebra package includes functionality for processing array and matrix data. So, we can solve, for an example, the following problem: find the sum of ‘A’ array elements those are greater than ‘x’. The result can be calculated with the following code:



The output for the code is the following:



The problem is solved with the ‘if’ function that compares all items of the ‘A’ array with ‘x’ value and generates new array which contains elements of ‘A’ if the condition satisfied and 0 value if not. When the sum of the result array calculated we get the solution of stated problem. The goals of new Statistics package is providing the simplest formula for evaluating base statistical characteristics and solving statistical problems that cannot be solved without specialized library. First, let us consider evaluation of base statistical characteristics of some discrete sample values, stored in ‘A’ array. This can be done with the following code:



For this data, we get the following statistical values:

Mean of A = 0.155625
Median of A = 0.135
Mode of A = 0.1
Variance of A = 0.012124609375
Deviation of A = 0.440447215906742

As can be seen from the code above, every value calculated with one function call. The function ‘Mean{P}(A)’ here evaluates the mean value of the data. This function is parametric and the ‘P’ parameter specifies the ‘power’ of the mean (https://en.wikipedia.org/wiki/Mean#Power_mean). The parameter value can be one of the four: ‘-1’ – harmonic mean, ‘0’ – geometric mean, ‘1’ – arithmetic mean, ‘2’ – quadratic mean. In our case P=1 and we calculated the arithmetic mean of ‘A’. One of the advantages of using the symbolic capabilities of the Analytics library is that, even if some feature is not realized in the package directly, one can use the formula for this feature. Let us consider how to do this for other types of ‘mean’ values. There is so called generalized mean (https://en.wikipedia.org/wiki/Mean#Generalized_means) that is defined by the formula:



where f is a function and f-1 is its inverse. For an example, if f is exponent, then f-1 is natural logarithm. The ‘exponential’ mean function is not provided with the statistical package, but it can be easily evaluated with the following simple formula:



which produces the output:

Exponent Mean of A = 0.161840327746035

The value of ‘exponent’ mean is slightly differs from common arithmetic mean that follows from the different meaning of the characteristics.

One of main features of Statistics package is that it allows working with probability distributions and solve real statistical problems (https://en.wikipedia.org/wiki/Probability_density_function). The version supports 6 distributions: Gauss (normal), Laplace, Cauchy, Gumbel, logistic and exponential. Let us consider the following statistical problem: there is a known probability distribution for lifetime of a bacteria species. Let us suppose the distribution is Gaussian function with parameters µ and s (https://en.wikipedia.org/wiki/Normal_distribution). We need to calculate the probability that the bacteria dies on the time interval [t1..t2].
This probability defined by the formula:



where f(x) is the probability density function (PDF) of the distribution. The value of the probability can be evaluated with the following code:



First, we added the variables for the distribution’s parameters to the translator and variables for the time interval. The function 'GaussPDF{µ s}(t1 t2 100)' produced the array of 100 values for the Gaussian PDF with specified parameters (µ=5 hours, s=0.5 hours) on the specified interval of [5.5..6.0] hours. Then we used numerical integration of the values, replacing the integral with the appropriate summation. The answer for our question is - the probability that the bacteria dies on the interval 5.5-6 hours is about 13.6%. The version 2.4 is already available. Source code of the example application for statistics analysis can be downloaded from here.

Bruno Fierens


Bookmarks: 

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




Previous  |  Next  |  Index