Ejemplo n.º 1
0
    /// @brief Internal method to update the node information stored in @ref m_nodeInformation
    protected void UpdateNodeInformation()
    {
        if (!Valid)
        {
            return;
        }
        NodeInfoList nodeList = m_context.BasicContext.EnumerateExistingNodes();

        foreach (NodeInfo nodeInfo in nodeList)
        {
            ProductionNodeDescription desc = nodeInfo.Description;
            bool foundPlace = false;
            for (int i = 0; i < m_nodeInformation.Count; i++)
            {
                if (m_nodeInformation[i].Type == desc.Type)
                {
                    m_nodeInformation[i] = desc;
                    foundPlace           = true;
                    break;
                }
            }
            if (!foundPlace)
            {
                m_nodeInformation.Add(desc);
            }
        }
        nodeList.Dispose();
    }
Ejemplo n.º 2
0
        void Refresh()
        {
            try
            {
                FLicense.Vendor = "PrimeSense";
                FLicense.Key    = "0KOIk2JeIBYClPWVnMoRKn5cdY4";
                FContext.AddLicense(FLicense);

                NodeInfoList list = FContext.EnumerateProductionTrees(global::OpenNI.NodeType.Device, null);
                FNodeList.Clear();
                foreach (var node in list)
                {
                    FNodeList.Add(node);
                }

                FPinOutName.SliceCount         = FNodeList.Count;
                FPinOutVendor.SliceCount       = FNodeList.Count;
                FPinOutVersion.SliceCount      = FNodeList.Count;
                FPinOutCreationInfo.SliceCount = FNodeList.Count;
                for (int i = 0; i < FNodeList.Count; i++)
                {
                    var node = FNodeList[i];
                    FPinOutName[i]         = node.Description.Name;
                    FPinOutVendor[i]       = node.Description.Vendor;
                    FPinOutVersion[i]      = (double)node.Description.Version.Major + ((double)FNodeList[i].Description.Version.Minor / 1000.0);
                    FPinOutCreationInfo[i] = node.CreationInfo;
                }

                FPinOutStatus[0] = "OK";
            }
            catch (Exception e)
            {
                FPinOutStatus[0] = e.Message;
            }
        }
        /// <summary>
        /// 获取数据点分页数据
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        private void getNodePageData(int pageIndex, int pageSize, bool isSearch, string searchInfo)
        {
#if DEBUG
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();
#endif
            pageRepuestParams = new PageRepuestParams();
            if (isSearch)
            {
                FilterGroup filterGroup      = new FilterGroup(FilterOperate.Or);
                FilterRule  filterRuleName   = new FilterRule("NodeName", searchInfo, FilterOperate.Contains);
                FilterRule  filterRuleServer = new FilterRule("DeviceServerInfo.DeviceServerName", searchInfo, FilterOperate.Contains);
                FilterRule  filterRuleUrl    = new FilterRule("NodeUrl", searchInfo, FilterOperate.Contains);
                filterGroup.Rules.Add(filterRuleName);
                filterGroup.Rules.Add(filterRuleServer);
                filterGroup.Rules.Add(filterRuleUrl);
                pageRepuestParams.FilterGroup = filterGroup;
            }
            pageRepuestParams.SortField = GlobalData.SortField;
            pageRepuestParams.SortOrder = GlobalData.SortOrder;
            pageRepuestParams.PageIndex = pageIndex;
            pageRepuestParams.PageSize  = pageSize;
            var result = Utility.Http.HttpClientHelper.PostResponse <OperationResult <PageResult <DeviceNodeModel> > >(GlobalData.ServerRootUri + "DeviceNode/PageData", Utility.JsonHelper.ToJson(pageRepuestParams));

#if DEBUG
            stopwatch.Stop();
            Utility.LogHelper.Info("获取数据点列表用时(毫秒):" + stopwatch.ElapsedMilliseconds);
            Utility.LogHelper.Info("数据点列表内容:" + Utility.JsonHelper.ToJson(result));
#endif

            if (!Equals(result, null) && result.Successed)
            {
                Application.Current.Resources["UiMessage"] = result?.Message;
                LogHelper.Info(Application.Current.Resources["UiMessage"].ToString());
                if (result.Data.Data.Any())
                {
                    NodeInfoList?.Clear();
                    foreach (var data in result.Data.Data)
                    {
                        DeviceNodeModel commOpcUaNode = new DeviceNodeModel();
                        commOpcUaNode = data;
                        commOpcUaNode.PropertyChanged += OnPropertyChangedCommand;
                        NodeInfoList.Add(commOpcUaNode);
                    }
                    //TotalCounts = result.Data.Total;
                }
                else
                {
                    NodeInfoList?.Clear();
                    Application.Current.Resources["UiMessage"] = "未找到数据";
                }
            }
            else
            {
                //操作失败,显示错误信息
                NodeInfoList = new ObservableCollection <DeviceNodeModel>();
                Application.Current.Resources["UiMessage"] = result?.Message ?? "查询数据点列表失败,请联系管理员!";
            }
        }
Ejemplo n.º 4
0
        void Open(int i)
        {
            try
            {
                Close(i);


                Device state   = FState[i];
                var    context = new Context();
                FState[i].Context = context;
                context.AddLicense(FLicense);
                context.GlobalMirror = false;

                NodeInfoList list = context.EnumerateProductionTrees(global::OpenNI.NodeType.Device, null);
                NodeInfo     node = null;
                if (FPinInNodes[i] != "")
                {
                    foreach (NodeInfo nodeitem in list)
                    {
                        if (nodeitem.CreationInfo == FPinInNodes[i])
                        {
                            node = nodeitem;
                            break;
                        }
                    }

                    if (node == null)
                    {
                        throw (new Exception("This device is unavailable. Check upstream ListDevices node"));
                    }

                    context.CreateProductionTree(node);
                }

                state.DepthGenerator = new DepthGenerator(context);
                MapOutputMode depthMode = new MapOutputMode();
                depthMode.FPS  = 30;
                depthMode.XRes = 640;
                depthMode.YRes = 480;

                state.DepthGenerator.MapOutputMode = depthMode;
                state.DepthGenerator.StartGenerating();

                state.Start();

                FPinOutContext[i] = state;
                FPinOutStatus[i]  = "OK";
            }
            catch (Exception e)
            {
                Close(i);
                FPinOutStatus[i] = e.Message;
            }
        }
        /// <summary>
        /// 获取数据点分页数据
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        private void getNodePageData(int pageIndex, int pageSize)
        {
#if DEBUG
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();
#endif
            pageRepuestParams.SortField = GlobalData.SortField;
            pageRepuestParams.SortOrder = GlobalData.SortOrder;
            pageRepuestParams.PageIndex = pageIndex;
            pageRepuestParams.PageSize  = pageSize;
            var result = Utility.Http.HttpClientHelper.PostResponse <OperationResult <PageResult <CommOpcUaNodeModel> > >(GlobalData.ServerRootUri + "CommOpcUaNode/PageData", Utility.JsonHelper.ToJson(pageRepuestParams));

#if DEBUG
            stopwatch.Stop();
            Utility.LogHelper.Info("获取数据点列表用时(毫秒):" + stopwatch.ElapsedMilliseconds);
            Utility.LogHelper.Info("数据点列表内容:" + Utility.JsonHelper.ToJson(result));
#endif

            if (!Equals(result, null) && result.Successed)
            {
                Application.Current.Resources["UiMessage"] = result?.Message;
                LogHelper.Info(Application.Current.Resources["UiMessage"].ToString());
                if (result.Data.Data.Any())
                {
                    NodeInfoList?.Clear();
                    foreach (var data in result.Data.Data)
                    {
                        CommOpcUaNodeModel commOpcUaNode = new CommOpcUaNodeModel();
                        commOpcUaNode = data;
                        commOpcUaNode.PropertyChanged += OnPropertyChangedCommand;
                        NodeInfoList.Add(commOpcUaNode);
                    }
                    //TotalCounts = result.Data.Total;
                }
                else
                {
                    NodeInfoList?.Clear();
                    Application.Current.Resources["UiMessage"] = "未找到数据";
                }
            }
            else
            {
                //操作失败,显示错误信息
                NodeInfoList = new ObservableCollection <CommOpcUaNodeModel>();
                Application.Current.Resources["UiMessage"] = result?.Message ?? "查询数据点列表失败,请联系管理员!";
            }
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            try {
                // 設定ファイルのパス(環境に合わせて変更してください)
                string CONFIG_XML_PATH = @"../../../../../Data/SamplesConfig.xml";

                // XMLをファイルから設定情報を取得して初期化する
                Console.Write(@"Context.InitFromXmlFile ... ");
                ScriptNode     scriptNode;
                OpenNI.Context context = OpenNI.Context.CreateFromXmlFile(CONFIG_XML_PATH, out scriptNode);
                Console.WriteLine(@"Success");

                // ライセンス情報を取得する
                Console.Write(@"Context.EnumerateLicenses ... ");
                License[] licenses = context.EnumerateLicenses();
                Console.WriteLine(@"Success");

                foreach (License license in licenses)
                {
                    Console.WriteLine(license.Vendor + @", " + license.Key);
                }

                // 登録されたデバイスを取得する
                Console.Write(@"Context.EnumerateExistingNodes ... ");
                NodeInfoList nodeList = context.EnumerateExistingNodes();
                Console.WriteLine(@"Success");

                foreach (NodeInfo node in nodeList)
                {
                    // GetDescriptionの呼び出しで落ちる、、、
                    //Console.WriteLine(node.Description.Name + "," +
                    //                  node.Description.Vendor + "," +
                    //                  node.InstanceName + ",");
                    Console.WriteLine(node.InstanceName);
                }

                Console.WriteLine(@"Shutdown");
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 7
0
 public void FilterList(Context context, NodeInfoList list)
 {
     int status = SafeNativeMethods.xnNodeQueryFilterList(context.InternalObject, this.InternalObject, list.InternalObject);
     WrapperUtils.ThrowOnError(status);
 }
Ejemplo n.º 8
0
 public void FilterList(Context context, NodeInfoList list)
 {
     UInt32 status = OpenNIImporter.xnNodeQueryFilterList(context.InternalObject, this.InternalObject, list.InternalObject);
     WrapperUtils.CheckStatus(status);
 }