Ejemplo n.º 1
0
        /// <summary>
        /// 强制一次获取,必须在停止主循环的前提下调用,且通过此函数返回数据而不使用委托
        /// </summary>
        /// <returns></returns>
        public List <Kernel.Management.UserInterfaceBlockStruct.LinePageRuntimeBlockStruct> ForceToGet()
        {
            if (DllState != enumDllReflectionState.Ready)
            {
                throw new InvalidOperationException();
            }

            //set command
            Command.SetValue(ReflectionClass, DllCommandCreator.CreateCommandOfMonitorDll(enumCommandOfMonitorDll.GetLine, ""));

            string result = "";

            try {
                result = MethodGetData.Invoke(ReflectionClass, null).ToString();
            } catch (Exception) {
                return(new List <Management.UserInterfaceBlockStruct.LinePageRuntimeBlockStruct>());
            }

            if (result == "")
            {
                return(new List <Management.UserInterfaceBlockStruct.LinePageRuntimeBlockStruct>());
            }

            //set list
            var list = new List <Kernel.Management.UserInterfaceBlockStruct.LinePageRuntimeBlockStruct>();

            foreach (var item in new StringGroup(result, "@").ToStringGroup())
            {
                var temp = new StringGroup(item, "#").ToStringGroup();
                list.Add(new Management.UserInterfaceBlockStruct.LinePageRuntimeBlockStruct()
                {
                    ID                = temp[0],
                    IsUpLine          = temp[1] == "0" ? true : false,
                    BelongToStopIndex = System.Convert.ToInt32(temp[2]),
                    Message1          = temp[3],
                    Message2          = temp[4],
                    Message3          = temp[5]
                });
            }

            return(list);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 阅读循环
        /// </summary>
        private void ReadLoop()
        {
            string result = "";

            while (true)
            {
                //set command
                Command.SetValue(ReflectionClass, DllCommandCreator.CreateCommandOfMonitorDll(enumCommandOfMonitorDll.GetLine, ""));

                //尝试获取,获取失败返回
                try {
                    result = MethodGetData.Invoke(ReflectionClass, null).ToString();
                } catch (Exception) {
                    continue;
                }

                if (result == "")
                {
                    continue;
                }

                //set list
                var list = new List <Kernel.Management.UserInterfaceBlockStruct.LinePageRuntimeBlockStruct>();
                foreach (var item in new StringGroup(result, "@").ToStringGroup())
                {
                    var temp = new StringGroup(item, "#").ToStringGroup();
                    list.Add(new Management.UserInterfaceBlockStruct.LinePageRuntimeBlockStruct()
                    {
                        ID                = temp[0],
                        IsUpLine          = temp[1] == "0" ? true : false,
                        BelongToStopIndex = System.Convert.ToInt32(temp[2]),
                        Message1          = temp[3],
                        Message2          = temp[4],
                        Message3          = temp[5]
                    });
                }

                NewData(list);
            }
        }