Example #1
0
        public void TestAddHistDataPointData_ModifyHistDataPoint_03()
        {
            //! m_View.GetStartDate() > m_View.GetEndDate()
            //m_View.GetHistDataPointName() !=""

            Accessor ctlAccessor = ReflectionAccessor.Wrap(histDataPointDataController);

            TrendViewer.View.HistDataPointData view = (TrendViewer.View.HistDataPointData)ctlAccessor.GetField("m_View");
            EtyHistDataPoint dp = new EtyHistDataPoint();

            dp.DPName          = "tempName";
            dp.DPStartDateTime = new DateTime(2013, 1, 1);
            dp.DPEndDateTime   = new DateTime(2013, 1, 2);
            view.SetFormType(FormType.Edit);
            view.Display(dp);

            // HistDataPointNameValid(dpName)
            histDataPointDataController.AddHistDataPointData(null, null);
            histDataPointDataController.ModifyHistDataPoint(null, null);

            //!HistDataPointNameValid(dpName)
            dp.DPName = "dpName1";
            view.Display(dp);
            histDataPointDataController.AddHistDataPointData(null, null);
            histDataPointDataController.ModifyHistDataPoint(null, null);
        }
Example #2
0
        public void TestStartRealTimeOrMixedModeCharting01()
        {
            DataPointListModel  dataPointListModel = new DataPointListModel();
            List <EtyDataPoint> dpList             = dataPointListModel.GetDPListByGrp(TestConst.GROUP_NAME);

            TrendViewModel trendViewModel = new TrendViewModel();
            DateTime       fromTime       = new DateTime(2013, 1, 10);
            DateTime       toTime         = new DateTime(2013, 1, 12);

            EtyHistDataPoint histDP = new EtyHistDataPoint();

            histDP.DPName          = TestConst.HIST_DP_NAME;
            histDP.DPServer        = TestConst.SERVER;
            histDP.DPStartDateTime = fromTime;
            histDP.DPEndDateTime   = toTime;
            histDP.DPEnabled       = true;
            histDP.DPHost          = TestConst.HOST;
            histDP.DPType          = LineType.Line;

            List <EtyDataLogDPLogTrend> logList = trendViewModel.GetHistDPLogList(histDP, fromTime, toTime);
            Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> > histDPLogMap = new Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> >();

            histDPLogMap.Add(histDP, logList);

            MarkerListModel  markerListModel = new MarkerListModel();
            List <EtyMarker> markerList      = markerListModel.GetMarkerListByGrp(TestConst.MARK_GROUP_NAME);

            FormulaListModel  formulaListModel = new FormulaListModel();
            List <EtyFormula> formulaList      = formulaListModel.GetFormulaListByGrp(TestConst.FORMULA_GROUP_NAME);

            trendView.StartRealTimeOrMixedModeCharting(dpList, formulaList, markerList, histDPLogMap);
        }
Example #3
0
        public void Test_Delete_Insert_GetHistDPGrp()
        {
            string histDPGrpName = "unitTest_histDPGrp";

            histDataPointDAO.DeleteAllHistDPInGrp(histDPGrpName);

            List <EtyHistDataPoint> histDPList = new List <EtyHistDataPoint>();
            EtyHistDataPoint        dp1        = new EtyHistDataPoint();
            EtyHistDataPoint        dp2        = new EtyHistDataPoint();

            dp1.DPName    = "histDP1";
            dp2.DPName    = "histDP2";
            dp1.EntityKey = 1;
            dp2.DPColor   = Color.Red.ToArgb().ToString();
            dp2.DPLblName = "lbl1";
            dp2.DPServer  = TestDBInit.OPCSERVER_NAME;
            dp2.DPHost    = TestDBInit.HOST_NAME;
            histDPList.Add(dp1);
            histDPList.Add(dp2);

            // histDataPointDAO.InsertHistDPListToGrp(histDPList, histDPGrpName);
            histDataPointDAO.SaveHistDPListToGrp(histDPList, histDPGrpName);

            histDataPointDAO.GetHistDPByCfgName(histDPGrpName);
        }
Example #4
0
 public void TestUpdateHistDPNameAndLabel()
 {
     using (HistDataPointData histDataPointData = HistDataPointDataFactory.CreateHistDataPointData01())
     {
         EtyHistDataPoint dp = new EtyHistDataPoint();
         histDataPointData.UpdateHistDPNameAndLabel(dp);
     }
 }
Example #5
0
        public void TestDisplay()
        {
            histDataPointData.SetFormType(FormType.Edit);
            EtyHistDataPoint dp = new EtyHistDataPoint();

            dp.DPColor = "-32704";
            histDataPointData.Display(dp);
        }
        public void AddHistDataPointToList(EtyHistDataPoint dataPoint)
        {
            DataRow newDataPointDataPointRow = m_DataPointTable.NewRow();

            SetHistDataPointRowByEty(ref newDataPointDataPointRow, dataPoint);

            m_DataPointTable.Rows.Add(newDataPointDataPointRow);
            m_View.PopulateDataPointListDataGridView(1, m_DataPointTable);
        }
Example #7
0
        public void TestUpdateChartForRealTimeOrMixedMode03()
        {
            //same as TestUpdateChartForRealTimeOrMixedMode01,but Eval(tempString) throw exception
            DateTime fromTime = new DateTime(2013, 1, 10);
            DateTime toTime   = new DateTime(2013, 1, 12);

            EtyHistDataPoint histDP = new EtyHistDataPoint();

            histDP.DPName          = TestConst.HIST_DP_NAME;
            histDP.DPServer        = TestConst.SERVER;
            histDP.DPStartDateTime = fromTime;
            histDP.DPEndDateTime   = toTime;
            histDP.DPEnabled       = true;
            histDP.DPHost          = TestConst.HOST;
            histDP.DPType          = LineType.Line;
            TrendViewModel trendViewModel = new TrendViewModel();

            List <EtyDataLogDPLogTrend> logList = trendViewModel.GetHistDPLogList(histDP, fromTime, toTime);
            Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> > histDPLogMap = new Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> >();

            histDPLogMap.Add(histDP, logList);

            //stub:
            //OPCServerProxy.GetInstance().IsOPCServerConnected() == true

            //make sure series has contents:
            List <EtyDataPoint> dpList = new List <EtyDataPoint>();
            EtyDataPoint        etyDP  = new EtyDataPoint();

            etyDP.DPColor   = "-32704";
            etyDP.DPName    = TestConst.DP_NAME;
            etyDP.DPEnabled = true;
            etyDP.DPServer  = "TransActiveDataSource";
            etyDP.DPType    = LineType.Line;
            etyDP.DPVisible = true;
            etyDP.DPHost    = "127.0.0.1";
            dpList.Add(etyDP);
            List <EtyFormula> formulaList = new List <EtyFormula>();
            EtyFormula        formula     = new EtyFormula();

            formula.DPColor   = "-32704";
            formula.DPEnabled = true;
            formula.DPLblName = "formulaLblName";
            formula.DPType    = LineType.Line;
            formulaList.Add(formula);
            trendView.InitializeChartForRealTime(dpList, formulaList);

            // (mixedModeCb.Checked && m_startDateRealTime.Date != DateTime.Now.Date)
            CheckBox cb = (CheckBox)viewAccessor.GetField("mixedModeCb");

            cb.Checked = true;
            viewAccessor.SetField("mixedModeCb", cb);
            DateTime dt = new DateTime(2011, 1, 1);

            viewAccessor.SetField("m_startDateRealTime", dt);
            trendView.UpdateChartForRealTimeOrMixedMode(histDPLogMap);
        }
Example #8
0
        public void TestAddHistDataPointToList_ModifyHistDataPoint_DeleteByHistDataPointName()
        {
            EtyHistDataPoint dp = new EtyHistDataPoint();

            dp.DPName = "temp";

            histDataPointListController.AddHistDataPointToList(dp);

            histDataPointListController.ModifyHistDataPoint("temp", dp);
            histDataPointListController.DeleteByHistDataPointName("temp");
        }
Example #9
0
        public void TestEtyHistDataPoint01()
        {
            EtyHistDataPoint etyHistDataPoint = new EtyHistDataPoint();

            string s = etyHistDataPoint.ConfigName;

            etyHistDataPoint.ConfigName = s;

            s = etyHistDataPoint.DisplayName;
            etyHistDataPoint.DisplayName = s;

            s = etyHistDataPoint.Description;
            etyHistDataPoint.Description = s;

            s = etyHistDataPoint.DPColor;
            etyHistDataPoint.DPColor = s;

            bool b = etyHistDataPoint.DPEnabled;

            etyHistDataPoint.DPEnabled = b;

            DateTime dt = etyHistDataPoint.DPEndDateTime;

            etyHistDataPoint.DPEndDateTime = dt;

            s = etyHistDataPoint.DPHost;
            etyHistDataPoint.DPHost = s;

            b = etyHistDataPoint.DPLblEnabled;
            etyHistDataPoint.DPLblEnabled = b;

            s = etyHistDataPoint.DPLblName;
            etyHistDataPoint.DPLblName = s;

            s = etyHistDataPoint.DPName;
            etyHistDataPoint.DPName = s;

            s = etyHistDataPoint.DPServer;
            etyHistDataPoint.DPServer = s;

            dt = etyHistDataPoint.DPStartDateTime;
            etyHistDataPoint.DPStartDateTime = dt;

            LineType lineType = etyHistDataPoint.DPType;

            etyHistDataPoint.DPType = lineType;

            ulong pkey = etyHistDataPoint.PKey;

            etyHistDataPoint.PKey = pkey;

            etyHistDataPoint.EntityKey = 1;
            etyHistDataPoint.EntityKey = etyHistDataPoint.EntityKey;
        }
        public List <EtyHistDataPoint> ConvertDataTableToList()
        {
            List <EtyHistDataPoint> dataPointList = new List <EtyHistDataPoint>();

            foreach (DataRow dataPointRow in m_DataPointTable.Rows)
            {
                EtyHistDataPoint dataPoint = new EtyHistDataPoint();
                SetHistDataPointEtyByRow(ref dataPoint, dataPointRow);
                dataPointList.Add(dataPoint);
            }
            return(dataPointList);
        }
Example #11
0
        public void TestGetHistDPLogList()
        {
            EtyHistDataPoint histDP = new EtyHistDataPoint();

            histDP.EntityKey       = 10147653;
            histDP.DPStartDateTime = new DateTime(2013, 5, 10);
            histDP.DPEndDateTime   = new DateTime(2013, 5, 11);

            DateTime startTime = new DateTime(2013, 5, 10, 1, 1, 1);
            DateTime endTime   = new DateTime(2013, 5, 10, 23, 59, 59);

            DataLogDPLogTrendDAO.GetInstance().GetHistDPLogList(histDP, startTime, endTime);
        }
Example #12
0
        public void TestSetHistDataPointEtyByRow()
        {
            Accessor  ctlAccessor = ReflectionAccessor.Wrap(histDataPointListController);
            DataTable table       = (DataTable)ctlAccessor.GetField("m_DataPointTable");
            DataRow   row         = table.NewRow();

            row["DATA_PT_DT"]     = new DateTime(2013, 1, 1);
            row["DATA_PT_DT_END"] = new DateTime(2013, 1, 2);
            row["ENTITYKEY"]      = 0;
            EtyHistDataPoint dp = new EtyHistDataPoint();

            histDataPointListController.SetHistDataPointEtyByRow(ref dp, row);
        }
        public void ModifyHistDataPoint(string dataPointName, EtyHistDataPoint DataPoint)
        {
            foreach (DataRow dpRow in m_DataPointTable.Rows)  //will only have 1 record
            {
                if (dataPointName == dpRow["DATA_PT_NAME"].ToString())
                {
                    DataRow row = dpRow;
                    SetHistDataPointRowByEty(ref row, DataPoint);
                }
            }

            m_View.PopulateDataPointListDataGridView(1, m_DataPointTable);
        }
Example #14
0
        public void TestInsertHistDPListToGrp02()
        {
            //test "executeOK == false"

            List <EtyHistDataPoint> histDPList = new List <EtyHistDataPoint>();
            EtyHistDataPoint        dp1        = new EtyHistDataPoint();

            dp1.DPName    = "histDP1";
            dp1.EntityKey = 1;
            histDPList.Add(dp1);


            histDataPointDAO.InsertHistDPListToGrp(histDPList, "");
        }
 public void SetHistDataPointEtyByRow(ref EtyHistDataPoint dataPoint, DataRow dpRow)
 {
     dataPoint.DPHost          = dpRow["DATA_PT_HOST"].ToString();
     dataPoint.DPName          = dpRow["DATA_PT_NAME"].ToString();
     dataPoint.DPType          = TrendViewerHelper.convertLineTypeToEnum(dpRow["DATA_PT_TYPE"].ToString());
     dataPoint.DPColor         = dpRow["DATA_PT_COLOR"].ToString();
     dataPoint.DPServer        = dpRow["DATA_PT_SERVER"].ToString();
     dataPoint.DPLblName       = dpRow["DATA_PT_LBL_NAME"].ToString();
     dataPoint.DPEnabled       = TrendViewerHelper.ChangeStrToBool(dpRow["DATA_PT_ENABLED"].ToString());
     dataPoint.DPLblEnabled    = TrendViewerHelper.ChangeStrToBool(dpRow["DATA_PT_LBL_ENABLED"].ToString());
     dataPoint.DPStartDateTime = (DateTime)(dpRow["DATA_PT_DT"]);
     dataPoint.DPEndDateTime   = (DateTime)(dpRow["DATA_PT_DT_END"]);
     dataPoint.EntityKey       = Convert.ToUInt64(dpRow["ENTITYKEY"]);
 }
 private void SetHistDataPointRowByEty(ref DataRow dpRow, EtyHistDataPoint dataPoint)
 {
     dpRow["DATA_PT_NAME"]        = dataPoint.DPName;
     dpRow["DATA_PT_TYPE"]        = TrendViewerHelper.convertLineTypeToDispLan(dataPoint.DPType);
     dpRow["DATA_PT_COLOR"]       = dataPoint.DPColor;
     dpRow["DATA_PT_SERVER"]      = dataPoint.DPServer;
     dpRow["DATA_PT_ENABLED"]     = TrendViewerHelper.ChangeBoolToStr(dataPoint.DPEnabled);
     dpRow["DATA_PT_LBL_ENABLED"] = TrendViewerHelper.ChangeBoolToStr(dataPoint.DPLblEnabled);
     dpRow["DATA_PT_LBL_NAME"]    = dataPoint.DPLblName;
     dpRow["DATA_PT_DT"]          = dataPoint.DPStartDateTime;
     dpRow["DATA_PT_HOST"]        = dataPoint.DPHost;
     dpRow["DATA_PT_DT_END"]      = dataPoint.DPEndDateTime;
     dpRow["ENTITYKEY"]           = dataPoint.EntityKey;
 }
Example #17
0
        public void TestGetHistDPLogList()
        {
            EtyHistDataPoint histDP = new EtyHistDataPoint();

            histDP.DPName          = "DT17.COM.CBN.RF2.diiRF-AlarmNormal.Value";
            histDP.DPServer        = TestDBInit.OPCSERVER_NAME; //"TransActiveDataSource"
            histDP.DPHost          = TestDBInit.HOST_NAME;
            histDP.DPStartDateTime = new DateTime(2013, 1, 10);
            histDP.DPEndDateTime   = new DateTime(2013, 1, 12);

            DateTime startTime = new DateTime(2012, 1, 10, 1, 1, 1);
            DateTime endTime   = new DateTime(2012, 1, 12, 23, 59, 59);

            TrendLogDAO.GetInstance().GetHistDPLogList(histDP, startTime, endTime);
        }
Example #18
0
        public void ModifyHistDataPoint(object sender, EventArgs e)
        {
            string Function_Name = "ModifyHistDataPoint";

            if (m_View.GetStartDate() > m_View.GetEndDate())
            {
                MessageBoxDialog.Show(
                    StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_Msg_StartDateMoreThenEnd, LanguageHelper.TrendViewer_Msg_StartDateMoreThenEnd_EN),
                    StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_Msg_WarningTitle, LanguageHelper.TrendViewer_Msg_WarningTitle_EN),
                    MessageBoxButtons.OK, MessageBoxIcon.Warning
                    );
                return;
            }

            string dpName = m_View.GetHistDataPointName();

            if (dpName == "")
            {
                return;
            }

            if (!HistDataPointNameValid(dpName))  //means has duplicate names
            {
                MessageBoxDialog.Show(StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_Msg_DuplicateName, LanguageHelper.TrendViewer_Msg_DuplicateName_EN),
                                      StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_Msg_ErrTitle, LanguageHelper.TrendViewer_Msg_ErrTitle_EN), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            EtyHistDataPoint histDP = m_View.GetNewHistDataPoint();

            try
            {
                histDP.EntityKey = m_Model.GetEntityKeyByName(histDP.DPName);  //update the entityKey
            }
            catch (DatabaseConnectionException ex)
            {
//                 MessageBoxDialog.Show(
//                     StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_Msg_NoDB, LanguageHelper.TrendViewer_Msg_NoDB_EN),
//                     StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_Msg_ErrTitle, LanguageHelper.TrendViewer_Msg_ErrTitle_EN),
//                     MessageBoxButtons.OK, MessageBoxIcon.Error);
                STEE.ISCS.Log.LogHelper.Error(CLASS_NAME, Function_Name, "Can't get entitykey for historical datapoint - " + histDP.DPName + ", due to DB error.");
            }

            KeyValuePair <string, EtyHistDataPoint> pair = new KeyValuePair <string, EtyHistDataPoint>(m_originalName, histDP);

            NotifyManager.GetInstance().Send(DataNotificaitonConst.ModifyHistDataPoint, m_View.ViewID, pair);
            m_View.DestroyView();
        }
        public EtyHistDataPoint GetNewHistDataPoint()
        {
            EtyHistDataPoint dataPoint = new EtyHistDataPoint();

            dataPoint.DPHost          = opcServerHostBox.Text;
            dataPoint.DPServer        = opcServerNameBox.Text;
            dataPoint.DPName          = dataPointBox.Text;
            dataPoint.DPType          = TrendViewerHelper.convertLineTypeToEnum(seriesTypeBox.Text);
            dataPoint.DPLblName       = dataLegendBox.Text;
            dataPoint.DPColor         = colorPanel.BackColor.ToArgb().ToString();
            dataPoint.DPEnabled       = dataPointEnabledCb.Checked;
            dataPoint.DPLblEnabled    = labelEnabledCb.Checked;
            dataPoint.DPStartDateTime = historyStartDateBox.Value;
            dataPoint.DPEndDateTime   = historyEndDateBox.Value;

            return(dataPoint);
        }
        //when usedInMixedMode is false, will ignore startTime and endTime
        public Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> > GetHistDPLogMap(DateTime startTime, DateTime endTime)
        {
            Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> > histDPLogMap = new Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> >();
            EtyHistDataPoint            dp        = null;
            List <EtyDataLogDPLogTrend> dpLogList = null;

            foreach (EtyHistDataPoint histDP in m_trendCache.m_histDataPointList)
            {
                if (histDP.DPEnabled == false)
                {
                    continue;
                }
                dpLogList = m_Model.GetHistDPLogList(histDP, startTime, endTime);
                histDPLogMap.Add(histDP, dpLogList);
            }
            return(histDPLogMap);
        }
        public void Display(EtyHistDataPoint dp)
        {
            string Function_Name = "Display";

            opcServerHostBox.Text = ConfigureFileHelper.GetInstance().HostIPAddress; //dp.DPHost.ToString();
            opcServerNameBox.Text = ConfigureFileHelper.GetInstance().OPCServerName; //dp.DPServer.ToString();

            colorPanel.BackColor = Color.Black;

            DateTime currentDT = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);

            historyStartDateBox.Value = currentDT;
            currentDT = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
            historyEndDateBox.Value = currentDT;

            try
            {
                seriesTypeBox.Items.Add(StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_LintTypeLine, LanguageHelper.TrendViewer_LintTypeLine_EN));
                seriesTypeBox.Items.Add(StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_LintTypeSpline, LanguageHelper.TrendViewer_LintTypeSpline_EN));
                seriesTypeBox.Text = StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_LintTypeLine, LanguageHelper.TrendViewer_LintTypeLine_EN);
                if (this.m_formType == FormType.Edit)
                {
                    opcServerHostBox.Text = dp.DPHost.ToString();
                    opcServerNameBox.Text = dp.DPServer.ToString();
                    dataPointBox.Text     = dp.DPName.ToString();
                    seriesTypeBox.Text    = TrendViewerHelper.convertLineTypeToDispLan(dp.DPType);
                    dataLegendBox.Text    = dp.DPLblName;
                    if (TrendViewerHelper.isNumeric(dp.DPColor, System.Globalization.NumberStyles.Number))
                    {
                        colorPanel.BackColor = Color.FromArgb(Convert.ToInt32(dp.DPColor));
                    }
                    dataPointEnabledCb.Checked = dp.DPEnabled;
                    labelEnabledCb.Checked     = dp.DPLblEnabled;

                    historyStartDateBox.Value = dp.DPStartDateTime;
                    historyEndDateBox.Value   = dp.DPEndDateTime;
                }
            }
            catch (Exception localException)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, localException.ToString());
            }
        }
Example #22
0
        public void TestStartRealTimeOrMixedModeCharting02()
        { //stub:IsOPCServerConnected = true
            DataPointListModel  dataPointListModel = new DataPointListModel();
            List <EtyDataPoint> dpList             = dataPointListModel.GetDPListByGrp(TestConst.GROUP_NAME);

            TrendViewModel trendViewModel = new TrendViewModel();
            DateTime       fromTime       = new DateTime(2013, 1, 10);
            DateTime       toTime         = new DateTime(2013, 1, 12);

            EtyHistDataPoint histDP = new EtyHistDataPoint();

            histDP.DPName          = TestConst.HIST_DP_NAME;
            histDP.DPServer        = TestConst.SERVER;
            histDP.DPStartDateTime = fromTime;
            histDP.DPEndDateTime   = toTime;
            histDP.DPEnabled       = true;
            histDP.DPHost          = TestConst.HOST;
            histDP.DPType          = LineType.Line;

            List <EtyDataLogDPLogTrend> logList = trendViewModel.GetHistDPLogList(histDP, fromTime, toTime);
            Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> > histDPLogMap = new Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> >();

            histDPLogMap.Add(histDP, logList);

            MarkerListModel  markerListModel = new MarkerListModel();
            List <EtyMarker> markerList      = markerListModel.GetMarkerListByGrp(TestConst.MARK_GROUP_NAME);

            FormulaListModel  formulaListModel = new FormulaListModel();
            List <EtyFormula> formulaList      = formulaListModel.GetFormulaListByGrp(TestConst.FORMULA_GROUP_NAME);

            System.Windows.Forms.CheckBox cb = (System.Windows.Forms.CheckBox)viewAccessor.GetField("mixedModeCb");
            cb.Checked = false;
            viewAccessor.SetField("mixedModeCb", cb);

            //stub: OPCServerProxy.GetInstance().IsOPCServerConnected() == true:
            trendView.StartRealTimeOrMixedModeCharting(dpList, formulaList, markerList, histDPLogMap);

            //mixedModeCb.Checked==true:
            cb.Checked = true;
            viewAccessor.SetField("mixedModeCb", cb);
            trendView.StartRealTimeOrMixedModeCharting(dpList, formulaList, markerList, histDPLogMap);
        }
        public void SaveHistDataPointListToGroup(string grpName)
        {
            string Function_Name = "SaveHistDataPointListToGroup";

            List <EtyHistDataPoint> dataPointList = new List <EtyHistDataPoint>();

            foreach (DataRow dataPointRow in m_DataPointTable.Rows)
            {
                EtyHistDataPoint DataPoint = new EtyHistDataPoint();
                SetHistDataPointEtyByRow(ref DataPoint, dataPointRow);
                dataPointList.Add(DataPoint);
            }

            try
            {
                m_Model.SaveHistDPListToGroup(dataPointList, grpName);
            }
            catch (Exception ex)
            {
                TrendViewerHelper.HandleEx(ex);
            }
        }
Example #24
0
        public void TestStartRealTimeOrMixedModeCharting04()
        {
            //stub:IsOPCServerConnected = false
            ////RemoveAllOPCItem throw Exception
            DataPointListModel  dataPointListModel = new DataPointListModel();
            List <EtyDataPoint> dpList             = dataPointListModel.GetDPListByGrp(TestConst.GROUP_NAME);

            TrendViewModel trendViewModel = new TrendViewModel();
            DateTime       fromTime       = new DateTime(2013, 1, 10);
            DateTime       toTime         = new DateTime(2013, 1, 12);

            EtyHistDataPoint histDP = new EtyHistDataPoint();

            histDP.DPName          = TestConst.HIST_DP_NAME;
            histDP.DPServer        = TestConst.SERVER;
            histDP.DPStartDateTime = fromTime;
            histDP.DPEndDateTime   = toTime;
            histDP.DPEnabled       = true;
            histDP.DPHost          = TestConst.HOST;
            histDP.DPType          = LineType.Line;

            List <EtyDataLogDPLogTrend> logList = trendViewModel.GetHistDPLogList(histDP, fromTime, toTime);
            Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> > histDPLogMap = new Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> >();

            histDPLogMap.Add(histDP, logList);

            MarkerListModel  markerListModel = new MarkerListModel();
            List <EtyMarker> markerList      = markerListModel.GetMarkerListByGrp(TestConst.MARK_GROUP_NAME);

            FormulaListModel  formulaListModel = new FormulaListModel();
            List <EtyFormula> formulaList      = formulaListModel.GetFormulaListByGrp(TestConst.FORMULA_GROUP_NAME);


            //stub: OPCServerProxy.GetInstance().IsOPCServerConnected()==true  //OPC server connected
            // OPCServerProxy.GetInstance().RemoveAllOPCItem() throw System.Exception
            trendView.StartRealTimeOrMixedModeCharting(dpList, formulaList, markerList, histDPLogMap);
        }
Example #25
0
        public void TestDrawHistoryChart()
        {
            DataPointListModel  dataPointListModel = new DataPointListModel();
            List <EtyDataPoint> dpList             = dataPointListModel.GetDPListByGrp(TestConst.GROUP_NAME);

            TrendViewModel trendViewModel = new TrendViewModel();
            DateTime       fromTime       = new DateTime(2013, 1, 10);
            DateTime       toTime         = new DateTime(2013, 1, 12);

            EtyHistDataPoint histDP = new EtyHistDataPoint();

            histDP.DPName          = TestConst.HIST_DP_NAME;
            histDP.DPServer        = TestConst.SERVER;
            histDP.DPStartDateTime = fromTime;
            histDP.DPEndDateTime   = toTime;
            histDP.DPEnabled       = true;
            histDP.DPHost          = TestConst.HOST;
            histDP.DPType          = LineType.Line;
            histDP.DPColor         = "-32704";

            List <EtyDataLogDPLogTrend> logList = trendViewModel.GetHistDPLogList(histDP, fromTime, toTime);
            Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> > histDPLogMap = new Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> >();

            histDPLogMap.Add(histDP, logList);

            viewAccessor.Call("DrawHistoryChart", DrawHistoryMode.Mixed, histDPLogMap);

            logList = new List <EtyDataLogDPLogTrend>();
            EtyDataLogDPLogTrend log = new EtyDataLogDPLogTrend();

            logList.Add(log);
            histDPLogMap = new Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> >();
            histDPLogMap.Add(histDP, logList);
            viewAccessor.Call("DrawHistoryChart", DrawHistoryMode.Mixed, histDPLogMap);

            viewAccessor.Call("DrawHistoryChart", DrawHistoryMode.NotMixed, histDPLogMap);
        }
Example #26
0
        /// <summary>
        /// get dp log list for a historical dp to plot
        /// </summary>
        /// <param name="histDP">the given historical dp for charting</param>
        /// <param name="startTime">start time</param>
        /// <param name="endTime">end time</param>
        /// <returns>trend log list</returns>
        public List <EtyTrendLog> GetHistDPLogList(EtyHistDataPoint histDP, DateTime startTime, DateTime endTime)
        {
            string             Function_Name = "GetHistDPLogList";
            List <EtyTrendLog> res           = new List <EtyTrendLog>();
            string             localSQL;

            //changed by luxiangmei, to make the logic for historical mode the same as mixed mode.
            //                 if (usedInMixMode)  //used in mixed mode
            //                 {
            localSQL = " SELECT DATA_PT_DATE,DATA_PT_VALUE " +
                       " FROM TRENDVIEWER_LOG WHERE DATA_PT_NAME = '" + DAOHelper.convertEscapeStringAndGB2312To8859P1(histDP.DPName) + "' " +
                       " AND DATA_PT_SERVER = '" + DAOHelper.convertEscapeStringAndGB2312To8859P1(histDP.DPServer) + "' " +
                       " AND DATA_PT_HOST = '" + DAOHelper.convertEscapeStringAndGB2312To8859P1(histDP.DPHost) + "' " +
                       " AND DATA_PT_DATE >= @StartDateValue" +
                       " AND DATA_PT_DATE <= @EndDateValue" +
                       " ORDER BY DATA_PT_DATE";
            //                 }
            //                 else  // used in history mode, will ignore "startTime" and "endTime"
            //                 {
            //                     localSQL = " SELECT DATA_PT_DATE,DATA_PT_VALUE " +
            //                          " FROM TRENDVIEWER_LOG WHERE DATA_PT_NAME = '" + DAOHelper.convertGB2312To8859P1(histDP.DPName) + "' " +
            //                          " AND DATA_PT_SERVER = '" + DAOHelper.convertGB2312To8859P1(histDP.DPServer) + "' " +
            //                          " AND DATA_PT_HOST = '" + DAOHelper.convertGB2312To8859P1(histDP.DPHost) + "' " +
            //                          " AND DATA_PT_DATE >= to_date(" + histDP.DPStartDateTime.ToString("yyyyMMdd") +
            //                          "000000,'YYYYMMDDHH24MISS') " +
            //                          " AND DATA_PT_DATE <= to_date(" + histDP.DPEndDateTime.ToString("yyyyMMdd") +
            //                           "235959,'YYYYMMDDHH24MISS')  " +
            //                          " ORDER BY DATA_PT_DATE";
            //                 }

            SqlParameter parameter1 = new SqlParameter();

            parameter1.ParameterName = "StartDateValue";
            parameter1.DbType        = DbType.DateTime;
            DateTime dtStart = new DateTime(histDP.DPStartDateTime.Year, histDP.DPStartDateTime.Month, histDP.DPStartDateTime.Day,
                                            startTime.Hour, startTime.Minute, startTime.Second);

            parameter1.Value     = dtStart;
            parameter1.Direction = System.Data.ParameterDirection.Input;
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(parameter1);


            SqlParameter parameter2 = new SqlParameter();

            parameter2.ParameterName = "EndDateValue";
            parameter2.DbType        = DbType.DateTime;
            DateTime dtEnd = new DateTime(histDP.DPEndDateTime.Year, histDP.DPEndDateTime.Month, histDP.DPEndDateTime.Day,
                                          endTime.Hour, endTime.Minute, endTime.Second);

            parameter2.Value     = dtEnd;
            parameter2.Direction = System.Data.ParameterDirection.Input;
            parameters.Add(parameter2);

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQueryWithParams(localSQL, parameters);
            try
            {
                while (drReader != null && drReader.Read())
                {
                    EtyTrendLog entity = new EtyTrendLog();

                    if (!drReader.IsDBNull(drReader.GetOrdinal("DATA_PT_DATE")))
                    {
                        DateTime dt;
                        if (DateTime.TryParse(drReader["DATA_PT_DATE"].ToString(), out dt))
                        {
                            entity.Data_PT_Time = dt;
                        }
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("DATA_PT_VALUE")))
                    {
                        entity.Data_PT_Value = Convert.ToDouble(drReader["DATA_PT_VALUE"]);
                    }

                    res.Add(entity);
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
            }

            if (drReader != null)
            {
                drReader.Close();
                drReader.Dispose();
            }

            return(res);
        }
        private void ExportHistoryData(string filename)
        {
            string Function_Name = "ExportHistoryData";

            try
            {
                // Open Stream for Writing

                System.IO.StreamWriter SW;
                SW = System.IO.File.AppendText(filename);

                EtyHistDataPoint histDP      = null;
                string           originalMsg = "";
                string           messageData = "";
                DateTime         startTime   = m_View.GetStartTime();
                DateTime         endTime     = m_View.GetEndTime();
                bool             hasData     = false;

                for (int i = 0; i < m_trendCache.m_histDataPointList.Count; i++)
                {
                    histDP = m_trendCache.m_histDataPointList[i];
                    if (histDP.DPEnabled == false)
                    {
                        continue;
                    }

                    if (histDP.DPName.Trim() != "")
                    {
                        List <EtyDataLogDPLogTrend> histDPLogList = m_Model.GetHistDPLogList(m_trendCache.m_histDataPointList[i], startTime, endTime);

                        originalMsg = histDP.DPName + "," + histDP.DPServer;
                        foreach (EtyDataLogDPLogTrend dpLog in histDPLogList)
                        {
                            messageData  = originalMsg;
                            messageData += "," + dpLog.Value.ToString();
                            messageData += "," + dpLog.CreateTime.ToString("dd'/'MM'/'yyyy hh:mm:ss tt"); // ("dd-MM-yyyy HH:mm:ss");
                            messageData += "," + "127.0.0.1";                                             //histDP.DPHost.ToString();
                            SW.WriteLine(messageData);
                            hasData = true;
                        }
                    }
                }

                SW.Close();
                if (!hasData)
                {
                    File.Delete(filename);
                    MessageBoxDialog.Show(
                        StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_Msg_ExportNoData, LanguageHelper.TrendViewer_Msg_ExportNoData_EN),
                        StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_Msg_WarningTitle, LanguageHelper.TrendViewer_Msg_WarningTitle_EN),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Warning);
                    LogHelper.Error(CLASS_NAME, Function_Name, "No Data for current Datapoint History.");
                    return;
                }

                MessageBoxDialog.Show(StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_Msg_ExportOK, LanguageHelper.TrendViewer_Msg_ExportOK_EN));
            }
            catch (Exception ex)
            {
                TrendViewerHelper.HandleEx(ex);
            }
        }
//         /// <summary>
//         /// insert a record into TRENDVIEWER_LOG
//         /// </summary>
//         /// <param name="etyTrendLog">a record of trending log</param>
//         /// <returns>true/false(successful/failed)</returns>
//         public bool InsertTrendViewerLog(EtyTrendLog etyTrendLog)
//         {
//             string Function_Name = "InsertTrendViewerLog";
//             LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
//             bool result = false;
//             /*string localSQL = " INSERT INTO TRENDVIEWER_LOG(DATA_PT_HOST," +
//                                        "DATA_PT_SERVER,DATA_PT_NAME,DATA_PT_VALUE,DATA_PT_DATE) " +
//                                         " VALUES( '" + etyTrendLog.Data_PT_Host + "'" +
//                                         " ,'" + etyTrendLog.Data_PT_Server + "'" +
//                                         " ,'" + etyTrendLog.Data_PT_Name + "'" +
//                                         " ,'" + etyTrendLog.Data_PT_Value + "'" +
//                                         " , to_date('" + etyTrendLog.Data_PT_Time.ToString("yyyyMMddHHmmss") + "','YYYYMMDDHH24MISS') " +
//                                         " )";
//             result = SimpleDatabase.getInstance().ExecuteAndReturnNonQuery(localSQL);*/
//             string localSQL = " INSERT INTO TRENDVIEWER_LOG(DATA_PT_HOST," +
//                                        "DATA_PT_SERVER,DATA_PT_NAME,DATA_PT_VALUE,DATA_PT_DATE) " +
//                                         " VALUES( '" + etyTrendLog.Data_PT_Host + "'" +
//                                         " ,'" + etyTrendLog.Data_PT_Server + "'" +
//                                         " ,'" + etyTrendLog.Data_PT_Name + "'" +
//                                         " ,'" + etyTrendLog.Data_PT_Value + "'" +
//                                         " ," + SimpleDatabase.GetInstance().GetParameterDelimiter() + "DateValue)";
//             SqlParameter parameter = new SqlParameter();
//             parameter.ParameterName = "DateValue";
//             parameter.DbType = DbType.DateTime;
//             parameter.Value = etyTrendLog.Data_PT_Time;
//             parameter.Direction = System.Data.ParameterDirection.Input;
//             List<SqlParameter> parameters = new List<SqlParameter>();
//             parameters.Add(parameter);
//             result = SimpleDatabase.GetInstance().ExecuteNonQueryWithParams(localSQL, parameters);
//
//             LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
//             return result;
//         }

        /// <summary>
        /// get dp log list for a historical dp to plot
        /// </summary>
        /// <param name="histDP">the given historical dp for charting</param>
        /// <param name="startTime">start time</param>
        /// <param name="endTime">end time</param>
        /// <returns>trend log list</returns>
        public List <EtyDataLogDPLogTrend> GetHistDPLogList(EtyHistDataPoint histDP, DateTime startTime, DateTime endTime)
        {
            string Function_Name            = "GetHistDPLogList";
            List <EtyDataLogDPLogTrend> res = new List <EtyDataLogDPLogTrend>();
            string localSQL;

            //changed by luxiangmei, to make the logic for historical mode the same as mixed mode.
            //                 if (usedInMixMode)  //used in mixed mode
            //                 {
            localSQL = " SELECT CREATETIME,VALUE " +
                       " FROM DATALOG_DP_LOG_TREND WHERE ENTITY_KEY = " + histDP.EntityKey +
                       " AND CREATETIME >= @StartDateValue" +
                       " AND CREATETIME <= @EndDateValue" +
                       " ORDER BY CREATETIME";


            SqlParameter parameter1 = new SqlParameter();

            parameter1.ParameterName = "StartDateValue";
            parameter1.DbType        = DbType.DateTime;
            DateTime dtStart = new DateTime(histDP.DPStartDateTime.Year, histDP.DPStartDateTime.Month, histDP.DPStartDateTime.Day,
                                            startTime.Hour, startTime.Minute, startTime.Second);

            parameter1.Value     = dtStart;
            parameter1.Direction = System.Data.ParameterDirection.Input;
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(parameter1);


            SqlParameter parameter2 = new SqlParameter();

            parameter2.ParameterName = "EndDateValue";
            parameter2.DbType        = DbType.DateTime;
            DateTime dtEnd = new DateTime(histDP.DPEndDateTime.Year, histDP.DPEndDateTime.Month, histDP.DPEndDateTime.Day,
                                          endTime.Hour, endTime.Minute, endTime.Second);

            parameter2.Value     = dtEnd;
            parameter2.Direction = System.Data.ParameterDirection.Input;
            parameters.Add(parameter2);

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQueryWithParams(localSQL, parameters);
            try
            {
                while (drReader != null && drReader.Read())
                {
                    EtyDataLogDPLogTrend entity = new EtyDataLogDPLogTrend();

                    if (!drReader.IsDBNull(drReader.GetOrdinal("CREATETIME")))
                    {
                        DateTime dt;
                        if (DateTime.TryParse(drReader["CREATETIME"].ToString(), out dt))
                        {
                            entity.CreateTime = dt;
                        }
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("VALUE")))
                    {
                        entity.Value = Convert.ToDouble(drReader["VALUE"]);
                    }

                    res.Add(entity);
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
            }

            if (drReader != null)
            {
                drReader.Close();
                drReader.Dispose();
                //SimpleDatabase.GetInstance().CloseCurrentSession();
            }

            return(res);
        }
 public void UpdateHistDPNameAndLabel(EtyHistDataPoint dp)
 {
     dataPointBox.Text  = dp.DPName.ToString();
     dataLegendBox.Text = dp.DPLblName;
 }
Example #30
0
        public List <EtyDataLogDPLogTrend> GetHistDPLogList(EtyHistDataPoint histDP, DateTime startTime, DateTime endTime)
        {
            DataLogDPLogTrendDAO dao = new DataLogDPLogTrendDAO();

            return(dao.GetHistDPLogList(histDP, startTime, endTime));
        }