Blog Options
Archive
<< May 2018 >>-
Friday 18
- Real-time communications with WebSockets in TMS WEB Core applications -
Monday 7
- May 25 is TMS XData training day, the day after TMS RADical Web Day
- Statistics extension for TMS Analytics & Physics developing library
Authors
- Adrian Gallero (19)
- Bernard Roussely (1)
- Bruno Fierens (182)
- Marcos Douglas B. Santos (4)
- Nancy Lescouhier (32)
- Pieter Scheldeman (10)
- Roman Yankovsky (1)
- Wagner R. Landgraf (52)
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;
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.
May 25 is TMS XData training day, the day after TMS RADical Web Day
Bookmarks:Monday, May 07, 2018
Our TMS XData expert Wagner R. Landgraf travels from Brasil to Germany especially for the TMS RADical Web training day on May 24th at Marienfeld, Germany. TMS XData is the tool for Delphi developers to enable creating fast, easy and secure REST APIs to access cloud databases from desktop, mobile and web client applications. As there is a demand for in-depth training on this powerful TMS XData product, we decided to also offer a possibility for training on TMS XData on May 25th, the day after the TMS RADical Web training day and available for an ultra limited number of developers to ensure a personal, hands-on and very interactive training.TMS XData Training Day (all sessions in English)
09h00 - 09h30
Welcome, coffee, meeting
09h30 - 10h30
1. Introduction to TMS Sparkle and TMS XData
a) Presenting TMS Sparkle concepts: http.sys, modules, example server
b) Creating a XData module with a “hello world” operation
c) XData overal concepts: service operations and entities
10h30 - 11h00
Coffee break / Instructor available for questions and discussion
11h00 - 12h00
2. Service Operations
a) Creating service operations - interface and implementation
b) Parameter passing: in body, in url
c) Supported parameter types: scalar, structured and PODO
d) Parameter by reference
e) Memory Management
f) Using/receiving TStream
12h00 - 13h30
3-course warm lunch / instructor available for questions and discussion
13h30 - 15h00
3. Database access
a) “Traditional” approach
b) Connection Pool
c) Aurelius integration in service operations
d) Entity publishing: CRUD operations
e) Querying, paging and counting entities
f) Entity set permissions
15h00 - 15h30
Coffee break / Instructor available for questions and discussion
15h30 - 16h15
4. Desktop client-side development
a) TXDataClient overview
b) Invoking service operations
c) CRUD operations from client
d) Memory management
16h15 - 17h00
5. Web client-side development
a) TXDataWebClient overview
b) TXDataWebDataset usage
c) Asynchronous paradigm
17h00 - 17h30
Closing, questions and answers.
Alternative advanced topics that can be handled on-demand:
a) JWT and authentication
b) Server-side events
c) Custom error-handling in server
d) Swagger/OpenAPI
The TMS XData training day price is 295EUR. For Delphi developers attending both the TMS RADical WEB training day and TMS XData training day, price is 395EUR. Contact us directly by email sales@tmssoftware.com for registrations. Contact us as quickly as possible as registration is on a first-come, first-serve basis.
Bruno Fierens
Bookmarks:
This blog post has not received any comments yet. Add a comment.
Overview of what's coming on the TMS RADical Web Day, May 24th in Germany
Bookmarks:Sunday, April 29, 2018
Here is an overview of what is waiting for you on the first TMS RADical Web Day on May 24th in Germany! You will experience first-hand from the experts of TMS software and Embarcadero all details, inner-workings, examples, architecture, roadmap, binding to server, etc... for exciting new ways to create modern web applications for Delphi developers.Check the full details and registration form link here: https://www.tmssoftware.com/site/tms-training-day-20180524.asp?ln=EN
The TMS software team looks forward to see you. Don't hesitate and sign-up for this exceptional training day!
Bruno Fierens
Bookmarks:
This blog post has not received any comments yet. Add a comment.
Previous | Next | Index