Hi,
I’m very new in root programming and i want use root for visualization of forex market data.
I have a big Database with a self-made structure, which holds the forex data for example EUR/USD.
Is it possible to read in data from a odbc database which have a user-defined structure ??
Can i read in data into root from a TCP/IP server ??
1 Like
linev
October 21, 2017, 3:31pm
2
Hi,
There are ODBC-support classes in ROOT
https://root.cern/doc/master/classTODBCServer.html#a4987eb3b668c79b453df5c847cd22f68
You can request any kind of information, using standard SQL syntax.
Here example macro how SQL classes (including ODBC) can be used:
/// \file
/// \ingroup tutorial_sql
///
/// \macro_code
///
/// \author Sergey Linev
#include <TSQLServer.h>
#include <TSQLResult.h>
#include <TSQLRow.h>
void sqlselect()
{
TSQLServer *db = TSQLServer::Connect("mysql://localhost/test","nobody", "");
printf("Server info: %s\n", db->ServerInfo());
TSQLRow *row;
TSQLResult *res;
This file has been truncated. show original
There is also TSocket class, while allows to open server and client sockets.
https://root.cern/doc/master/classTSocket.html
Examplse you will find in tutorials/net like hserv.C or hclient.C
Regards,
Sergey
Hi Linev,
cool, now i can connect to my Server. But i have written my server with windows sockets and i transmit a data structure.
I have imported the structure in root and noticed that the structure alignment is different from the alignment in my server.
Visual Studio 2013 Server:
typedef struct { … }s_TCP_IP_SEND_BUFF_t;
…
iResult = send(ClientSocket[ui32_Counter], (char *)&s_TCP_IP_SEND_BUFF, sizeof(s_TCP_IP_SEND_BUFF), 0);
Root 5.34/36 Client
typedef struct { … }s_TCP_IP_SEND_BUFF_t;
…
int ret = sock->RecvRaw((void *)(&s_TCP_IP_SEND_RECV), sizeof(s_TCP_IP_SEND_RECV_t));
linev
October 22, 2017, 8:12am
4
Simplest solution for alignment - use data types which are 8-bytes aligned. Like int64_t or double, but not bool.
This type in one system is 16 bytes, and in the other it is 12 byte.
>typedef struct s_test_t
{
uint8 ui8_v1;
uint64 ui64_v2;
}s_test_t;
I started to add padding bytes like
>typedef struct s_test_t
{
uint8 ui8_v1;
uint32 ui32_PADDING_0;
uint64 ui64_v2;
}s_test_t;
to make it the same size. The reason is that i must adapt the root types to the server types. It’s not possible to
adapt the server in this case.
linev
October 23, 2017, 4:56pm
6
If you cannot change server code, you can use #pragma pack as described here . Code will look like:
#pragma pack(push, 1) // exact fit - no padding
struct MyStruct
{
char b;
int a;
int array[2];
};
#pragma pack(pop) //back to whatever the previous packing mode was
But most probably, you will need to run macro in compiled mode.
system
Closed
November 6, 2017, 4:56pm
7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.