MATLABfromCSharp.MainControl.getPIData C# (CSharp) Method

getPIData() public method

Get the Data from PIServer using AFSDK.
public getPIData ( string point, string server, string MatlabName, string start, string end, bool edit ) : void
point string The name of the PIPoint.
server string The PIServer
MatlabName string The name of the variable to be used for Matlab.
start string The time to start taking data from.
end string The time to stop taking data from.
edit bool true: Adds the log to the LogSystem (generally true)
return void
        public void getPIData(string point, string server, string MatlabName, string start, string end, bool edit)
        {
            string name = MatlabAccess.modifyMatlabName(MatlabName);
            if (name == string.Empty)
                return;
            try
            {
                AFAccess.getPIData(name, server, point, start, end, edit);
                mainForm.Status("Data sent for " + point);
                return;
            }
            catch { checkMatlab(true); mainForm.Status("ERROR: Data not sent for  " + point); return; }
        }

Usage Example

Example #1
0
        /// <summary>
        ///  Resulting Action of editting the List View.
        ///  1) Edit the List Item
        ///  2) Re-log the item
        ///  3) Edit the Matlab workspace.
        /// </summary>
        /// <param name="name"> The new variable name. (or the same)</param>
        /// <param name="start"> The new start time. (or the same)</param>
        /// <param name="end"> The new end time. (or the same)</param>
        /// <param name="previous"></param>
        public void EditLog(string name, string start, string end, LogInput previous)
        {
            MatlabAccess.removeMatlabVariable(previous.getKeyVariableName());
            if (previous.getKeyVariableName() != name)
            {
                name = MatlabAccess.modifyMatlabName(name);
            }
            if (name == string.Empty)
            {
                name = previous.getKeyVariableName();
            }
            string attName = previous.getAttribute();
            string path    = previous.getPath();
            string elem    = previous.getElement();

            //EDIT LIST VIEW
            if (AFAccess.isAbsoluteTimeString(start, end, previous))
            {
                lv_LogDialog.SelectedItems[0].SubItems[3].Text = start + " = " + end;
                lv_LogDialog.SelectedItems[0].Text             = name;
            }
            else
            {
                AFTimeRange range = new AFTimeRange(start, end);
                lv_LogDialog.SelectedItems[0].SubItems[3].Text = range.ToString();
                lv_LogDialog.SelectedItems[0].Text             = name;
            }


            //EDIT ACTUAL LOG
            LogSystem.removeLogInput(previous.getKeyVariableName(), previous.getServerDatabase());

            //Workspace Edit - remove variable, getNewData
            if (path == "PI.Point")
            {
                string[] info = Regex.Split(previous.getServerDatabase(), "'");
                control.getPIData(attName, info[1], name, start, end, false);
            }
            else
            {
                control.getAFData(previous.getServerDatabase(), attName, name, path, start, end, false);
            }
        }