Ejemplo n.º 1
0
        public void TestPushToWriteQuene01()
        {
            OPCDataPointManager oPCDataPointManager = OPCDataPointManager.GetInstance();

            Entity.Trending.EtyTrendLog tre = new Entity.Trending.EtyTrendLog();
            oPCDataPointManager.PushToWriteQuene(tre);
        }
Ejemplo n.º 2
0
        public void TestGetNextSampleTime01()
        {
            //Test --- First time called for intialization of the logger datapoints
            // Current time is greater than start time
            OPCDataPointManager oPCDataPointManager = OPCDataPointManager.GetInstance();
            DateTime            currenttime         = System.DateTime.Now;

            currenttime = new DateTime(currenttime.Year, currenttime.Month, currenttime.Day, (currenttime.Hour - 1), currenttime.Minute, 0, 0);
            double   intervalInSecs         = 120;
            Accessor oPCLoggerCacheAccessor = ReflectionAccessor.Wrap(oPCDataPointManager);
            DateTime dateTime = (DateTime)oPCLoggerCacheAccessor.Call("GetNextSampleTime", currenttime, intervalInSecs, true);

            //Post Test Condition Check
            currenttime = System.DateTime.Now;
            currenttime = new DateTime(currenttime.Year, currenttime.Month, currenttime.Day, currenttime.Hour, currenttime.Minute, 0, 0);
            DateTime time = currenttime.AddSeconds(120);

            Assert.AreEqual(time, dateTime);


            ////Test 2 --- Second time called for calculating next log time
            // Current time is greater than planned log time
            //current time is System.DateTime dt = new DateTime(2013, 01, 29, 14, 25, 50);
            currenttime = System.DateTime.Now;
            currenttime = new DateTime(currenttime.Year, currenttime.Month, currenttime.Day, currenttime.Hour, currenttime.Minute - 1, 0, 0);
            DateTime dateTime1 = (DateTime)oPCLoggerCacheAccessor.Call("GetNextSampleTime", currenttime, intervalInSecs, false);

            //Post Test Condition Check
            currenttime = currenttime.AddSeconds(120);
            Assert.AreEqual(currenttime, dateTime1);
        }
Ejemplo n.º 3
0
        public void TestInitializeOPCSetting01()
        {
            //Test ---- Exception thrown
            OPCDataPointManager oPCDataPointManager = OPCDataPointManager.GetInstance();

            oPCDataPointManager.InitializeOPCSetting("1223");
        }
Ejemplo n.º 4
0
 public void TestisNumeric01()
 {
     OPCDataPointManager oPCDataPointManager = OPCDataPointManager.GetInstance();
     string       val         = "22";
     NumberStyles numberStyle = NumberStyles.AllowTrailingSign;
     bool         b           = oPCDataPointManager.isNumeric(val, numberStyle);
 }
Ejemplo n.º 5
0
 public void TestInitializeAndConnectOPCServer01()
 {
     OPCDataPointManager oPCDataPointManager    = OPCDataPointManager.GetInstance();
     Accessor            oPCLoggerCacheAccessor = ReflectionAccessor.Wrap(oPCDataPointManager);
     bool b = oPCDataPointManager.InitializeAndConnectOPCServer();
     //Post Test Condition Check
 }
Ejemplo n.º 6
0
        public void TestRun02()
        {
            //Testing ----- invalid datapoint Value from OPCProxy
            OPCLoggerQuene oPCLoggerQuene         = OPCLoggerQueneFactory.CreateOPCLoggerQuene02();
            Accessor       oPCLoggerQueneAccessor = ReflectionAccessor.Wrap(oPCLoggerQuene);

            oPCLoggerQueneAccessor.SetField("m_serviceStarted", true);
            Dictionary <string, OPCDPGrpDetails> opcdic = new Dictionary <string, OPCDPGrpDetails>();
            OPCDPGrpDetails deta1 = new OPCDPGrpDetails();

            opcdic.Add("testingDP1", new OPCDPGrpDetails());
            Accessor oPCMagerAccessor = ReflectionAccessor.Wrap(OPCDataPointManager.GetInstance());

            oPCMagerAccessor.SetField("m_DataPointdic", opcdic);
            System.Threading.ThreadStart func = new System.Threading.ThreadStart(oPCLoggerQuene.Run);
            System.Threading.Thread      t1   = new System.Threading.Thread(func);
            t1.Start();
            //wait till test completes
            m_OPCLoggerQuenesignal.WaitOne();

            //PostCondition Check
            //check no data point in WriteQuene.
            Assert.AreEqual(0, oPCMagerAccessor.GetFieldAccessor("m_writeQuene").GetFieldAccessor("m_writeQuene").GetProperty("Count"));


            //release all instances
            OPCDataPointManager.ReleaseInstance();
            OPCLoggerQueneFactory.ReleaseOPCLoggerQuene02();
        }
Ejemplo n.º 7
0
        public void TestInitializeDataLogger02()
        {
            OPCDataPointManager oPCDataPointManager    = OPCDataPointManager.GetInstance();
            Accessor            oPCLoggerCacheAccessor = ReflectionAccessor.Wrap(oPCDataPointManager);

            //Test3 ----- Valid setup
            oPCDataPointManager.InitializeDataLogger(false);
        }
Ejemplo n.º 8
0
        public void TestFinalize01()
        {
            OPCDataPointManager oPCDataPointManager = OPCDataPointManager.GetInstance();
            Accessor            managerAccessor     = ReflectionAccessor.Wrap(oPCDataPointManager);

            OPCDataPointManager.ReleaseInstance();
            managerAccessor.Call("Finalize");
        }
Ejemplo n.º 9
0
        public void TestConnectDPToOPC01()
        {
            OPCDataPointManager oPCDataPointManager           = OPCDataPointManager.GetInstance();
            Accessor            oPCLoggerCacheAccessor        = ReflectionAccessor.Wrap(oPCDataPointManager);
            Dictionary <string, OPCDPGrpDetails> dataPointdic = new Dictionary <string, OPCDPGrpDetails>();

            dataPointdic.Add("DP1", new OPCDPGrpDetails());
            oPCLoggerCacheAccessor.SetField("m_DataPointdic", dataPointdic);
            oPCDataPointManager.ConnectDPToOPC();
        }
Ejemplo n.º 10
0
        public void TestInitializeDataLogger04()
        {
            //Test ----- Exception thrown
            OPCDataPointManager oPCDataPointManager    = OPCDataPointManager.GetInstance();
            Accessor            oPCLoggerCacheAccessor = ReflectionAccessor.Wrap(oPCDataPointManager);

            oPCLoggerCacheAccessor.SetField("m_localConnectionString", "DataSource=;UserID=;Password=;");
            //Test Procedure Call
            oPCDataPointManager.InitializeDataLogger(false);
            //Post Condition Check
        }
Ejemplo n.º 11
0
        public void TestClearDataPoints01()
        {
            OPCDataPointManager oPCDataPointManager           = OPCDataPointManager.GetInstance();
            Accessor            oPCDataPointManagerAccessor   = ReflectionAccessor.Wrap(oPCDataPointManager);
            Dictionary <string, OPCDPGrpDetails> dataPointdic = new Dictionary <string, OPCDPGrpDetails>();

            dataPointdic.Add("Datapoint1.Value", new OPCDPGrpDetails());
            oPCDataPointManagerAccessor.SetField("m_DataPointdic", dataPointdic);
            oPCDataPointManager.ClearDataPoints();
            //Post test condition check
            Assert.AreEqual(0, oPCDataPointManagerAccessor.GetFieldAccessor("m_DataPointdic").GetProperty("Count"));
        }
Ejemplo n.º 12
0
        public void TestRun05()
        {
            //Testing ----- Initialization data logger failed
            OPCLoggerQuene oPCLoggerQuene         = OPCLoggerQueneFactory.CreateOPCLoggerQuene02();
            Accessor       oPCLoggerQueneAccessor = ReflectionAccessor.Wrap(oPCLoggerQuene);

            oPCLoggerQueneAccessor.SetField("m_serviceStarted", true);
            oPCLoggerQuene.Run();
            //release all instances
            OPCDataPointManager.ReleaseInstance();
            OPCLoggerQueneFactory.ReleaseOPCLoggerQuene02();
        }
Ejemplo n.º 13
0
        public void TestInitializeDataLogger01()
        {
            OPCDataPointManager oPCDataPointManager    = OPCDataPointManager.GetInstance();
            Accessor            oPCLoggerCacheAccessor = ReflectionAccessor.Wrap(oPCDataPointManager);

            //Test1 ----- invalid database string
            oPCLoggerCacheAccessor.SetField("m_localConnectionString", "DataSource=;UserID=;Password=;");
            oPCDataPointManager.ExitApplicationEvent += new OPCDataPointManager.VoidEventHandler(oPCDataPointManager_ExitApplicationEvent);
            //Test Procedure Call
            oPCDataPointManager.InitializeDataLogger(false);
            //Post Condition Check
            Assert.IsTrue(bExitApplicationCalled);
        }
Ejemplo n.º 14
0
        public void TestLoadDataPointTimeStamp01()
        {
            OPCDataPointManager oPCDataPointManager    = OPCDataPointManager.GetInstance();
            Accessor            oPCLoggerCacheAccessor = ReflectionAccessor.Wrap(oPCDataPointManager);

            oPCDataPointManager.LoadDataPointTimeStamp();
            //Post Test Condition Check
            Assert.AreEqual(1, oPCLoggerCacheAccessor.GetFieldAccessor("m_DataPointdic").GetProperty("Count"));
            Dictionary <string, OPCDPGrpDetails> dic = (Dictionary <string, OPCDPGrpDetails>)oPCLoggerCacheAccessor.GetField("m_DataPointdic");
            string          key1       = "SampleName";
            OPCDPGrpDetails opcDetails = dic[key1];

            Assert.AreEqual(60, opcDetails.Interval);
            //TODO
        }
Ejemplo n.º 15
0
        public void TestGetNextSampleTime02()
        {
            //Test --- First time called for intialization of the logger datapoints
            // Current time is correct log time
            OPCDataPointManager oPCDataPointManager = OPCDataPointManager.GetInstance();
            DateTime            starttime           = new DateTime(2013, 01, 29, 10, 25, 00);
            double   intervalInSecs         = 50;
            Accessor oPCLoggerCacheAccessor = ReflectionAccessor.Wrap(oPCDataPointManager);
            DateTime dateTime = (DateTime)oPCLoggerCacheAccessor.Call("GetNextSampleTime", starttime, intervalInSecs, true);

            //Post Test Condition Check
            Assert.AreEqual(System.DateTime.Now, dateTime);


            ////Test 2 --- Second time called for calculating next log time
            // Current time is greater than planned log time
            DateTime plannedTime = new DateTime(2013, 01, 29, 14, 25, 50);
            DateTime dateTime1   = (DateTime)oPCLoggerCacheAccessor.Call("GetNextSampleTime", plannedTime, intervalInSecs, false);
            //Post Test Condition Check
            DateTime currenttime = System.DateTime.Now;

            currenttime = currenttime.AddSeconds(intervalInSecs);
            Assert.AreEqual(currenttime, dateTime1);

            //Test --- current time is less than start time
            starttime = new DateTime(2013, 01, 29, 20, 25, 00);
            dateTime  = (DateTime)oPCLoggerCacheAccessor.Call("GetNextSampleTime", starttime, intervalInSecs, true);
            //Post Test Condition Check
            Assert.AreEqual(starttime, dateTime);


            //Test --- current time is less than planned time
            //not possible case in real time
            plannedTime = new DateTime(2013, 01, 29, 15, 21, 50);
            dateTime    = (DateTime)oPCLoggerCacheAccessor.Call("GetNextSampleTime", plannedTime, intervalInSecs, false);
            //Post Test Condition Check
            plannedTime = plannedTime.AddSeconds(50);
            Assert.AreEqual(plannedTime, dateTime);

            //Test --- currenttime is planned time with reminder 0
            plannedTime = new DateTime(2013, 01, 29, 14, 24, 10);
            dateTime    = (DateTime)oPCLoggerCacheAccessor.Call("GetNextSampleTime", plannedTime, intervalInSecs, false);
            //Post Test Condition Check
            plannedTime = System.DateTime.Now;
            plannedTime = plannedTime.AddSeconds(50);
            Assert.AreEqual(plannedTime, dateTime);
        }
Ejemplo n.º 16
0
        public void TestInitializeDataLogger03()
        {
            //Test2 ----- Valid database string but cannot connect to OPC
            OPCDataPointManager oPCDataPointManager = OPCDataPointManager.GetInstance();

            oPCDataPointManager.ExitApplicationEvent += new OPCDataPointManager.VoidEventHandler(oPCDataPointManager_ExitApplicationEvent);
            //Test Procedure Call
            oPCDataPointManager.InitializeDataLogger(false);
            //Post Condition Check
            Assert.IsTrue(bExitApplicationCalled);

            bExitApplicationCalled = false;

            //Test ----- Valid database string but cannot connect to OPC but not first called
            //Test Procedure Call
            oPCDataPointManager.InitializeDataLogger(true);
            //Post Condition Check
            Assert.IsFalse(bExitApplicationCalled);
        }
Ejemplo n.º 17
0
        public void TestRun04()
        {
            //Testing ----- Exception cases
            OPCLoggerQuene oPCLoggerQuene         = OPCLoggerQueneFactory.CreateOPCLoggerQuene02();
            Accessor       oPCLoggerQueneAccessor = ReflectionAccessor.Wrap(oPCLoggerQuene);

            oPCLoggerQueneAccessor.SetField("m_serviceStarted", true);
            Dictionary <string, OPCDPGrpDetails> opcdic = new Dictionary <string, OPCDPGrpDetails>();

            opcdic.Add("testingDP1", null);
            Accessor oPCMagerAccessor = ReflectionAccessor.Wrap(OPCDataPointManager.GetInstance());

            oPCMagerAccessor.SetField("m_DataPointdic", opcdic);
            System.Threading.ThreadStart func = new System.Threading.ThreadStart(oPCLoggerQuene.Run);
            System.Threading.Thread      t1   = new System.Threading.Thread(func);
            t1.Start();
            //wait till test completes
            m_OPCLoggerQuenesignal.WaitOne();
            //release all instances
            OPCDataPointManager.ReleaseInstance();
            OPCLoggerQueneFactory.ReleaseOPCLoggerQuene02();
        }
Ejemplo n.º 18
0
 public void TestisBoolean01()
 {
     OPCDataPointManager oPCDataPointManager = OPCDataPointManager.GetInstance();
     string val = "1";
     bool   b   = oPCDataPointManager.isBoolean(val);
 }
Ejemplo n.º 19
0
        public void TestCreateOPCDataPointManager02()
        {
            OPCDataPointManager oPCDataPointManager = CreateOPCDataPointManager02();

            Assert.IsNotNull(oPCDataPointManager);
        }
Ejemplo n.º 20
0
        internal static OPCDataPointManager CreateOPCDataPointManager02()
        {
            OPCDataPointManager oPCDataPointManager = (OPCDataPointManager)ReflectionAccessor.Construct("OPCDataLogger.OPCDataPointManager");

            return(oPCDataPointManager);
        }
Ejemplo n.º 21
0
        internal static OPCDataPointManager CreateOPCDataPointManager01()
        {
            OPCDataPointManager oPCDataPointManager = OPCDataPointManager.GetInstance();

            return(oPCDataPointManager);
        }
Ejemplo n.º 22
0
 public void SuiteSetUp()
 {
     //release if has been used by any other test suites.
     OPCDataPointManager.ReleaseInstance();
 }
Ejemplo n.º 23
0
 public void TestOPCLoggerCacheConstructor01()
 {
     OPCDataPointManager oPCDataPointManager = (OPCDataPointManager)ReflectionAccessor.Construct("OPCDataLogger.OPCDataPointManager");
 }
Ejemplo n.º 24
0
        public void TestReleaseInstance01()
        {
            OPCDataPointManager oPCDataPointManager = OPCDataPointManager.GetInstance();

            OPCDataPointManager.ReleaseInstance();
        }
Ejemplo n.º 25
0
 public void TestGetInstance01()
 {
     // Having valid TimeinMilliSecs -- logging sleep time in config file
     OPCDataPointManager oPCDataPointManager = OPCDataPointManager.GetInstance();
 }
Ejemplo n.º 26
0
 public void TesttearDown()
 {
     OPCDataPointManager.ReleaseInstance();
 }
Ejemplo n.º 27
0
 public void TestGetLoggerInterval01()
 {
     OPCDataPointManager oPCDataPointManager = OPCDataPointManager.GetInstance();
     int i = oPCDataPointManager.GetLoggerInterval();
 }
Ejemplo n.º 28
0
        public void TestTerminateAndWait01()
        {
            OPCDataPointManager oPCDataPointManager = OPCDataPointManager.GetInstance();

            oPCDataPointManager.TerminateAndWait();
        }
Ejemplo n.º 29
0
 public void TestGetOPCLoggerDataPoints01()
 {
     OPCDataPointManager oPCDataPointManager         = OPCDataPointManager.GetInstance();
     Dictionary <string, OPCDPGrpDetails> dictionary = oPCDataPointManager.GetOPCLoggerDataPoints();
 }