Category Archives: Programming

MariaDB adds NoSQL features to relational database roots

SUMMARY:MariaDB 10 is out, featuring a “Connect engine” that makes it easier to handle data from both traditional SQL databases and more web-scale NoSQL systems. The new functionality merits new editions of the MariaDB Enterprise and Enterprise Cluster products.

SkySQL has released new versions of MariaDB Enterprise and MariaDB Enterprise Cluster, promising that these editions will combine the consistency of traditional SQL database technology with the scalability of NoSQL.

It’s now almost a year since SkySQL merged with Monty Program, bringing back together a lot of the old MySQL team — around 50 of them, including Monty Widenius and David Axmark — to take on the current MySQL proprietor, Oracle, with the MariaDB fork of the venerable database system.

MariaDB was always pitched as a “bridge” between MySQL and NoSQL databases like Cassandra and LevelDB. Now the MariaDB Foundation has released version 10of the open-source database, bringing in several NoSQL-esque capabilities that make MariaDB Enterprise 2 a more enticing package.

The big addition is the Connect engine, which provides quick access to unstructured files, for example log files in a folder, from within MariaDB. Cassandra data can also be accessed from within MariaDB 10, and “dynamic columns” also allow NoSQL-style storage of variously-labelled objects in each row. Apart from that, MariaDB 10 is also supposedly much faster and more stable than previous versions.

SkySQL sales chief Dion Cornett suggested to me that enterprise users would find value in being able to glue together the various file and data formats they might encounter.

“What if your online store sells and fulfills orders from a broad range of different suppliers, and your systems must access and combine their inventory records — stored in different SQL databases from Oracle to MySQL to PostgreSQL to SQL Server?” Cornett posited. “Combining such different data sources together in real time has required a lot of hand-coded logic — a costly and time-consuming proposition.”

As for MariaDB Enterprise Cluster 2, a new user console and management API aims to simplify the deployment of Galera clusters, a movement that should appeal to those with high-availability needs.

via: http://gigaom.com/2014/03/31/mariadb-adds-nosql-features-to-relational-database-roots/

New features of SQL Server 2014

image

In the last edition of TechEd USA (May 2013), Microsoft announced what the future SQL Server 2014 would be like, and since then more information and preliminary test versions have continued to be released so that we can all be preparing little by little.

The final version is here! it has been launched on April 1st and it will become available to the general public on the 15th day of the same month.

With SQL Server 2014, Microsoft is focusing on everything that has to do with performance, scalability, integration with the cloud and Big Data management features.

Although these are the main improvement areas, the new version actually includes hundreds of little enhancements, performance tunings and solutions for small bugs. On MSDN we can find a comprehensive list of new features, grouped into areas, but here I will highlight the most important ones.

First we have “Hekaton”, the impressive OLTP engine developed together with Microsoft Research. It is a new engine for the data manager that uses especially optimized tables to reside in memory, without the typical constraints related to data management on disk, which makes performance gains spectacular. Microsoft is speaking of up to 30 times faster applications when they are designed to make use of Hekaton, and an average x10 speed gains in other applications (here you have a specific PDF on the subject). In fact, these in-memory tables can be marked as persistent (and saved to disk) or “schema only duration”, in which case only their definition is saved and they are ideal for temporary heavy tasks, such as transformations, data load, temporary tables, cache, etc. The use of SSD disks to increase the memory available for Hekaton is also allowed.

SQL-Server-2014-Hekaton-perf

Secondly, the acclaimed high availability “AlwaysOn” feature introduced in SQL Server 2012 has evolved and now adds new functionalities such as support for up to 8 secondary replications (before they used to be 4) which work for reading even in the event of network failures, and the possibility of using shared storage to improve resilience to failures. There are also improvements in the time needed for certain complex maintenances (such as rebuilding partition indexes) which will make databases available for longer.

Other features that we can highlight are:

  • A much improved query optimizer. It’s the data engine component in charge of creating and optimizing query plans.
  • Mixed environments on the cloud made easy—you can have the transaction log and data stored in a Windows Azure Storage account but having the transactions processed on your local servers. Also, the data can be encrypted in Azure, but the encryption keys are stored on your local machine for greater security and privacy.
  • New security permissions for users and roles—connecting to future databases, impersonating any other user, being able to alter any database and performing SELECTs on any database (without writing).
  • Greater control over resource isolation, including the ability to set the maximum and minimum number of input/output operations (IOPS) for each storage volume used.
  • Delayed durability transactions. In order to reduce latency, transactions can be defined in this way and thus they will return control to the client before the corresponding registry is written into the Log.
  • Improvements in the free tool for backups to Azure which facilitate performing them fromSQL Server 2005 onwards. We can also save and retrieve a backup directly from a mere URL.
  • Encryption of backups, both in locally made copies and those sent to Azure.

You can find detailed information, with datasheets, whitepapers and technical presentations in the Microsoft SQL Server 2014 CTP2 Product Guide.

via: http://www.campusmvp.net/blog/new-features-sql-server-2014

Modbus with C#: libraries, code, utilities and examples

In this post you will find how to use nModbus with C# and how to create a simulation enviroment to test your program with Modbus.
Other useful resources that you can find in this post are:

  • using a Modbus simulator
  • Creating virtual Com ports
  • Using sniffer tools to debug the transmission
  • A Modbus TCP Client in C# with another library

Getting NModbus

The C# library that i use the most when i need Modbus communication between pc and plcs or other components is nModbus.
nModbus manages both Modbus TCP and RTU protocols, it’s well tested and sources are available. The site for nModbus is http://code.google.com/p/nmodbus/and here you can get the latest sources.

Once you extract the sources you can open the solution file, located in the src folder.

Sample code

NModbus contains many samples included in the source code. Once you open it, you can watch at the MySample project that contains many examples on how to read and write using different devices:

The two examples that i use the most are Modbus TCP and RTU, and an example of the code to use the library is this:

Modbus TCP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 *  Reading
 */
TcpClient client = new TcpClient("127.0.0.1", 502);
ModbusIpMaster master = ModbusIpMaster.CreateIp(client);
// read five input values
ushort startAddress = 100;
ushort numInputs = 5;
bool[] inputs = master.ReadInputs(startAddress, numInputs);
for (int i = 0; i < numInputs; i++)
    Console.WriteLine("Input {0}={1}", startAddress + i, inputs[i] ? 1 : 0);
/*
 *  Writing
 */
ushort startAddress = 1;
// write three coils
master.WriteMultipleCoils(startAddress, new bool[] { true, false, true });

Modbus RTU

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
SerialPort port = new SerialPort("COM1");
// configure serial port
port.BaudRate = 9600;
port.DataBits = 8;
port.Parity = Parity.None;
port.StopBits = StopBits.One;
port.Open();
// create modbus master
IModbusSerialMaster master = ModbusSerialMaster.CreateRtu(port);
byte slaveId = 1;
ushort startAddress = 1;
ushort numRegisters = 5;
// read five registers
ushort[] registers = master.ReadHoldingRegisters(slaveId, startAddress, numRegisters);
for (int i = 0; i < numRegisters; i++)
    Console.WriteLine("Register {0}={1}", startAddress + i, registers[i]);
byte slaveId = 1;
ushort startAddress = 1;
// write three coils
master.WriteMultipleCoils(slaveId, startAddress, new bool[] { true, false, true });

Depending on the registers that you are going to read and write you have different methods, that will call the different functions of the protocol, and that will return the results in 2 formats: ushort or bool (if you are reading multiple registers you will get array of ushorts and bools).

ITDONOTWORK

NModbus is supported by thousands of users, and you can find help on the NModbus google Group.

Testing your program with a simulation:

The most common Modbus simulator is located at http://www.plcsimulator.org/

This simulator provides both Modbus TCP and RTU protocols, and shows the content of the registers in the main windows so you can analyze the behaviour of your program directly in the tables of the simulator.

Creating Virtual COM Ports to test Modbus RTU:

While it’s easy to use TCP to analyze the Modbus TCP on the host (just create a socket with a 127.0.0.1 ip), testing Modbus RTU or ASCII may require some hardware, like a null-modem cable and 2 COM Ports.
To avoid this you can download a null modem emulator called Com0Com (open source, located at http://sourceforge.net/projects/com0com/) to create a pair of virtual com ports wich you can use to connect your simulator and software.

Sniffer tools available for free:

If you need to analyze the traffic between the 2 devices, to see what’s going on with your communication, there are 2 useful tools:
Wireshark is used to sniff ethernet packets and to decode the protocol. This tool can decode Modbus TCP protocol quite good and it’s useful to debug the transmission.
Free Serial Port Monitor is a serial port sniffer that can analyze the transmission between 2 COM Ports.

Other Modbus TCP libraries:

a good Modbus TCP library is available athttp://www.codeproject.com/Articles/16260/Modbus-TCP-class

This library offers a client with some interesting features and it’s also useful when debugging devices.

via: http://www.mesta-automation.com/modbus-with-c-sharp-libraries-examples/