Esempio n. 1
2
        PISDK.Server PI_Server;  // Creates instance of Pi Server

        //Connection to Pi Server function

        public void connect_Server(string PiServerName)
        {

            PISDK.PISDK SDK = new PISDK.PISDK();  //Creates new instace of PI SDK
            PI_Server = SDK.Servers[PiServerName]; // Assign PI server to local machine
            PI_Server.Open(PI_Server.DefaultUser); // Open connection through default user

        }
Esempio n. 2
2
        protected void Page_Load(object sender, EventArgs e)
        {
            PISDK.PISDK SDK = new PISDK.PISDK();            //Creates new instance of PI SDK
            PI_SERVER = SDK.Servers["esmartserver-pc"];     //Assign PI server to local machine [Piservername]
            PI_SERVER.Open("piadmin");          //Open connection through default user

            //Initialize point data starting at 12:50p
            rpiCONNECT = updatePointValue("SP14VICE_Connection", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            RPM = updatePointValue("SP14VICE_RPM", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            FLOW = updatePointValue("SP14VICE_Flow", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            PRESSURE = updatePointValue("SP14VICE_Pressure", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            POWER = updatePointValue("F13APA_POWER_BOT1", "12/6/2013 4:50:00 PM", DateTime.Now.ToString());
            TEMP = updatePointValue("SP14VICE_Temp", "3/13/2013 1:05:00 PM", DateTime.Now.ToString());
        }
Esempio n. 3
1
        public bool ConnectToPI()
        {
            try {
                if (pSdk == null || !piServer.Connected) {
                    pSdk = new PISDK.PISDK();
                    string piserver_name = ConfigurationManager.AppSettings["PIServer"].ToString();
                    string connectstr = ConfigurationManager.AppSettings["PIConnectionString"].ToString();
                    piServer = pSdk.Servers[piserver_name];

                    if (piServer.Connected) return true;
                    piServer.ConnectTimeout = 120;
                    piServer.Open(connectstr);
                }
            }
            catch (Exception ex) {
                pSdk = null;
                _ErrorInfo = ex.Message;
                return false;
            }
            return true;
        }
Esempio n. 4
1
        protected void Page_Load(object sender, EventArgs e)
        {
            PISDK.PISDK SDK = new PISDK.PISDK();            //Creates new instance of PI SDK
            PI_SERVER = SDK.Servers["esmartserver-pc"];     //Assign PI server to local machine [Piservername]
            PI_SERVER.Open("piadmin");          //Open connection through default user

            //Initialize point data starting at 12:50p
            rpiCONNECT = updatePointValue("SP14VICE_Connection", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            FREQ = updatePointValue("SP14VICE_Freq", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            RPM = updatePointValue("SP14VICE_RPM", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            FLOW = updatePointValue("SP14VICE_Flow", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            DF = updatePointValue("SP14VICE_DesiredFlow", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            PRESSURE = updatePointValue("SP14VICE_Pressure", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            VOLT = updatePointValue("SP14VICE_TopVoltage1", "3/6/2014 1:20:00 PM", DateTime.Now.ToString());
            CURR = updatePointValue("SP14VICE_TopCurrent1", "3/6/2014 1:20:00 PM", DateTime.Now.ToString());
            POWER = updatePointValue("SP14VICE_TopPower1", "3/6/2014 1:20:00 PM", DateTime.Now.ToString());
            TEMP = updatePointValue("SP14VICE_Temp", "3/13/2013 1:05:00 PM", DateTime.Now.ToString());
            USERLOCK = updatePointValue("SP14VICE_Lock", "12/6/2013 4:50:00 PM", DateTime.Now.ToString()); // 1= unlocked, 0 = locked

            COST.value = findCost(120, (float)0.35).ToString(); //Assume: running pump for 4 hrs/day for 30 days; tier 3 pricing during summer ($.35/kWH)
            COST.timestamp = DateTime.Now.ToString();

            setTableValues();
        }
Esempio n. 5
1
 private void gameTimeButton_click(object sender, EventArgs e)
 {
     // Allow the user to set the appropriate properties.
     if (serialPort.IsOpen)
         serialPort.Close();
     serialPort.PortName = comComboBox.SelectedItem.ToString();
     serialPort.BaudRate = 9600;
     serialPort.Open();
     //send the Arduino an 'A' to get it going :)
     serialPort.Write("A");
     if (serialPort.IsOpen)
         Console.WriteLine(serialPort.PortName + " is open");
     serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
     serverName = serverTextBox.Text;
     tagName = tagTextBox.Text;
     piSDK = new PISDK.PISDKClass();
     piServer = piSDK.Servers[serverName];
     if (piServer.Connected)
         Console.WriteLine("Connected to Server");
     piPoint = readPIPoint(piServer, tagName);
 }
Esempio n. 6
1
        protected void Page_Load(object sender, EventArgs e)
        {
            ///// Connect to pi server /////
            PISDK.PISDK SDK = new PISDK.PISDK();            //Creates new instance of PI SDK
            PI_SERVER = SDK.Servers["esmartserver-pc"];     //Assign PI server to local machine [Piservername]
            PI_SERVER.Open("piadmin");          //Open connection through default user

            //Initialize point data starting at 12:50p
            rpiCONNECT = updatePointValue("SP14VICE_Connection", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            RPM = updatePointValue("SP14VICE_RPM", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            FLOW = updatePointValue("SP14VICE_Flow", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            PRESSURE = updatePointValue("SP14VICE_Pressure", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            POWER = updatePointValue("F13APA_POWER_BOT1", "12/6/2013 4:50:00 PM", DateTime.Now.ToString());
            USERLOCK = updatePointValue("SP14VICE_Lock", "12/6/2013 4:50:00 PM", DateTime.Now.ToString()); // 1= unlocked, 0 = locked

            if (USERLOCK.value == "1")
            {
                lockoutdisp.InnerHtml = "OFF - UNLOCKED";
            }
            else if (USERLOCK.value == "0")
            {
                lockoutdisp.InnerHtml = "ON - LOCKED";
            }
        }
Esempio n. 7
1
 //<<<<<<<<<<Connect to PI Server>>>>>>>>>>
 public void connectToServer(string piServerName)
 {
     PISDK.PISDK SDK = new PISDK.PISDK();                    // Create new instance of PI SDK
     piServer = SDK.Servers[piServerName];                   // Assign PI Server to local machine
     piServer.Open(piServer.DefaultUser);                    // Open connection through default user
 }
Esempio n. 8
0
 public MainForm()
 {
     InitializeComponent();
     pisdk = new PISDK.PISDK();
     pisrv = pisdk.Servers.DefaultServer;
     pisrv.Open();
 }
Esempio n. 9
0
        /// <summary>
        /// PiHelper构造函数
        /// </summary>
        /// <param name="hostName">pi服务器名</param>
        /// <param name="uid">登录服务器的用户id</param>
        /// <param name="pwd">登录密码</param>
        /// <param name="piPort">pi服务器端口</param>
        public PiHelper(string hostName, string uid, string pwd, int piPort)
        {
            this.hostName      = hostName;
            this.uid           = uid;
            this.pwd           = pwd;
            this.piPort        = piPort;
            piConnectionString = string.Format("UID={0};PWD={1};port={2};Host={3};", uid, pwd, piPort, hostName);
            try
            {
                pisdk = new PISDK.PISDK();
                foreach (PISDK.Server Iserver in pisdk.Servers)
                {
                    if (Iserver.Name.Equals(hostName))
                    {
                        this.server = Iserver;

                        //初始化PIServer日志 by Nutk'Z 141111
                        //log4net.ILog log = log4net.LogManager.GetLogger(this.GetType());
                        //log.Info("初始化PIServer成功");
                        logs.writelog("初始化PIServer成功");
                    }
                }
            }
            catch (Exception ex)
            {
                log4net.ILog log = log4net.LogManager.GetLogger(this.GetType());
                log.Error(ex);
            }
        }
Esempio n. 10
0
 private void gameTimeButton_click(object sender, EventArgs e)
 {
     // Allow the user to set the appropriate properties.
     if (serialPort.IsOpen)
     {
         serialPort.Close();
     }
     serialPort.PortName = comComboBox.SelectedItem.ToString();
     serialPort.BaudRate = 9600;
     serialPort.Open();
     //send the Arduino an 'A' to get it going :)
     serialPort.Write("A");
     if (serialPort.IsOpen)
     {
         Console.WriteLine(serialPort.PortName + " is open");
     }
     serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
     serverName = serverTextBox.Text;
     tagName    = tagTextBox.Text;
     piSDK      = new PISDK.PISDKClass();
     piServer   = piSDK.Servers[serverName];
     if (piServer.Connected)
     {
         Console.WriteLine("Connected to Server");
     }
     piPoint = readPIPoint(piServer, tagName);
 }
Esempio n. 11
0
 //数据库连接与断开
 //——由于初始化时,可以选择带字符串的初始化,或者不带字符串的初始化,因此Logon时,就不再提供两种情况
 //——即,在初始化时,可以选择用连接字符串取初始化不同连接。
 //——但是,连接时,应当认为,在初始化的时候,已经选好了连接目标
 #region public String Logon() 获取数据库连接:不带连接字符串的连接函数
 public String Logon()
 {
     try
     {
         //_piServer==null,是第一次建立logon的时候
         //_piServer==null==false
         if (this._piServer == null || this._piServer.Connected == false)
         {
             this._piServer      = this._piSDK.Servers.DefaultServer; //服务器对象
             this._piServer.Path = this._server;                      //ip地址
             this._piServer.Port = int.Parse(this._port);             //端口
             this._piServer.Open(_connectionString);                  //用户名称,密码
         }
         if (this._piServer.Connected)
         {
             //this._isLogon = true; 不再使用_isLogon内部变量,而直接使用公用变量isLogOn的get获得_piServer.Connected的当前值
             return("logon");
         }
         else
         {
             //this._isLogon = true; 不再在使用_isLogon内部变量,而直接使用公用变量isLogOn的get获得_piServer.Connected的当前值
             return("logoff");
         }
     }
     catch (Exception ex)
     {
         _exception = ex.ToString();
         throw new Exception(ex.ToString());     //将pi的异常继续向外传递。
     }
 }
Esempio n. 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PISDK.PISDK SDK = new PISDK.PISDK();        //Creates new instance of PI SDK
            PI_SERVER = SDK.Servers["esmartserver-pc"]; //Assign PI server to local machine [Piservername]
            PI_SERVER.Open("piadmin");                  //Open connection through default user

            //Initialize point data starting at 12:50p
            rpiCONNECT = updatePointValue("SP14VICE_Connection", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            RPM        = updatePointValue("SP14VICE_RPM", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            FLOW       = updatePointValue("SP14VICE_Flow", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            PRESSURE   = updatePointValue("SP14VICE_Pressure", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
        }
Esempio n. 13
0
        public String Logon(string connectionString)
        {
            string[] _connArray = connectionString.Split(';');

            this._server   = _connArray.Length >= 1 ? _connArray[0].Substring(_connArray[0].IndexOf('=') + 1) : this._server;
            this._port     = _connArray.Length >= 2 ? _connArray[1].Substring(_connArray[1].IndexOf('=') + 1) : this._port;
            this._userId   = _connArray.Length >= 3 ? _connArray[2].Substring(_connArray[2].IndexOf('=') + 1) : this._userId;
            this._password = _connArray.Length >= 4 ? _connArray[3].Substring(_connArray[3].IndexOf('=') + 1) : this._password;
            //外部的Connectstring保持xml格式统一
            //内部的_connectionString按照各数据库要求走,比如PGIM、golden、Pi各不相同
            this._connectionString = string.Format("UID={0};PWD={1};", this._userId, this._password);
            try
            {
                //_piServer==null,是第一次建立logon的时候
                //_piServer==null==false
                if (this._piServer == null || this._piServer.Connected == false)
                {
                    this._piServer      = this._piSDK.Servers.DefaultServer; //服务器对象
                    this._piServer.Path = this._server;                      //ip地址
                    this._piServer.Port = int.Parse(this._port);             //端口
                    this._piServer.Open(_connectionString);                  //用户名称,密码
                }
                if (this._piServer.Connected)
                {
                    //this._isLogon = true; 不再使用_isLogon内部变量,而直接使用公用变量isLogOn的get获得_piServer.Connected的当前值
                    return("logon");
                }
                else
                {
                    //this._isLogon = true; 不再在使用_isLogon内部变量,而直接使用公用变量isLogOn的get获得_piServer.Connected的当前值
                    return("logoff");
                }
            }
            catch (Exception ex)
            {
                _exception = ex.ToString();
                throw new Exception(ex.ToString());     //将pi的异常继续向外传递。
            }
        }
Esempio n. 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ///// Connect to pi server /////
            PISDK.PISDK SDK = new PISDK.PISDK();        //Creates new instance of PI SDK
            PI_SERVER = SDK.Servers["esmartserver-pc"]; //Assign PI server to local machine [Piservername]
            PI_SERVER.Open("piadmin");                  //Open connection through default user

            //Initialize point data starting at 12:50p
            rpiCONNECT = updatePointValue("SP14VICE_Connection", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            RPM        = updatePointValue("SP14VICE_RPM", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            FLOW       = updatePointValue("SP14VICE_Flow", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            PRESSURE   = updatePointValue("SP14VICE_Pressure", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            POWER      = updatePointValue("F13APA_POWER_BOT1", "12/6/2013 4:50:00 PM", DateTime.Now.ToString());
            USERLOCK   = updatePointValue("SP14VICE_Lock", "12/6/2013 4:50:00 PM", DateTime.Now.ToString()); // 1= unlocked, 0 = locked

            if (USERLOCK.value == "1")
            {
                lockoutdisp.InnerHtml = "OFF - UNLOCKED";
            }
            else if (USERLOCK.value == "0")
            {
                lockoutdisp.InnerHtml = "ON - LOCKED";
            }
        }
Esempio n. 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PISDK.PISDK SDK = new PISDK.PISDK();        //Creates new instance of PI SDK
            PI_SERVER = SDK.Servers["esmartserver-pc"]; //Assign PI server to local machine [Piservername]
            PI_SERVER.Open("piadmin");                  //Open connection through default user

            //Initialize point data starting at 12:50p
            rpiCONNECT = updatePointValue("SP14VICE_Connection", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            FREQ       = updatePointValue("SP14VICE_Freq", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            RPM        = updatePointValue("SP14VICE_RPM", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            FLOW       = updatePointValue("SP14VICE_Flow", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            DF         = updatePointValue("SP14VICE_DesiredFlow", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            PRESSURE   = updatePointValue("SP14VICE_Pressure", "2/27/2014 12:50:00 PM", DateTime.Now.ToString());
            VOLT       = updatePointValue("SP14VICE_TopVoltage1", "3/6/2014 1:20:00 PM", DateTime.Now.ToString());
            CURR       = updatePointValue("SP14VICE_TopCurrent1", "3/6/2014 1:20:00 PM", DateTime.Now.ToString());
            POWER      = updatePointValue("SP14VICE_TopPower1", "3/6/2014 1:20:00 PM", DateTime.Now.ToString());
            TEMP       = updatePointValue("SP14VICE_Temp", "3/13/2013 1:05:00 PM", DateTime.Now.ToString());
            USERLOCK   = updatePointValue("SP14VICE_Lock", "12/6/2013 4:50:00 PM", DateTime.Now.ToString()); // 1= unlocked, 0 = locked

            COST.value     = findCost(120, (float)0.35).ToString();                                          //Assume: running pump for 4 hrs/day for 30 days; tier 3 pricing during summer ($.35/kWH)
            COST.timestamp = DateTime.Now.ToString();

            setTableValues();
        }
Esempio n. 16
0
 private PIPoint readPIPoint(PISDK.Server piServer, string tagName)
 {
     return(piSDK.GetPoint("\\\\" + piServer.Path.ToString() + "\\" + tagName));
 }
Esempio n. 17
0
        PISDK.Server PI_Server;  // Creates instance of Pi Server

        //Connection to Pi Server function

        public void connect_Server(string PiServerName)
        {
            PISDK.PISDK SDK = new PISDK.PISDK();   //Creates new instace of PI SDK
            PI_Server = SDK.Servers[PiServerName]; // Assign PI server to local machine
            PI_Server.Open(PI_Server.DefaultUser); // Open connection through default user
        }
Esempio n. 18
0
        PISDK.Server piServer;                                      //Create instance of PI Server

        //<<<<<<<<<<Connect to PI Server>>>>>>>>>>
        public void connectToServer(string piServerName)
        {
            PISDK.PISDK SDK = new PISDK.PISDK();                    // Create new instance of PI SDK
            piServer = SDK.Servers[piServerName];                   // Assign PI Server to local machine
            piServer.Open(piServer.DefaultUser);                    // Open connection through default user
        }