Ejemplo n.º 1
0
        private static void reportHandler(Report report, object parameter)
        {
            Console.WriteLine("Received report:\n----------------");

            if (report.HasTimestamp())
            {
                Console.WriteLine("  timestamp: " + MmsValue.MsTimeToDateTimeOffset(report.GetTimestamp()).ToString());
            }

            MmsValue values = report.GetDataSetValues();

            Console.WriteLine("  report dataset contains " + values.Size() + " elements");

            for (int i = 0; i < values.Size(); i++)
            {
                if (report.GetReasonForInclusion(i) != ReasonForInclusion.REASON_NOT_INCLUDED)
                {
                    Console.WriteLine("    element " + i + " included for reason " + report.GetReasonForInclusion(i).ToString() + " " + values.GetElement(i));
                }
            }

            ReportControlBlock rcb = (ReportControlBlock)parameter;

            Console.WriteLine("Buffered: " + rcb.IsBuffered());
        }
Ejemplo n.º 2
0
 internal void RemoveRCB(ReportControlBlock rcb)
 {
     if (activeRCBs != null)
     {
         activeRCBs.Remove(rcb);
     }
 }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            IedConnection con = new IedConnection();

            string hostname;

            if (args.Length > 0)
            {
                hostname = args [0];
            }
            else
            {
                //hostname = "localhost";
                hostname = "172.23.44.10";
            }

            Console.WriteLine("Connect to " + hostname);

            try {
                con.Connect(hostname, 102);

                string rcbReference = "simpleIOGenericIO/LLN0.RP.EventsRCB01";

                ReportControlBlock rcb = con.GetReportControlBlock(rcbReference);

                rcb.GetRCBValues();

                // note: the second parameter is not required!
                rcb.InstallReportHandler(reportHandler, rcb);

                if (rcb.IsBuffered())
                {
                    Console.WriteLine("RCB: " + rcbReference + " is buffered");
                }

                Console.WriteLine(rcb.GetDataSetReference());

                rcb.SetTrgOps(TriggerOptions.DATA_CHANGED | TriggerOptions.INTEGRITY);
                rcb.SetIntgPd(5000);
                rcb.SetRptEna(true);

                rcb.SetRCBValues();

                /* run until Ctrl-C is pressed */
                Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) {
                    e.Cancel = true;
                    ReportingExample.running = false;
                };

                while (running)
                {
                    Thread.Sleep(10);
                }

                con.Abort();
            } catch (IedConnectionException e) {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 4
0
            public ReportControlBlock GetReportControlBlock(string rcbObjectReference)
            {
                var newRCB = new ReportControlBlock(rcbObjectReference, this, connection);

                if (activeRCBs == null)
                {
                    activeRCBs = new List <ReportControlBlock> ();
                }

                activeRCBs.Add(newRCB);

                return(newRCB);
            }
Ejemplo n.º 5
0
        private static void reportHandler(Report report, object parameter)
        {
            Console.WriteLine("Received report:\n----------------");

            Console.WriteLine("  for RCB: " + report.GetRcbReference());

            if (report.HasTimestamp())
            {
                Console.WriteLine("  timestamp: " + MmsValue.MsTimeToDateTimeOffset(report.GetTimestamp()).ToString());
            }

            MmsValue values = report.GetDataSetValues();

            byte[] entryId = report.GetEntryId();

            if (entryId != null)
            {
                SoapHexBinary shb = new SoapHexBinary(entryId);

                Console.WriteLine("  entryID: " + shb.ToString());
            }

            if (report.HasDataSetName())
            {
                Console.WriteLine("   report data set: " + report.GetDataSetName());
            }

            Console.WriteLine("  report dataset contains " + values.Size() + " elements");

            for (int i = 0; i < values.Size(); i++)
            {
                if (report.GetReasonForInclusion(i) != ReasonForInclusion.REASON_NOT_INCLUDED)
                {
                    Console.WriteLine("    element " + i + " included for reason " + report.GetReasonForInclusion(i).ToString() + " " + values.GetElement(i));
                }

                if (report.HasDataReference())
                {
                    Console.WriteLine("       data-ref: " + report.GetDataReference(i));
                }
            }

            ReportControlBlock rcb = (ReportControlBlock)parameter;

            Console.WriteLine("  For RCB: " + rcb.GetObjectReference() + " Buffered: " + rcb.IsBuffered() +
                              " data-set: " + rcb.GetDataSetReference());
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            IedConnection con = new IedConnection();

            string hostname;

            if (args.Length > 0)
            {
                hostname = args[0];
            }
            else
            {
                hostname = "localhost";
            }

            Console.WriteLine("Connect to " + hostname);

            try
            {
                con.Connect(hostname, 102);

                // create a new data set

                List <string> dataSetElements = new List <string>();

                dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn1.mag.f[MX]");
                dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn2.mag.f[MX]");
                dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn3.mag.f[MX]");
                dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn4.mag.f[MX]");

                // permanent (domain specific) data set
                //string dataSetReference = "simpleIOGenericIO/LLN0.ds1";

                // temporary (association specific) data set
                string dataSetReference = "@newds";

                // Note: this function will throw an exception when a data set with the same name already exists
                con.CreateDataSet(dataSetReference, dataSetElements);

                // reconfigure existing RCB with new data set

                string rcbReference = "simpleIOGenericIO/LLN0.RP.EventsRCB01";

                ReportControlBlock rcb = con.GetReportControlBlock(rcbReference);

                rcb.GetRCBValues();

                // note: the second parameter is not required!
                rcb.InstallReportHandler(reportHandler, rcb);

                string rcbDataSetReference = dataSetReference.Replace('.', '$');

                rcb.SetDataSetReference(rcbDataSetReference);
                rcb.SetTrgOps(TriggerOptions.DATA_CHANGED | TriggerOptions.INTEGRITY);
                rcb.SetIntgPd(5000);
                rcb.SetRptEna(true);

                rcb.SetRCBValues();

                /* run until Ctrl-C is pressed */
                Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) {
                    e.Cancel = true;
                    running  = false;
                };

                while (running)
                {
                    Thread.Sleep(1000);
                }

                // delete the data set
                con.DeleteDataSet(dataSetReference);

                con.Abort();
            }
            catch (IedConnectionException e)
            {
                Console.WriteLine(e.Message + " reason: " + e.GetIedClientError().ToString());
            }

            // release all resources - do NOT use the object after this call!!
            con.Dispose();
        }
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            IedConnection con = new IedConnection();

            string hostname;

            if (args.Length > 0)
            {
                hostname = args [0];
            }
            else
            {
                hostname = "localhost";
            }

            Console.WriteLine("Connect to " + hostname);

            try {
                con.Connect(hostname, 102);

                string rcbReference1 = "simpleIOGenericIO/LLN0.RP.EventsRCB01";
                string rcbReference2 = "simpleIOGenericIO/LLN0.RP.EventsIndexed01";
                string rcbReference3 = "simpleIOGenericIO/LLN0.BR.Measurements01";

                ReportControlBlock rcb1 = con.GetReportControlBlock(rcbReference1);
                ReportControlBlock rcb2 = con.GetReportControlBlock(rcbReference2);
                ReportControlBlock rcb3 = con.GetReportControlBlock(rcbReference3);

                rcb1.GetRCBValues();

                // note: the second parameter is not required!
                rcb1.InstallReportHandler(reportHandler, rcb1);

                if (rcb1.IsBuffered())
                {
                    Console.WriteLine("RCB: " + rcbReference1 + " is buffered");
                }

                rcb1.SetTrgOps(TriggerOptions.DATA_CHANGED | TriggerOptions.INTEGRITY);
                rcb1.SetIntgPd(5000);
                rcb1.SetRptEna(true);

                rcb2.GetRCBValues();

                if (rcb2.IsBuffered())
                {
                    Console.WriteLine("RCB: " + rcbReference2 + " is buffered");
                }

                rcb2.InstallReportHandler(reportHandler, rcb2);

                rcb2.SetOptFlds(ReportOptions.REASON_FOR_INCLUSION | ReportOptions.SEQ_NUM | ReportOptions.TIME_STAMP |
                                ReportOptions.CONF_REV | ReportOptions.ENTRY_ID | ReportOptions.DATA_REFERENCE | ReportOptions.DATA_SET);
                rcb2.SetTrgOps(TriggerOptions.DATA_CHANGED | TriggerOptions.INTEGRITY);
                rcb2.SetIntgPd(2000);
                rcb2.SetRptEna(true);

                rcb2.SetRCBValues();

                rcb3.GetRCBValues();

                if (rcb3.IsBuffered())
                {
                    Console.WriteLine("RCB: " + rcbReference3 + " is buffered");
                }

                rcb3.InstallReportHandler(reportHandler, rcb2);

                rcb3.SetOptFlds(ReportOptions.REASON_FOR_INCLUSION | ReportOptions.SEQ_NUM | ReportOptions.TIME_STAMP |
                                ReportOptions.CONF_REV | ReportOptions.ENTRY_ID | ReportOptions.DATA_REFERENCE | ReportOptions.DATA_SET);
                rcb3.SetTrgOps(TriggerOptions.DATA_CHANGED | TriggerOptions.INTEGRITY);
                rcb3.SetIntgPd(2000);
                rcb3.SetRptEna(true);

                rcb3.SetRCBValues();


                /* run until Ctrl-C is pressed */
                Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) {
                    e.Cancel = true;
                    ReportingExample.running = false;
                };

                /* stop main loop when connection is lost */
                con.InstallConnectionClosedHandler(delegate(IedConnection connection) {
                    Console.WriteLine("Connection closed");
                    ReportingExample.running = false;
                });

                while (running)
                {
                    Thread.Sleep(10);
                }

                /* Dispose the RCBs when you no longer need them */
                rcb1.Dispose();
                rcb2.Dispose();
                rcb3.Dispose();

                con.Abort();

                con.Dispose();
            } catch (IedConnectionException e) {
                Console.WriteLine("Error: " + e.Message);

                con.Dispose();
            }
        }
Ejemplo n.º 8
0
        public ResultDatasetModel ReadRCB(string hostip, Int32 port, string dataaddress)
        {   //instance
            IedConnection con = new IedConnection();

            try
            {   //connection
                con.Connect(hostip, port);
                //read data set
                // create a new data set

                List <string> dataSetElements = new List <string>();

                dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn1.mag.f[MX]");
                dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn2.mag.f[MX]");
                dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn3.mag.f[MX]");
                dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn4.mag.f[MX]");

                // permanent (domain specific) data set
                //string dataSetReference = "simpleIOGenericIO/LLN0.ds1";

                // temporary (association specific) data set
                string dataSetReference = "@ss";

                // Note: this function will throw an exception when a data set with the same name already exists
                con.CreateDataSet(dataSetReference, dataSetElements);

                // reconfigure existing RCB with new data set

                string rcbReference = "simpleIOGenericIO/LLN0.RP.EventsRCB01";

                ReportControlBlock rcb = con.GetReportControlBlock(rcbReference);

                rcb.GetRCBValues();

                // note: the second parameter is not required!
                rcb.InstallReportHandler(reportHandler, rcb);

                string rcbDataSetReference = dataSetReference.Replace('.', '$');

                rcb.SetDataSetReference(rcbDataSetReference);
                rcb.SetTrgOps(TriggerOptions.DATA_CHANGED | TriggerOptions.INTEGRITY);
                rcb.SetIntgPd(5000);
                rcb.SetRptEna(true);

                rcb.SetRCBValues();

                // Console.WriteLine(mmsresult.GetRCBValues());
                List <Dataset_Result> valuelist   = new List <Dataset_Result>();
                data_extract          dataExtract = new data_extract();

                //con close
                con.Abort();

                ResultDatasetModel result = new ResultDatasetModel
                {
                    data         = valuelist,
                    error        = false,
                    errormessage = null
                };
                //destroy instance
                con.Dispose();
                //result
                return(result);
            }
            catch (IedConnectionException e)
            {
                ResultDatasetModel result = new ResultDatasetModel()
                {
                    data         = null,
                    error        = true,
                    errormessage = e.Message.ToString()
                };
                //insert logs into db
                Submission dbinsert = new Submission
                {
                    CreatedAt = DateTime.Now,
                    Content   = e.Message.ToString()
                };
                _subSvc.Create(dbinsert);
                //destroy result
                con.Dispose();
                //result
                return(result);
            }
        }
Ejemplo n.º 9
0
        public void OnGet()
        {
            IndexModel viewdata = new IndexModel();

            IedConnection con = new IedConnection();

            string hostname;

            hostname = "100.100.100.100";

            Console.WriteLine("Connect to " + hostname);

            try {
                con.Connect(hostname, 102);

                string rcbReference3 = "TEMPLATEMEAS/LLN0.RP.urcbAinA01";
                // string rcbReference3 = "TEMPLATECTRL/LLN0.BR.brcbDinD01";
                ReportControlBlock rcb3 = con.GetReportControlBlock(rcbReference3);

                rcb3.GetRCBValues();

                if (rcb3.IsBuffered())
                {
                    Console.WriteLine("RCB: " + rcbReference3 + " is buffered");
                }

                rcb3.InstallReportHandler(reportHandler, rcb3);

                rcb3.SetOptFlds(ReportOptions.REASON_FOR_INCLUSION | ReportOptions.SEQ_NUM | ReportOptions.TIME_STAMP |
                                ReportOptions.CONF_REV | ReportOptions.ENTRY_ID | ReportOptions.DATA_REFERENCE | ReportOptions.DATA_SET);
                rcb3.SetTrgOps(TriggerOptions.DATA_CHANGED | TriggerOptions.INTEGRITY);
                rcb3.SetIntgPd(2000);
                rcb3.SetRptEna(true);

                rcb3.SetRCBValues();


                /* run until Ctrl-C is pressed */
                Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) {
                    e.Cancel           = true;
                    IndexModel.running = false;
                };

                /* stop main loop when connection is lost */
                con.InstallConnectionClosedHandler(delegate(IedConnection connection) {
                    Console.WriteLine("Connection closed");
                    IndexModel.running = false;
                });

                while (running)
                {
                    Thread.Sleep(10);
                }

                /* Dispose the RCBs when you no longer need them */
                rcb3.Dispose();

                con.Abort();

                con.Dispose();
            } catch (IedConnectionException e) {
                Console.WriteLine("Error: " + e.Message);

                con.Dispose();
            }
        }