Esempio n. 1
0
 private void SetParameterString(string paramName, string val)
 {
     if (_iSensor == 0)
     {
         return;
     }
     lock (_lockCommands)
     {
         MEDAQLibDLL.ERR_CODE iRet = MEDAQLibDLL.ERR_CODE.ERR_NOERROR;
         iRet = MEDAQLibDLL.SetParameterString(_iSensor, paramName, val);
         if (iRet != MEDAQLibDLL.ERR_CODE.ERR_NOERROR)
         {
             throw new MCoreExceptionPopup("Error with SetParameterString('{0}', '{1}') : '{2}'", paramName, val, GetError());
         }
     }
 }
Esempio n. 2
0
        private MEDAQLibDLL.ERR_CODE Open()
        {
            if (_iSensor == 0)
            {
                return(MEDAQLibDLL.ERR_CODE.ERR_CANNOT_OPEN);
            }
            MEDAQLibDLL.ERR_CODE iRet = MEDAQLibDLL.ERR_CODE.ERR_NOERROR;
            iRet = MEDAQLibDLL.ClearAllParameters(_iSensor);
            if (iRet != MEDAQLibDLL.ERR_CODE.ERR_NOERROR)
            {
                throw new Exception("MEDAQLibDLL.ClearAllParameters");
            }

            SetParameterString("IP_Interface", "RS232");
            SetParameterString("IP_Port", Port.CommPort.ToString());

            //iRet = MEDAQLibDLL.SetParameterInt(_iSensor, "IP_Baudrate", (int)CommSettings.BaudRate);
            //if (iRet != MEDAQLibDLL.ERR_CODE.ERR_NOERROR)
            //{
            //    throw new Exception("SetParameterInt(IP_Baudrate)");
            //}

            //iRet = MEDAQLibDLL.SetParameterInt(_iSensor, "IP_Stopbits", (int)CommSettings.StopBits);
            //if (iRet != MEDAQLibDLL.ERR_CODE.ERR_NOERROR)
            //{
            //    throw new Exception("SetParameterInt(IP_Stopbits)");
            //}

            //iRet = MEDAQLibDLL.SetParameterInt(_iSensor, "IP_Parity", (int)CommSettings.Parity);
            //if (iRet != MEDAQLibDLL.ERR_CODE.ERR_NOERROR)
            //{
            //    throw new Exception("SetParameterInt(IP_Parity)");
            //}

            //iRet = MEDAQLibDLL.SetParameterInt(_iSensor, "IP_ByteSize", (int)CommSettings.DataLength);
            //if (iRet != MEDAQLibDLL.ERR_CODE.ERR_NOERROR)
            //{
            //    throw new Exception("SetParameterInt(IP_ByteSize)");
            //}

            iRet = MEDAQLibDLL.OpenSensor(_iSensor);
            if (iRet != MEDAQLibDLL.ERR_CODE.ERR_NOERROR)
            {
                throw new Exception(string.Format("OpenSensor {0}", Port.ToString()));
            }
            return(MEDAQLibDLL.ERR_CODE.ERR_NOERROR);
        }
Esempio n. 3
0
 private void SensorCommand(string cmd)
 {
     if (_iSensor == 0)
     {
         return;
     }
     SetParameterString("S_Command", cmd);
     lock (_lockCommands)
     {
         MEDAQLibDLL.ERR_CODE iRet = MEDAQLibDLL.ERR_CODE.ERR_NOERROR;
         iRet = MEDAQLibDLL.SensorCommand(_iSensor);
         if (iRet != MEDAQLibDLL.ERR_CODE.ERR_NOERROR)
         {
             throw new MCoreExceptionPopup("Error with SensorCommand : '{0}'", GetError());
         }
     }
 }
Esempio n. 4
0
        private int GetParameterInt(string paramName)
        {
            if (_iSensor == 0)
            {
                return(0);
            }
            int iVal = 0;

            lock (_lockCommands)
            {
                MEDAQLibDLL.ERR_CODE iRet = MEDAQLibDLL.GetParameterInt(_iSensor, paramName, ref iVal);
                if (iRet != MEDAQLibDLL.ERR_CODE.ERR_NOERROR)
                {
                    throw new MCoreExceptionPopup("Error with GetParameterInt('{0}' : '{1}'", paramName, GetError());
                }
            }
            return(iVal);
        }
Esempio n. 5
0
        private UInt32 GetParameterDWORD(string paramName)
        {
            if (_iSensor == 0)
            {
                return(0);
            }
            UInt32 dword = 0;

            lock (_lockCommands)
            {
                MEDAQLibDLL.ERR_CODE iRet = MEDAQLibDLL.ERR_CODE.ERR_NOERROR;
                iRet = MEDAQLibDLL.GetParameterDWORD(_iSensor, paramName, ref dword);
                if (iRet != MEDAQLibDLL.ERR_CODE.ERR_NOERROR)
                {
                    throw new MCoreExceptionPopup("Error with GetParameterDWORD('{0}' : '{1}'", paramName, GetError());
                }
            }
            return(dword);
        }
Esempio n. 6
0
        private string GetParameterString(string paramName)
        {
            if (_iSensor == 0)
            {
                return(string.Empty);
            }
            string ret = string.Empty;

            lock (_lockCommands)
            {
                UInt32               iMaxLen = 1024;
                StringBuilder        sb      = new StringBuilder((int)iMaxLen);
                MEDAQLibDLL.ERR_CODE iRet    = MEDAQLibDLL.GetParameterString(_iSensor, paramName, sb, ref iMaxLen);
                if (iRet != MEDAQLibDLL.ERR_CODE.ERR_NOERROR)
                {
                    throw new MCoreExceptionPopup("Error with GetParameterString('{0}' : '{1}'", paramName, GetError());
                }
                ret = sb.ToString();
            }
            return(ret);
        }
Esempio n. 7
0
 /// <summary>
 /// Get the current data values
 /// </summary>
 /// <returns></returns>
 public double[] GetData()
 {
     lock (_lockCommands)
     {
         int iAvail = 0;
         int iRead  = 0;
         MEDAQLibDLL.ERR_CODE iRet = MEDAQLibDLL.DataAvail(_iSensor, ref iAvail);
         if (iRet == MEDAQLibDLL.ERR_CODE.ERR_NOERROR)
         {
             // Get no more than 10
             int      iMax        = System.Math.Min(iAvail, 10);
             int[]    iRawData    = new Int32[iMax];
             double[] dScaledData = new double[iMax];
             iRet = MEDAQLibDLL.TransferData(_iSensor, iRawData, dScaledData, iMax, ref iRead);
             if (iRet == MEDAQLibDLL.ERR_CODE.ERR_NOERROR)
             {
                 return(dScaledData);
             }
         }
     }
     return(null);
 }