Exemplo n.º 1
0
    //设备初始化连接
    public ziDotNET connect(ziDotNET daq, String dev)
    {
        String id    = daq.discoveryFind(dev);
        String iface = daq.discoveryGetValueS(dev, "connected");

        if (string.IsNullOrWhiteSpace(iface))
        {
            // Device is not connected to the server
            String ifacesList = daq.discoveryGetValueS(dev, "interfaces");
            // Select the first available interface and use it to connect
            string[] ifaces = ifacesList.Split('\n');
            if (ifaces.Length > 0)
            {
                iface = ifaces[0];
            }
        }
        String host = daq.discoveryGetValueS(dev, "serveraddress");
        long   port = daq.discoveryGetValueI(dev, "serverport");
        long   api  = daq.discoveryGetValueI(dev, "apilevel");

        //该函数会自动抛出异常
        daq.init(host, Convert.ToUInt16(port), (ZIAPIVersion_enum)api);
        // Ensure that LabOne API and LabOne Data Server are from
        // the same release version.
        apiServerVersionCheck(daq);
        // If device is not yet connected a reconnect
        // will not harm.
        daq.connectDevice(dev, iface, "");


        return(daq);
    }
Exemplo n.º 2
0
    //检查serverapi版本
    public void apiServerVersionCheck(ziDotNET daq)
    {
        String serverVersion = daq.getByte("/zi/about/version");
        String apiVersion    = daq.version();

        //Assert.AreEqual(serverVersion, apiVersion,
        // "Version mismatch between LabOne API and Data Server.");
        //Console.WriteLine("Current   Firmware   Version  is:    " + apiVersion);
    }
Exemplo n.º 3
0
    //开启数据传输 设置传输速率
    public bool  setMFLIenableAndrate(ziDotNET daq, String dev)
    {
        //开始采集前必须确保数据传输开启
        daq.syncSetInt(DemodsEnablepath, 1);
        //数据传输速率
        daq.syncSetInt(DemodsEnablepath, 857100); // 最大857100

        return(true);
    }
Exemplo n.º 4
0
 // The resetDeviceToDefault will reset the device settings
 // to factory default. The call is quite expensive
 // in runtime. Never use it inside loops!
 public bool  resetDeviceToDefault(ziDotNET daq)
 {
     daq.setInt(String.Format("/{0}/system/preset/index", dev), 0);
     daq.setInt(String.Format("/{0}/system/preset/load", dev), 1);
     while (daq.getInt(String.Format("/{0}/system/preset/busy", dev)) != 0)
     {
         System.Threading.Thread.Sleep(100);
     }
     System.Threading.Thread.Sleep(1000);
     return(true);
 }
Exemplo n.º 5
0
 //内部晶振频率设置
 public bool SetSignalOscillators(ziDotNET daq, String dev, double theOscillatorsFrequency = 100000.000)
 {
     //开始设置参数
     try
     {
         daq.syncSetDouble(SignalOscillatorsPath, theOscillatorsFrequency); ////默认 100kHz
     }
     catch (ZIException e)
     {
         System.Diagnostics.Trace.WriteLine(e.ToString(), "Warning");
     }
     return(true);//设置成功标志
 }
Exemplo n.º 6
0
 //初始化连接和设置
 public String InitTheDevice(ziDotNET daq, String dev)
 {
     if (isNetWorkDeviceContainStringExsit())
     {
         //通过查看是否存在 Zurich Instruments  RNDIS 网卡判断是否存在 MFLI 设备
         daq = connect(daq, dev);//初始化
         //SetSignalOutputSetting(daq, dev);//设置输出信号
         //SetSignalInputSetting(daq, dev);//设置信号输入各参数
         //SetSignalOscillators(daq, dev);//设置频率
         //返回当前版本表示连接成功
         return(daq.version());
     }
     return(null);//返回null表示设备不存在
 }
Exemplo n.º 7
0
 //设置输出
 public bool SetSignalInputSetting(ziDotNET daq, String dev, double SignalInputManualRangeValue = 0.30000, long isSignalInputAutoRange = 0, double SignalInputScalingValue = 1.000, long isSignalInputACCoupling = 1, long isSignalInput50Ohm = 1, long isSignalInputFloatGround = 1)
 {
     //开始设置输入参数
     try
     {
         if ((int)isSignalInputAutoRange != 0)                                           //如果自动量程开启则不用设置手动量程
         {
             daq.syncSetDouble(SignalInputManualRangePath, SignalInputManualRangeValue); //默认300mV ,若设置的量程低于实际输入值,系统会自动选择一个合适的量程
         }
         daq.syncSetInt(SignalInputAutoRangePath, isSignalInputAutoRange);               //默认关闭
         daq.syncSetDouble(SignalInputScalingPath, SignalInputScalingValue);             //缩放因子,默认不缩放 1.000
         daq.syncSetInt(SignalInputACCouplingPath, isSignalInputACCoupling);             //默认 使用AC耦合
         daq.syncSetInt(SignalInputSwitchBetween50And10MegaOhmPath, isSignalInput50Ohm); //默认使用50欧姆
         daq.syncSetInt(SignalInputFloatPath, isSignalInputFloatGround);                 //默认悬浮地
     }
     catch (ZIException e)
     {
         System.Diagnostics.Trace.WriteLine(e.ToString(), "Warning");
     }
     return(true);//设置成功标志
 }
Exemplo n.º 8
0
 //设置输入
 public bool SetSignalOutputSetting(ziDotNET daq, String dev, long isSignalOutputSwitchOn = 1, long isSignalOutputImpendence50 = 1, double SignalOutputManualRangeValue = 0.500000, long isSignalOutputAutoRange = 0, double SignalOutputOffsetValue = 0, long isSignalOutputAmplitudesEnable = 1, double SignalOutputAmplitudesValue = 0.212132034)
 {
     //开始设置输出参数
     try
     {
         daq.syncSetInt(SignalOutputSwitchOnPath, isSignalOutputSwitchOn);                 //默认 开启 1
         daq.syncSetInt(SignalOutputImpendence50Path, isSignalOutputImpendence50);         //默认开启 1
         if ((int)isSignalOutputAutoRange != 0)                                            //如果自动量程开启则不用设置手动量程
         {
             daq.syncSetDouble(SignalOutputManualRangePath, SignalOutputManualRangeValue); // 量程 默认500mV (0.500000)
         }
         daq.syncSetInt(SignalOutputAutoRangePath, isSignalOutputAutoRange);               //默认关闭 0
         daq.syncSetDouble(SignalOutputOffsetPath, SignalOutputOffsetValue);               //默认 0
         daq.syncSetInt(SignalOutputAmplitudesEnablePath, isSignalOutputAmplitudesEnable); //默认开启
         daq.syncSetDouble(SignalOutputAmplitudesValuePath, SignalOutputAmplitudesValue);  //默认150mV Vrms 0.212132034
     }
     catch (ZIException e)
     {
         System.Diagnostics.Trace.WriteLine(e.ToString(), "Warning");
     }
     return(true);//设置成功标志
 }
Exemplo n.º 9
0
    //获取采样数据
    public ZIDemodSample GetDemodSample(ziDotNET daq, String dev)
    {
        ZIDemodSample sample = daq.getDemodSample(DemodSamplePath);

        return(sample);
    }