ProcessDB实时/时序数据库——C#读写实时数据

目录

前言

一、实时数据字段介绍

二、根据点名插入实时数据

三、根据点ID插入实时数据

四、根据点名查询实时数据

五、根据点ID查询实时数据


前言

ProcessDB实时/时序数据库支持C#语言开发,本文将针对C#操作ProcessDB库的实时数据的相关操作进行介绍


一、实时数据字段介绍

字段注释
id数据点id
name数据点名

nTagType

数据类型

nQuality

数据质量

nMilliSecond

数据时间(毫秒)

nSecond

数据时间(秒)

nDigital

数字量

bBool

bool类型的值

nuInt8

uint8类型的值

nInt8

in8类型的值

nuInt16

uint16类型的值

nInt16

int16类型的值

nuInt32

uint32类型的值

nInt32

int32类型的值

nuInt64

uint64类型的值

nInt64

Int64类型的值

nTime

time时间类型的值

fFloat32

float32类型的值

fFloat64

float64类型的值

二、根据点名插入实时数据

ProcessDB支持根据点名列表,批量插入实时数据

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProcessDB;

namespace Data_RealTime
{
    class Program
    {  
        static void Main(string[] args)
        {
            TestRealTime testRealTime = new TestRealTime();
            int res = testRealTime.RealTimeTest();
        }
    }

    public class TestRealTime
    {
        public class pointlist
        {
            public string pointname { get; set; }
            public int pointid { get; set; }
            public DATA_TYPE datatype { get; set; }
        }

        static int add_realtime_data_by_name(string pointname, DATA_TYPE datatype)
        {
            /* 根据点名称添加实时数据到容器 */
            int i = 1;
            float val = i * 2.3f;
            byte val1 = 0;
            byte val2 = 2;
            short val3 = 3;
            int val4 = 4;
            long val5 = 5;
            float val6 = i * 3.4f;
            MemSampleRecord memSampleRecord = new MemSampleRecord();
            memSampleRecord.nTagType = (byte)datatype;
            switch (memSampleRecord.nTagType)
            {
                case (byte)DATA_TYPE.TAG_TYPE_FLOAT32:
                    memSampleRecord.fFloat32 = val;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_DIGITAL:
                    memSampleRecord.nDigital = val1;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_UINT8:
                    memSampleRecord.nUInt8 = val2;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_INT8:
                    memSampleRecord.nInt8 = val2;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_UINT16:
                    memSampleRecord.nUInt16 = val3;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_INT16:
                    memSampleRecord.nInt16 = val3;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_UINT32:
                    memSampleRecord.nUInt32 = val4;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_INT32:
                    memSampleRecord.nInt32 = val4;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_UINT64:
                    memSampleRecord.nUInt64 = val5;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_INT64:
                    memSampleRecord.nInt64 = val5;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_FLOAT64:
                    memSampleRecord.fFloat64 = val6;
                    break;
            }
            int res = ProcessDBDao.getInstance().add_realtime_data_to_update_builder_by_name(pointname, ref memSampleRecord);
            if (0 != res)
            {
                Console.WriteLine("add {0} realtime_data to builder by name failed!error code: {1}", pointname, res);
                return res;
            }
            else
            {
                switch (memSampleRecord.nTagType)
                {
                    case (byte)DATA_TYPE.TAG_TYPE_FLOAT32:
                        Console.WriteLine("Using pointname add realtime data to update builder succeed! pointname: {0} seconds: {1}, status: {2}, value: {3}", pointname, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.fFloat32);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_DIGITAL:
                        Console.WriteLine("Using pointname add realtime data to update builder succeed! pointname: {0} seconds: {1}, status: {2}, value: {3}", pointname, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nDigital);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT8:
                        Console.WriteLine("Using pointname add realtime data to update builder succeed! pointname: {0} seconds: {1}, status: {2}, value: {3}", pointname, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nUInt8);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT8:
                        Console.WriteLine("Using pointname add realtime data to update builder succeed! pointname: {0} seconds: {1}, status: {2}, value: {3}", pointname, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nInt8);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT16:
                        Console.WriteLine("Using pointname add realtime data to update builder succeed! pointname: {0} seconds: {1}, status: {2}, value: {3}", pointname, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nUInt16);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT16:
                        Console.WriteLine("Using pointname add realtime data to update builder succeed! pointname: {0} seconds: {1}, status: {2}, value: {3}", pointname, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nInt16);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT32:
                        Console.WriteLine("Using pointname add realtime data to update builder succeed! pointname: {0} seconds: {1}, status: {2}, value: {3}", pointname, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nUInt32);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT32:
                        Console.WriteLine("Using pointname add realtime data to update builder succeed! pointname: {0} seconds: {1}, status: {2}, value: {3}", pointname, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nInt32);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT64:
                        Console.WriteLine("Using pointname add realtime data to update builder succeed! pointname: {0} seconds: {1}, status: {2}, value: {3}", pointname, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nUInt64);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT64:
                        Console.WriteLine("Using pointname add realtime data to update builder succeed! pointname: {0} seconds: {1}, status: {2}, value: {3}", pointname, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nInt64);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_FLOAT64:
                        Console.WriteLine("Using pointname add realtime data to update builder succeed! pointname: {0} seconds: {1}, status: {2}, value: {3}", pointname, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.fFloat64);
                        break;
                }

            }
            /* 将容器中的数据提交到实时数据库里 */
            res = ProcessDBDao.getInstance().exec_update_realtime();
            if (0 != res)
            {
                Console.WriteLine("execute update realtime failed!error code: {0}", res);
                return res;
            }
            else {
                Console.WriteLine("execute update realtime succeed!");
            }
            return 0;
        }

        public int RealTimeTest() {
            int res = 0;
            /* 初始化连接控制块 */
            res = ProcessDBDao.getInstance().init();
            if (0 != res)
            {
                Console.WriteLine("ProcessDBDao init failed! error code: {0}", res);
                return res;
            }
            /* 建立连接 */
            res = ProcessDBDao.getInstance().connect("127.0.0.1", 8301, "root", "root");
            //res = ProcessDBDao.getInstance().connect("192.168.0.186", 8301, "root", "root");
            if (0 != res)
            {
                Console.WriteLine("login failed! error code: {0}", res);
                return res;
            }
            /* 采样点 */
            var pointlist = new List<pointlist>
            {
                new pointlist{ pointname = "D99.T99.P99", pointid = 1003000009, datatype = DATA_TYPE.TAG_TYPE_FLOAT32},
            };

            /* 通过点名更新实时数据、查询实时数据*/
            for (int i = 0; i < pointlist.Count; i++)
            {

                /* 根据点名更新实时数据 */
                add_realtime_data_by_name(pointlist[i].pointname, pointlist[i].datatype);

            }

            /* 关闭连接 */
            res = ProcessDBDao.getInstance().close();
            return res;

        }

       
    }
}

三、根据点ID插入实时数据

ProcessDB支持根据点ID列表,批量插入实时数据

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProcessDB;

namespace Data_RealTime
{
    class Program
    {  
        static void Main(string[] args)
        {
            TestRealTime testRealTime = new TestRealTime();
            int res = testRealTime.RealTimeTest();
        }
    }

    public class TestRealTime
    {
        public class pointlist
        {
            public string pointname { get; set; }
            public int pointid { get; set; }
            public DATA_TYPE datatype { get; set; }
        }

        static int add_realtime_data_by_id(int pointid, DATA_TYPE datatype)
        {
            /* 根据点id添加实时数据到容器 */
            int i = 1;
            float val = i * 8.9f;
            byte val1 = 1;
            byte val2 = 3;
            short val3 = 4;
            int val4 = 5;
            long val5 = 6;
            float val6 = i * 6.4f;
            MemSampleRecord memSampleRecord = new MemSampleRecord();
            memSampleRecord.nTagType = (byte)datatype;
            switch (memSampleRecord.nTagType)
            {
                case (byte)DATA_TYPE.TAG_TYPE_FLOAT32:
                    memSampleRecord.fFloat32 = val;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_DIGITAL:
                    memSampleRecord.nDigital = val1;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_UINT8:
                    memSampleRecord.nUInt8 = val2;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_INT8:
                    memSampleRecord.nInt8 = val2;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_UINT16:
                    memSampleRecord.nUInt16 = val3;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_INT16:
                    memSampleRecord.nInt16 = val3;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_UINT32:
                    memSampleRecord.nUInt32 = val4;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_INT32:
                    memSampleRecord.nInt32 = val4;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_UINT64:
                    memSampleRecord.nUInt64 = val5;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_INT64:
                    memSampleRecord.nInt64 = val5;
                    break;
                case (byte)DATA_TYPE.TAG_TYPE_FLOAT64:
                    memSampleRecord.fFloat64 = val6;
                    break;

            }
            int res = ProcessDBDao.getInstance().add_realtime_data_to_update_builder_by_id(pointid, ref memSampleRecord);
            if (0 != res)
            {
                Console.WriteLine("add {0} realtime_data to builder by id failed!error code: {1}", pointid, res);
                return res;
            }
            else
            {
                switch (memSampleRecord.nTagType)
                {
                    case (byte)DATA_TYPE.TAG_TYPE_FLOAT32:
                        Console.WriteLine("Using pointid add realtime data to update builder succeed! pointid: {0} seconds: {1}, status: {2}, value: {3}", pointid, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.fFloat32);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_DIGITAL:
                        Console.WriteLine("Using pointid add realtime data to update builder succeed! pointid: {0} seconds: {1}, status: {2}, value: {3}", pointid, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nDigital);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT8:
                        Console.WriteLine("Using pointid add realtime data to update builder succeed! pointid: {0} seconds: {1}, status: {2}, value: {3}", pointid, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nUInt8);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT8:
                        Console.WriteLine("Using pointid add realtime data to update builder succeed! pointid: {0} seconds: {1}, status: {2}, value: {3}", pointid, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nInt8);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT16:
                        Console.WriteLine("Using pointid add realtime data to update builder succeed! pointid: {0} seconds: {1}, status: {2}, value: {3}", pointid, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nUInt16);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT16:
                        Console.WriteLine("Using pointid add realtime data to update builder succeed! pointid: {0} seconds: {1}, status: {2}, value: {3}", pointid, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nInt16);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT32:
                        Console.WriteLine("Using pointid add realtime data to update builder succeed! pointid: {0} seconds: {1}, status: {2}, value: {3}", pointid, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nUInt32);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT32:
                        Console.WriteLine("Using pointid add realtime data to update builder succeed! pointid: {0} seconds: {1}, status: {2}, value: {3}", pointid, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nInt32);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT64:
                        Console.WriteLine("Using pointid add realtime data to update builder succeed! pointid: {0} seconds: {1}, status: {2}, value: {3}", pointid, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nUInt64);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT64:
                        Console.WriteLine("Using pointid add realtime data to update builder succeed! pointid: {0} seconds: {1}, status: {2}, value: {3}", pointid, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.nInt64);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_FLOAT64:
                        Console.WriteLine("Using pointid add realtime data to update builder succeed! pointid: {0} seconds: {1}, status: {2}, value: {3}", pointid, memSampleRecord.nSecond, memSampleRecord.nQuality, memSampleRecord.fFloat64);
                        break;
                }

            }
            /* 将容器中的数据提交到实时数据库里 */
            res = ProcessDBDao.getInstance().exec_update_realtime();
            if (0 != res)
            {
                Console.WriteLine("execute update realtime failed!error code: {0}", res);
                return res;
            }
            else {
                Console.WriteLine("execute update realtime succeed!");
            }
            return 0;
        }

        public int RealTimeTest() {
            int res = 0;
            /* 初始化连接控制块 */
            res = ProcessDBDao.getInstance().init();
            if (0 != res)
            {
                Console.WriteLine("ProcessDBDao init failed! error code: {0}", res);
                return res;
            }
            /* 建立连接 */
            res = ProcessDBDao.getInstance().connect("127.0.0.1", 8301, "root", "root");
            if (0 != res)
            {
                Console.WriteLine("login failed! error code: {0}", res);
                return res;
            }
         
            /* 采样点 */
            var pointlist = new List<pointlist>
            {
                new pointlist{ pointname = "D99.T99.P99", pointid = 1003000009, datatype = DATA_TYPE.TAG_TYPE_FLOAT32}
              
            };

 

            /* 通过点id更新实时数据*/
            for (int j = 0; j < pointlist.Count; j++)
            {
                /* 根据点id更新实时数据 */
                add_realtime_data_by_id(pointlist[j].pointid, pointlist[j].datatype);
              
            }
            /* 关闭连接 */
            res = ProcessDBDao.getInstance().close();
            return res;

        }

       
    }
}

四、根据点名查询实时数据

根据数据点名的集合,批量查询实时数据

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProcessDB;

namespace Data_RealTime
{
    class Program
    {  
        static void Main(string[] args)
        {
            TestRealTime testRealTime = new TestRealTime();
            int res = testRealTime.RealTimeTest();
        }
    }

    public class TestRealTime
    {
        public class pointlist
        {
            public string pointname { get; set; }
            public int pointid { get; set; }
            public DATA_TYPE datatype { get; set; }
        }

        static void get_realtime_data_by_name(string pointname)
        {
            int res = ProcessDBDao.getInstance().add_name_to_query_builder(pointname);
            ProcessDBDao.getInstance().exec_query_realtime();
            /* 根据点名查出实时数据 */
            MemSampleRecord memSampleRecord = new MemSampleRecord();
            res = ProcessDBDao.getInstance().get_realtime_data_by_name(pointname, ref memSampleRecord);
            if (0 != res)
            {
                Console.WriteLine("Using pointName get realTime-data failed! pointname : {0}, error code: {1}", pointname, res);
                return;
            }
            else
            {
                switch (memSampleRecord.nTagType)
                {
                    case (byte)DATA_TYPE.TAG_TYPE_FLOAT32:
                        Console.WriteLine("Using pointName get realTime-data succeed!,pointname: {0}, value: {1}, status: {2}", pointname, memSampleRecord.fFloat32, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_DIGITAL:
                        Console.WriteLine("Using pointName get realTime-data succeed!,pointname: {0}, value: {1}, status:{2}", pointname, memSampleRecord.nDigital, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT8:
                        Console.WriteLine("Using pointName get realTime-data succeed!,pointname: {0}, value:{1}, status:{2}", pointname, memSampleRecord.nUInt8, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT8:
                        Console.WriteLine("Using pointName get realTime-data succeed!,pointname: {0}, value:{1}, status:{2}", pointname, memSampleRecord.nInt8, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT16:
                        Console.WriteLine("Using pointName get realTime-data succeed!,pointname: {0}, value:{1}, status:{2}", pointname, memSampleRecord.nUInt16, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT16:
                        Console.WriteLine("Using pointName get realTime-data succeed!,pointname: {0}, value:{1}, status:{2}", pointname, memSampleRecord.nInt16, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT32:
                        Console.WriteLine("Using use pointName get realTime-data succeed!,pointname: {0}, value:{1}, status:{2}", pointname, memSampleRecord.nUInt32, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT32:
                        Console.WriteLine("Using use pointName get realTime-data succeed!,pointname: {0}, value:{1}, status:{2}", pointname, memSampleRecord.nInt32, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT64:
                        Console.WriteLine("Using use pointName get realTime-data succeed!,pointname: {0}, value:{1}, status:{2}", pointname, memSampleRecord.nUInt64, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT64:
                        Console.WriteLine("Using use pointName get realTime-data succeed!,pointname: {0}, value:{1}, status:{2}", pointname, memSampleRecord.nInt64, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_FLOAT64:
                        Console.WriteLine("Using use pointName get realTime-data succeed!,pointname: {0}, value:{1}, status:{2}", pointname, memSampleRecord.fFloat64, memSampleRecord.nQuality);
                        break;
                }
            }
        }

        public int RealTimeTest() {
            int res = 0;
            /* 初始化连接控制块 */
            res = ProcessDBDao.getInstance().init();
            if (0 != res)
            {
                Console.WriteLine("ProcessDBDao init failed! error code: {0}", res);
                return res;
            }
            /* 建立连接 */
            res = ProcessDBDao.getInstance().connect("127.0.0.1", 8301, "root", "root");
            //res = ProcessDBDao.getInstance().connect("192.168.0.186", 8301, "root", "root");
            if (0 != res)
            {
                Console.WriteLine("login failed! error code: {0}", res);
                return res;
            }
            /* 采样点 */
            var pointlist = new List<pointlist>
            {
                new pointlist{ pointname = "D99.T99.P99", pointid = 1003000009, datatype = DATA_TYPE.TAG_TYPE_FLOAT32}  ,
                 new pointlist{ pointname = "D99.T99.P98", pointid = 1003000010, datatype = DATA_TYPE.TAG_TYPE_FLOAT32} 
            };

            /* 通过点名查询实时数据*/
            for (int i = 0; i < pointlist.Count; i++)
            {
                /* 根据点名查询实时数据 */
                get_realtime_data_by_name(pointlist[i].pointname);

            }

            /* 关闭连接 */
            res = ProcessDBDao.getInstance().close();
            return res;

        }

       
    }
}

示例运行结果:

Using pointName get realTime-data succeed!,pointname: D99.T99.P99, value: 8.9, status: 0
Using pointName get realTime-data succeed!,pointname: D99.T99.P98, value: 999, status: 0

五、根据点ID查询实时数据

根据数据点ID的集合,批量查询实时数据

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProcessDB;

namespace Data_RealTime
{
    class Program
    {  
        static void Main(string[] args)
        {
            TestRealTime testRealTime = new TestRealTime();
            int res = testRealTime.RealTimeTest();
        }
    }

    public class TestRealTime
    {
        public class pointlist
        {
            public string pointname { get; set; }
            public int pointid { get; set; }
            public DATA_TYPE datatype { get; set; }
        }

        static void get_realtime_data_by_id(int pointid)
        {
            int res = ProcessDBDao.getInstance().add_id_to_query_builder(pointid);
            ProcessDBDao.getInstance().exec_query_realtime();
            /* 根据点id查出实时数据 */
            MemSampleRecord memSampleRecord = new MemSampleRecord();
            res = ProcessDBDao.getInstance().get_realtime_data_by_id(pointid, ref memSampleRecord);
            if (0 != res)
            {
                Console.WriteLine("Using pointID get realTime-data failed! pointid : {0}, error code : {1}", pointid, res);
                return;
            }
            else
            {
                switch (memSampleRecord.nTagType)
                {
                    case (byte)DATA_TYPE.TAG_TYPE_FLOAT32:
                        Console.WriteLine("Using pointID get realTime-data succeed! pointid:{0}, value:{1}, status:{2}", pointid, memSampleRecord.fFloat32, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_DIGITAL:
                        Console.WriteLine("Using pointID get realTime-data succeed! pointid:{0}, value:{1}, status:{2}", pointid, memSampleRecord.nDigital, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT8:
                        Console.WriteLine("Using pointID get realTime-data succeed! pointid:{0}, value:{1}, status:{2}", pointid, memSampleRecord.nUInt8, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT8:
                        Console.WriteLine("Using pointID get realTime-data succeed! pointid:{0}, value:{1}, status:{2}", pointid, memSampleRecord.nInt8, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT16:
                        Console.WriteLine("Using pointID get realTime-data succeed! pointid:{0}, value:{1}, status:{2}", pointid, memSampleRecord.nUInt16, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT16:
                        Console.WriteLine("Using pointID get realTime-data succeed! pointid:{0}, value:{1}, status:{2}", pointid, memSampleRecord.nInt16, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT32:
                        Console.WriteLine("Using pointID get realTime-data succeed! pointid:{0}, value:{1}, status:{2}", pointid, memSampleRecord.nUInt32, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT32:
                        Console.WriteLine("Using pointID get realTime-data succeed! pointid:{0}, value:{1}, status:{2}", pointid, memSampleRecord.nInt32, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_UINT64:
                        Console.WriteLine("Using pointID get realTime-data succeed! pointid:{0}, value:{1}, status:{2}", pointid, memSampleRecord.nUInt64, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_INT64:
                        Console.WriteLine("Using pointID get realTime-data succeed! pointid:{0}, value:{1}, status:{2}", pointid, memSampleRecord.nInt64, memSampleRecord.nQuality);
                        break;
                    case (byte)DATA_TYPE.TAG_TYPE_FLOAT64:
                        Console.WriteLine("Using pointID get realTime-data succeed! pointid:{0}, value:{1}, status:{2}", pointid, memSampleRecord.fFloat64, memSampleRecord.nQuality);
                        break;
                }
            }
        }
        public int RealTimeTest() {
            int res = 0;
            /* 初始化连接控制块 */
            res = ProcessDBDao.getInstance().init();
            if (0 != res)
            {
                Console.WriteLine("ProcessDBDao init failed! error code: {0}", res);
                return res;
            }
            /* 建立连接 */
            res = ProcessDBDao.getInstance().connect("127.0.0.1", 8301, "root", "root");
            //res = ProcessDBDao.getInstance().connect("192.168.0.186", 8301, "root", "root");
            if (0 != res)
            {
                Console.WriteLine("login failed! error code: {0}", res);
                return res;
            }

            /*数据点 */
            var pointlist = new List<pointlist>
            {
               new pointlist{ pointname = "D99.T99.P99", pointid = 1003000009, datatype = DATA_TYPE.TAG_TYPE_FLOAT32}  ,
               new pointlist{ pointname = "D99.T99.P98", pointid = 1003000010, datatype = DATA_TYPE.TAG_TYPE_FLOAT32}
            };


            /* 通过点id查询实时数据*/
            for (int j = 0; j < pointlist.Count; j++)
            {
                /* 根据点id获取实时数据 */
                get_realtime_data_by_id(pointlist[j].pointid);
            }


            /* 关闭连接 */
            res = ProcessDBDao.getInstance().close();
            return res;

        }

       
    }
}

示例运行结果:

Using pointID get realTime-data succeed! pointid:1003000009, value:8.9, status:0
Using pointID get realTime-data succeed! pointid:1003000010, value:999, status:0
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当然,我可以为您介绍一下时序数据库、时空数据库、向量数据库和密态数据库。 1. 时序数据库(Time Series Database): 时序数据库是一种专门用于存储和处理时间序列数据数据库。时间序列数据是按照时间顺序排列的数据点或事件的集合,例如传感器数据、股票价格、气象数据等。时序数据库具有高效的数据存储和查询能力,可以支持快速的时间范围查询、聚合计算和模式识别等操作。 2. 时空数据库(Spatial Database): 时空数据库是一种专门用于存储和处理时空数据数据库。时空数据是具有地理位置和时间属性的数据,例如地理信息系统(GIS)数据、移动轨迹数据等。时空数据库提供了对时空数据进行索引、查询和分析的功能,可以支持空间范围查询、空间关系分析和轨迹分析等操作。 3. 向量数据库(Vector Database): 向量数据库是一种专门用于存储和处理向量数据数据库。向量数据是由数值组成的多维向量,例如图像特征向量、文本向量等。向量数据库提供了高效的向量索引和相似度搜索功能,可以支持基于向量的检索和聚类分析等操作。 4. 密态数据库(Dense Database): 密态数据库是一种专门用于存储和处理密集数据数据库。密集数据是指具有高维度和大规模的数据,例如科学计算、机器学习和人工智能领域的数据。密态数据库提供了高效的存储和计算能力,可以支持大规模数据的并行处理和分布式计算。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值