コード例 #1
0
        private void _requestGroupDefMonitor_Notification(object sender, PostgreSQLListener <FDADataBlockRequestGroup> .PostgreSQLNotification notifyEvent)
        {
            string changeType = notifyEvent.Notification.operation;
            FDADataBlockRequestGroup requestGroup = notifyEvent.Notification.row;

            RequestGroupMonitorNotification(changeType, requestGroup);
        }
コード例 #2
0
        private void _userScriptsMonitor_Notification(object sender, PostgreSQLListener <UserScriptDefinition> .PostgreSQLNotification notifyEvent)
        {
            string changeType           = notifyEvent.Notification.operation;
            UserScriptDefinition script = notifyEvent.Notification.row;

            UserScriptChangeNotification(changeType, script);
        }
コード例 #3
0
        private void _schedMonitor_Notification(object sender, PostgreSQLListener <FDARequestGroupScheduler> .PostgreSQLNotification notifyEvent)
        {
            string changeType = notifyEvent.Notification.operation;
            FDARequestGroupScheduler sched = notifyEvent.Notification.row;

            SchedulerMonitorNotification(changeType, sched);
        }
コード例 #4
0
        private void _dataPointDefMonitor_Notification(object sender, PostgreSQLListener <FDADataPointDefinitionStructure> .PostgreSQLNotification notifyEvent)
        {
            string changeType = notifyEvent.Notification.operation;
            FDADataPointDefinitionStructure datapoint = notifyEvent.Notification.row;

            DataPointMonitorNotification(changeType, datapoint);
        }
コード例 #5
0
        private void _connectionDefMonitor_Notification(object sender, PostgreSQLListener <FDASourceConnection> .PostgreSQLNotification notifyEvent)
        {
            string changeType = notifyEvent.Notification.operation;
            FDASourceConnection connection = notifyEvent.Notification.row;

            SourceConnectionMonitorNotification(changeType, connection);
        }
コード例 #6
0
        private void _deviceDefMonitor_Notification(object sender, PostgreSQLListener <FDADevice> .PostgreSQLNotification notifyEvent)
        {
            string    changeType = notifyEvent.Notification.operation;
            FDADevice device     = notifyEvent.Notification.row;

            DeviceMonitorNotification(changeType, device);
        }
コード例 #7
0
        private void _datasubscriptionMonitor_Notification(object sender, PostgreSQLListener <DataSubscription> .PostgreSQLNotification notifyEvent)
        {
            string           changeType = notifyEvent.Notification.operation;
            DataSubscription sub        = notifyEvent.Notification.row;

            SubscriptionChangeNotification(changeType, sub);
        }
コード例 #8
0
        private void _taskDefMonitor_Notification(object sender, PostgreSQLListener <FDATask> .PostgreSQLNotification notifyEvent)
        {
            string  changeType = notifyEvent.Notification.operation;
            FDATask task       = notifyEvent.Notification.row;

            TaskMonitorNotification(changeType, task);
        }
コード例 #9
0
        private void _demandMonitor_Notification(object sender, PostgreSQLListener <FDARequestGroupDemand> .PostgreSQLNotification notifyEvent)
        {
            string changeType            = notifyEvent.Notification.operation;
            FDARequestGroupDemand demand = notifyEvent.Notification.row;

            DemandMonitorNotification(changeType, demand);
        }
コード例 #10
0
        public void TaskInsert()
        {
            // create a FDATask
            FDATask original = new FDATask()
            {
                TASK_ID      = rowID,
                task_type    = "task type",
                task_details = "task details"
            };


            // start listening for changes
            PostgreSQLListener <FDATask> listener = new PostgreSQLListener <FDATask>("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDA; Keepalive = 1;", "fdatasks");

            listener.Notification += Listener_NotificationTasks;
            listener.StartListening();

            currentTest = "INSERT";

            expectedTask = new FDATask()
            {
                TASK_ID      = rowID,
                task_type    = "task type",
                task_details = "task details"
            };

            using (NpgsqlConnection conn = new NpgsqlConnection("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDA;Keepalive=1"))
            {
                conn.Open();
                string query = "insert into fdatasks (task_id,task_type,task_details) values (cast('" + original.TASK_ID + "' as uuid),'" + original.task_type + "','" + original.task_details + "');";
                using (NpgsqlCommand command = new NpgsqlCommand(query, conn))
                {
                    waiting = true;
                    command.ExecuteNonQuery();
                }

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                while (waiting && stopwatch.ElapsedMilliseconds < waitlimitms)
                {
                    Thread.Sleep(100);
                }
                stopwatch.Stop();

                if (stopwatch.ElapsedMilliseconds >= waitlimitms)
                {
                    Assert.Fail("Notification not received");
                }
                else
                {
                    if (currentTest != resultOperation)
                    {
                        Assert.Fail("Unexpected operation '" + resultOperation + "', expected '" + currentTest + "'");
                    }

                    CompareTasks(expectedTask, resultingTask);
                }
            }
        }
コード例 #11
0
        public void REFDelete()
        {
            // start listening for changes
            PostgreSQLListener <FDATask> listener = new PostgreSQLListener <FDATask>("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDASystem; Keepalive = 1;", "roceventformats");

            listener.Notification += Listener_NotificationTasks;
            listener.StartListening();

            currentTest  = "DELETE";
            expectedTask = new FDATask()
            {
                TASK_ID      = rowID,
                task_details = null,
                task_type    = null
            };

            using (NpgsqlConnection conn = new NpgsqlConnection("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDASystem;Keepalive=1"))
            {
                conn.Open();
                string query = "delete from roceventformats where pointtype=1 and format=2;";
                using (NpgsqlCommand command = new NpgsqlCommand(query, conn))
                {
                    waiting = true;
                    command.ExecuteNonQuery();
                }

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                while (waiting && stopwatch.ElapsedMilliseconds < waitlimitms)
                {
                    Thread.Sleep(100);
                }
                stopwatch.Stop();

                if (stopwatch.ElapsedMilliseconds >= waitlimitms)
                {
                    Assert.Fail("delete notification not received");
                }
                else
                {
                    if (currentTest != resultOperation)
                    {
                        Assert.Fail("Unexpected operation '" + resultOperation + "', expected '" + currentTest + "'");
                    }

                    if (expectedREF.POINTTYPE != resultingREF.POINTTYPE)
                    {
                        Assert.Fail("Unexpected POINTTYPE. expected " + expectedREF.POINTTYPE.ToString() + ", received " + resultingREF.POINTTYPE.ToString());
                    }

                    if (expectedREF.FORMAT != resultingREF.FORMAT)
                    {
                        Assert.Fail("Unexpected FORMAT. expected " + expectedREF.FORMAT.ToString() + ", received " + resultingREF.FORMAT.ToString());
                    }
                }
            }
        }
コード例 #12
0
        public void RequestGroupDelete()
        {
            // start listening for changes
            PostgreSQLListener <FDADataBlockRequestGroup> listener = new PostgreSQLListener <FDADataBlockRequestGroup>("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDA; Keepalive = 1;", "fdadatablockrequestgroup");

            listener.Notification += Listener_NotificationRequestGroup;
            listener.StartListening();

            currentTest = "DELETE";
            expectedRequestGroupResult = new FDADataBlockRequestGroup()
            {
                Description = "FDATestsGroup",
                DRGEnabled  = true,
                DPSType     = "ROC",
                DataPointBlockRequestListVals = "20:4:1|INT16:4BB8D0AF-0DC8-437E-A0F3-0B773A7B0083",
                CommsLogEnabled = false,
                DRGUID          = rowID
            };

            using (NpgsqlConnection conn = new NpgsqlConnection("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDA;Keepalive=1"))
            {
                conn.Open();
                string query = "delete from fdadatablockrequestgroup where drguid = cast('" + rowID.ToString() + "' as uuid);";
                using (NpgsqlCommand command = new NpgsqlCommand(query, conn))
                {
                    waiting = true;
                    command.ExecuteNonQuery();
                }

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                while (waiting && stopwatch.ElapsedMilliseconds < waitlimitms)
                {
                    Thread.Sleep(100);
                }
                stopwatch.Stop();

                if (stopwatch.ElapsedMilliseconds >= waitlimitms)
                {
                    Assert.Fail("Notification not received");
                }
                else
                {
                    if (currentTest != resultOperation)
                    {
                        Assert.Fail("Unexpected operation '" + resultOperation + "', expected '" + currentTest + "'");
                    }

                    if (expectedRequestGroupResult.DRGUID != requestGroupResult.DRGUID)
                    {
                        Assert.Fail("Unexpected DRGUID. expected " + expectedRequestGroupResult.DRGUID.ToString() + ", received " + requestGroupResult.DRGUID.ToString());
                    }
                }
            }
        }
コード例 #13
0
        public void TaskDelete()
        {
            // start listening for changes
            PostgreSQLListener <FDATask> listener = new PostgreSQLListener <FDATask>("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDA; Keepalive = 1;", "fdatasks");

            listener.Notification += Listener_NotificationTasks;
            listener.StartListening();

            currentTest  = "DELETE";
            expectedTask = new FDATask()
            {
                TASK_ID      = rowID,
                task_details = null,
                task_type    = null
            };

            using (NpgsqlConnection conn = new NpgsqlConnection("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDA;Keepalive=1"))
            {
                conn.Open();
                string query = "delete from FDATasks where task_id = cast('" + rowID.ToString() + "' as uuid);";
                using (NpgsqlCommand command = new NpgsqlCommand(query, conn))
                {
                    waiting = true;
                    command.ExecuteNonQuery();
                }

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                while (waiting && stopwatch.ElapsedMilliseconds < waitlimitms)
                {
                    Thread.Sleep(100);
                }
                stopwatch.Stop();

                if (stopwatch.ElapsedMilliseconds >= waitlimitms)
                {
                    Assert.Fail("delete notification not received");
                }
                else
                {
                    if (currentTest != resultOperation)
                    {
                        Assert.Fail("Unexpected operation '" + resultOperation + "', expected '" + currentTest + "'");
                    }

                    if (expectedTask.TASK_ID != resultingTask.TASK_ID)
                    {
                        Assert.Fail("Unexpected DRGUID. expected " + expectedRequestGroupResult.DRGUID.ToString() + ", received " + requestGroupResult.DRGUID.ToString());
                    }
                }
            }
        }
コード例 #14
0
        public void REFUpdate()
        {
            // start listening for changes
            PostgreSQLListener <FDATask> listener = new PostgreSQLListener <FDATask>("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDASystem; Keepalive = 1;", "fdatasks");

            listener.Notification += Listener_NotificationTasks;
            listener.StartListening();

            currentTest = "UPDATE";
            expectedREF = new RocEventFormats()
            {
                POINTTYPE = 1,
                FORMAT    = 2,
                DescShort = "FAKE-updated",
                DescLong  = "FAKE FORMAT-updated"
            };

            using (NpgsqlConnection conn = new NpgsqlConnection("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDASystem;Keepalive=1"))
            {
                conn.Open();
                string query = "update roceventformats set descshort = 'FAKE-updated',desclong='FAKE FORMAT-updated' where pointtype = 1 and FORMAT = 2";
                using (NpgsqlCommand command = new NpgsqlCommand(query, conn))
                {
                    waiting = true;
                    command.ExecuteNonQuery();
                }

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                while (waiting && stopwatch.ElapsedMilliseconds < waitlimitms)
                {
                    Thread.Sleep(100);
                }
                stopwatch.Stop();

                if (stopwatch.ElapsedMilliseconds >= waitlimitms)
                {
                    Assert.Fail("Notification not received");
                }
                else
                {
                    if (currentTest != resultOperation)
                    {
                        Assert.Fail("Unexpected operation '" + resultOperation + "', expected '" + currentTest + "'");
                    }

                    CompareREFs(expectedREF, resultingREF);
                }
            }
        }
コード例 #15
0
        public void RequestGroupInsert()
        {
            // create a FDADataBlockrequestGroup
            FDADataBlockRequestGroup original = new FDADataBlockRequestGroup()
            {
                Description = "FDATestsGroup",
                DRGEnabled  = false,
                DPSType     = "MODBUS",
                DataPointBlockRequestListVals = "20:3:1|INT16:4BB8D0AF-0DC8-437E-A0F3-0B773A7B0083",
                CommsLogEnabled = true,
                DRGUID          = rowID,
            };


            // start listening for changes
            PostgreSQLListener <FDADataBlockRequestGroup> listener = new PostgreSQLListener <FDADataBlockRequestGroup>("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDA; Keepalive = 1;", "fdadatablockrequestgroup");

            listener.Notification += Listener_NotificationRequestGroup;
            listener.StartListening();

            currentTest = "INSERT";
            expectedRequestGroupResult = new FDADataBlockRequestGroup()
            {
                Description = "FDATestsGroup",
                DRGEnabled  = false,
                DPSType     = "MODBUS",
                DataPointBlockRequestListVals = "20:3:1|INT16:4BB8D0AF-0DC8-437E-A0F3-0B773A7B0083",
                CommsLogEnabled = true,
                DRGUID          = rowID,
            };

            using (NpgsqlConnection conn = new NpgsqlConnection("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDA;Keepalive=1"))
            {
                conn.Open();
                string query = "insert into fdadatablockrequestgroup (description,drgenabled,commslogenabled,dpstype,datapointblockrequestlistvals,drguid) values ('" + original.Description + "',cast(" + (original.DRGEnabled ? 1 : 0) + " as bit),cast(" + (original.CommsLogEnabled?1:0) + " as bit),'MODBUS','20:3:1|INT16:4BB8D0AF-0DC8-437E-A0F3-0B773A7B0083',cast('" + original.DRGUID.ToString() + "' as uuid));";
                using (NpgsqlCommand command = new NpgsqlCommand(query, conn))
                {
                    waiting = true;
                    command.ExecuteNonQuery();
                }

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                while (waiting && stopwatch.ElapsedMilliseconds < waitlimitms)
                {
                    Thread.Sleep(100);
                }
                stopwatch.Stop();

                if (stopwatch.ElapsedMilliseconds >= waitlimitms)
                {
                    Assert.Fail("Notification not received");
                }
                else
                {
                    if (currentTest != resultOperation)
                    {
                        Assert.Fail("Unexpected operation '" + resultOperation + "', expected '" + currentTest + "'");
                    }

                    CompareResult(expectedRequestGroupResult, requestGroupResult);
                }
            }
        }
コード例 #16
0
        public void REFInsert()
        {
            // create an REF
            RocEventFormats original = new RocEventFormats()
            {
                POINTTYPE = 1,
                FORMAT    = 2,
                DescShort = "FAKE",
                DescLong  = "FAKE FORMAT"
            };


            // start listening for changes
            PostgreSQLListener <RocEventFormats> listener = new PostgreSQLListener <RocEventFormats>("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDASystem; Keepalive = 1;", "roceventformats");

            listener.Notification += Listener_NotificationREF;
            listener.StartListening();

            currentTest = "INSERT";

            expectedREF = new RocEventFormats()
            {
                POINTTYPE = 1,
                FORMAT    = 2,
                DescShort = "FAKE",
                DescLong  = "FAKE FORMAT"
            };

            using (NpgsqlConnection conn = new NpgsqlConnection("Server = localhost; Port = 5432; User Id = Intricatesql; Password = Intricate2790!; Database = FDASystem;Keepalive=1"))
            {
                conn.Open();
                string query = "insert into RocEventFormats (pointtype,format,descshort,desclong) values (1,2,'FAKE','FAKE FORMAT');";
                using (NpgsqlCommand command = new NpgsqlCommand(query, conn))
                {
                    waiting = true;
                    command.ExecuteNonQuery();
                }

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                while (waiting && stopwatch.ElapsedMilliseconds < waitlimitms)
                {
                    Thread.Sleep(100);
                }
                stopwatch.Stop();

                if (stopwatch.ElapsedMilliseconds >= waitlimitms)
                {
                    Assert.Fail("Notification not received");
                }
                else
                {
                    if (currentTest != resultOperation)
                    {
                        Assert.Fail("Unexpected operation '" + resultOperation + "', expected '" + currentTest + "'");
                    }

                    CompareREFs(expectedREF, resultingREF);
                }
            }
        }
コード例 #17
0
 private void Listener_NotificationTasks(object sender, PostgreSQLListener <FDATask> .PostgreSQLNotification notifyEvent)
 {
     resultOperation = notifyEvent.Notification.operation;
     resultingTask   = notifyEvent.Notification.row;
     waiting         = false;
 }
コード例 #18
0
 private void Listener_NotificationRequestGroup(object sender, PostgreSQLListener <FDADataBlockRequestGroup> .PostgreSQLNotification notifyEvent)
 {
     resultOperation    = notifyEvent.Notification.operation;
     requestGroupResult = notifyEvent.Notification.row;
     waiting            = false;
 }
コード例 #19
0
 private void Listener_NotificationREF(object sender, PostgreSQLListener <RocEventFormats> .PostgreSQLNotification notifyEvent)
 {
     resultOperation = notifyEvent.Notification.operation;
     resultingREF    = notifyEvent.Notification.row;
     waiting         = false;
 }
コード例 #20
0
        public override void Initialize()
        {
            base.Initialize();


            // PostgreSQL table monitors
            _schedMonitor           = new PostgreSQLListener <FDARequestGroupScheduler>(ConnectionString, Globals.SystemManager.GetTableName("FDARequestGroupScheduler"));
            _demandMonitor          = new PostgreSQLListener <FDARequestGroupDemand>(ConnectionString, Globals.SystemManager.GetTableName("FDARequestGroupDemand"));
            _requestGroupDefMonitor = new PostgreSQLListener <FDADataBlockRequestGroup>(ConnectionString, Globals.SystemManager.GetTableName("FDADataBlockRequestGroup"));
            _dataPointDefMonitor    = new PostgreSQLListener <FDADataPointDefinitionStructure>(ConnectionString, Globals.SystemManager.GetTableName("DataPointDefinitionStructures"));
            _connectionDefMonitor   = new PostgreSQLListener <FDASourceConnection>(ConnectionString, Globals.SystemManager.GetTableName("FDASourceConnections"));
            if (_devicesTableExists)
            {
                _deviceDefMonitor = new PostgreSQLListener <FDADevice>(ConnectionString, Globals.SystemManager.GetTableName("FDADevices"));
            }
            if (_tasksTableExists)
            {
                _taskDefMonitor = new PostgreSQLListener <FDATask>(ConnectionString, Globals.SystemManager.GetTableName("FDATasks"));
            }
            if (_datasubscriptionsTableExists)
            {
                _datasubscriptionMonitor = new PostgreSQLListener <DataSubscription>(ConnectionString, Globals.SystemManager.GetTableName("FDASubscriptions"));
            }
            if (_scriptsTableExists)
            {
                _userScriptsMonitor = new PostgreSQLListener <UserScriptDefinition>(ConnectionString, Globals.SystemManager.GetTableName("fda_scripts"));
            }

            _demandMonitor.Notification          += _demandMonitor_Notification;
            _schedMonitor.Notification           += _schedMonitor_Notification;
            _requestGroupDefMonitor.Notification += _requestGroupDefMonitor_Notification;
            _connectionDefMonitor.Notification   += _connectionDefMonitor_Notification;
            _dataPointDefMonitor.Notification    += _dataPointDefMonitor_Notification;
            if (_datasubscriptionMonitor != null)
            {
                _datasubscriptionMonitor.Notification += _datasubscriptionMonitor_Notification;
            }
            if (_deviceDefMonitor != null)
            {
                _deviceDefMonitor.Notification += _deviceDefMonitor_Notification;
            }
            if (_taskDefMonitor != null)
            {
                _taskDefMonitor.Notification += _taskDefMonitor_Notification;
            }
            if (_userScriptsMonitor != null)
            {
                _userScriptsMonitor.Notification += _userScriptsMonitor_Notification;
            }

            _demandMonitor.Error          += _PostgresSQLMonitor_Error;
            _schedMonitor.Error           += _PostgresSQLMonitor_Error;
            _requestGroupDefMonitor.Error += _PostgresSQLMonitor_Error;
            _connectionDefMonitor.Error   += _PostgresSQLMonitor_Error;
            _dataPointDefMonitor.Error    += _PostgresSQLMonitor_Error;
            if (_deviceDefMonitor != null)
            {
                _deviceDefMonitor.Error += _PostgresSQLMonitor_Error;
            }
            if (_taskDefMonitor != null)
            {
                _taskDefMonitor.Error += _PostgresSQLMonitor_Error;
            }
            if (_datasubscriptionMonitor != null)
            {
                _datasubscriptionMonitor.Error += _PostgresSQLMonitor_Error;
            }
            if (_userScriptsMonitor != null)
            {
                _userScriptsMonitor.Error += _PostgresSQLMonitor_Error;
            }

            StartChangeMonitoring();
        }