コード例 #1
0
ファイル: OSIPI.cs プロジェクト: kristinjm/VICEproject
        //<<<<<<<<<<Add data entry given a tag name >>>>>>>>>>
        public void setPiPointValue(string tagName, object value)
        {
            PISDK.PIValue piValue = new PISDK.PIValue();            // Create new instance of PIValue
            piValue.Value = value;                                  // Set the Pi Value

            PITimeServer.PITime piTime = new PITimeServer.PITime(); // Create new instance of PITime
            piValue.TimeStamp = piTime;                             //Set the datetime

            //Add entry to server
            piServer.PIPoints[tagName].Data.UpdateValue(piValue, "*", PISDK.DataMergeConstants.dmInsertDuplicates, null);
        }
コード例 #2
0
        List <Pi> getPiData(string tagName, DateTime StartDate, DateTime EndDate, out string unit)
        {
            PISDK.PISDK sdk           = new PISDK.PISDK();
            string      piServer      = string.IsNullOrEmpty(ConfigurationSettings.AppSettings["PIServer"]) ? "mus-as-126.corp.pdo.om" : ConfigurationSettings.AppSettings["PIServer"];
            string      piCredentials = string.IsNullOrEmpty(ConfigurationSettings.AppSettings["PICredentials"]) ? "UID=upoa;PWD=upoa" : ConfigurationSettings.AppSettings["PICredentials"];
            Server      srv           = sdk.Servers[piServer];

            srv.Open(piCredentials);
            string nameConcat = "";
            int    i          = 0;

            PISDK.PIPoints myPoints = srv.PIPoints;
            PointList      list     = srv.GetPoints("tag = '*" + tagName + "*'");
            int            count    = list.Count;
            PIData         data     = list[1].Data;

            unit = list[1].PointAttributes["EngUnits"].Value.ToString();
            PIValues        values;
            List <string>   stringValues = new List <string>();
            List <DateTime> timeValues   = new List <DateTime>();
            List <Pi>       piData       = new List <Pi>();

            try
            {
                values = data.RecordedValues(StartDate, EndDate);
                foreach (PIValue value in values)
                {
                    try
                    {
                        if (value.Value.GetType().IsCOMObject)
                        {
                            stringValues.Add((value.Value as DigitalState).Name.ToString());
                            PITimeServer.PITime pt = value.TimeStamp;
                        }
                        else
                        {
                            stringValues.Add((value.Value).ToString());
                            Pi p = new Pi();
                            p.time  = value.TimeStamp.LocalDate;
                            p.value = Convert.ToString(value.Value);
                            p.tag   = tagName;
                            piData.Add(p);
                        }
                    }
                    catch (Exception ex)
                    { //throw ex;
                    }
                }
            }
            catch (Exception ex)
            { }
            return(piData);
        }
コード例 #3
0
ファイル: OSIPI.cs プロジェクト: kristinjm/VICEproject
        ////////////////add data entry given a tag name////////////////////////////

        public void setPiPointValue(string tagName, object value)
        {
            PISDK.PIValue PiValue = new PISDK.PIValue(); // Create new instance of PI value
            PiValue.Value = value; // set the Pi Value

            PITimeServer.PITime piTime = new PITimeServer.PITime(); // create new instance of PITime
            PiValue.TimeStamp = piTime;  // set datetime


            //////////////////// add entry to server//////////////////////////
            PI_Server.PIPoints[tagName].Data.UpdateValue(PiValue, "*", PISDK.DataMergeConstants.dmInsertDuplicates, null);


        }
コード例 #4
0
        List <Pi> getPiData(string tagName, DateTime StartDate, DateTime EndDate)
        {
            ////DateTime startTime = DateTime.Now.AddSeconds(-1);
            ////DateTime endTime = DateTime.Now;
            ////TimeSpan span = new TimeSpan(0, 5, 0);
            PISDK.PISDK sdk = new PISDK.PISDK();
            //PISDK.Server srv = sdk.Servers["mus-as-126.corp.pdo.om"];
            //srv.Open("UID=upoa;PWD=upoa");
            string piServer      = string.IsNullOrEmpty(ConfigurationSettings.AppSettings["PIServer"]) ? "mus-as-126.corp.pdo.om" : ConfigurationSettings.AppSettings["PIServer"];
            string piCredentials = string.IsNullOrEmpty(ConfigurationSettings.AppSettings["PICredentials"]) ? "UID=upoa;PWD=upoa" : ConfigurationSettings.AppSettings["PICredentials"];
            Server srv           = sdk.Servers[piServer];

            srv.Open(piCredentials);
            string nameConcat = "";
            int    i          = 0;

            PISDK.PIPoints  myPoints = srv.PIPoints;
            PointList       list     = srv.GetPoints("tag = '*" + tagName + "*'");
            int             count    = list.Count;
            PIData          data     = list[1].Data;
            PIValues        values;
            List <string>   stringValues = new List <string>();
            List <DateTime> timeValues   = new List <DateTime>();
            List <Pi>       piData       = new List <Pi>();

            try
            {
                ////DateTime DateTimeStart = new DateTime();
                ////DateTimeStart = Convert.ToDateTime(StartDate);
                ////DateTime DateTimeEnd = new DateTime();
                ////DateTimeEnd = Convert.ToDateTime(EndDate);
                ////if (!string.IsNullOrEmpty(Request.Form["txtStartDate"]))
                ////{
                ////    TimeSpan timeSpan = new TimeSpan(int.Parse(ddlHoursStart.SelectedValue), int.Parse(ddlMinutesStart.SelectedValue), 0);
                ////    DateTimeStart.Add(timeSpan);
                ////    DateTimeEnd.AddHours(int.Parse(ddlHoursEnd.SelectedValue));
                ////    DateTimeEnd.AddMinutes(int.Parse(ddlMinutesEnd.SelectedValue));
                ////}
                values = data.RecordedValues(StartDate, EndDate);
                foreach (PIValue value in values)
                {
                    try
                    {
                        if (value.Value.GetType().IsCOMObject)
                        {
                            stringValues.Add((value.Value as DigitalState).Name.ToString());
                            PITimeServer.PITime pt = value.TimeStamp;
                        }
                        else
                        {
                            stringValues.Add((value.Value).ToString());
                            Pi p = new Pi();
                            p.time  = value.TimeStamp.LocalDate;
                            p.value = Convert.ToString(value.Value);
                            p.tag   = tagName;
                            piData.Add(p);
                        }
                    }
                    catch (Exception ex)
                    { //throw ex;
                    }
                }
            }
            catch (Exception ex)
            { }
            return(piData);
        }