Пример #1
0
        private string ReadFeedrateHandle(ref ushort flib, string para)
        {
            string message = null;

            var res = new ReadFeedrateResultModel();

            var ret = new FeedrateHelper().ReadFeedrate(flib, ref res);

            if (ret.Item1 == -16)
            {
                var ret_conn = ConnectHelper.BuildConnect(ref flib, m_ip, m_port, m_timeout);

                if (ret_conn == 0)
                {
                    ret = new FeedrateHelper().ReadFeedrate(flib, ref res);
                }
            }

            if (ret.Item1 != 0)
            {
                message = ret.Item2;
            }
            GetResultEvent?.Invoke(new BaseCNCResultModel <ReadFeedrateResultModel>()
            {
                Value = new List <ReadFeedrateResultModel>()
                {
                    res
                }, Id = para
            });

            return(message);
        }
Пример #2
0
        private string ReadPositionHandle(ref ushort flib, string para)
        {
            string message = null;

            var paraModel = JsonConvert.DeserializeObject <ReadPositionModel>(para);
            var res       = new List <ReadPositionResultItemModel>();

            Dictionary <CncPositionTypeEnum, int[]> datas = new Dictionary <CncPositionTypeEnum, int[]>();

            foreach (var item in paraModel.Readers)
            {
                int[] data = new int[Focas1.MAX_AXIS];
                var   ret  = new PositionHelper().ReadPositionRange(flib, item.PositionType, ref data);
                if (ret.Item1 == -16 || ret.Item1 == -8)
                {
                    var ret_conn = ConnectHelper.BuildConnect(ref flib, m_ip, m_port, m_timeout);

                    if (ret_conn == 0)
                    {
                        ret = new PositionHelper().ReadPositionRange(flib, item.PositionType, ref data);
                    }
                }

                if (ret.Item1 == 0)
                {
                    datas.Add(item.PositionType, data);
                }
            }

            foreach (var item in paraModel.Decompilers)
            {
                int    data    = 0;
                string ret_dec = "";
                if (datas.ContainsKey(item.PositionType))
                {
                    ret_dec = new PositionHelper().DecompilerReadPositionInfo(datas[item.PositionType], item, ref data);
                }

                if (ret_dec != null)
                {
                    message = ret_dec;
                }
                else
                {
                    res.Add(new ReadPositionResultItemModel()
                    {
                        Id    = item.Id,
                        Value = (double)data / m_increment
                    });
                }
            }
            GetResultEvent?.Invoke(new BaseCNCResultModel <ReadPositionResultItemModel>()
            {
                Value = res, Id = ""
            });

            return(message);
        }
Пример #3
0
        private string ReadPmcHandle(ref ushort flib, string para)
        {
            string message = null;

            var paraModel = JsonConvert.DeserializeObject <ReadPmcModel>(para);
            var res       = new List <ReadPmcResultItemModel>();

            Dictionary <short, int[]> datas = new Dictionary <short, int[]>();

            foreach (var item in paraModel.Readers)
            {
                int[] data = new int[item.DwordQuantity];
                var   ret  = new PmcHelper().ReadPmcRange(flib, item.AdrType, item.StartNum, item.DwordQuantity, ref data);
                if (ret.Item1 == -16 || ret.Item1 == -8)
                {
                    var ret_conn = ConnectHelper.BuildConnect(ref flib, m_ip, m_port, m_timeout);

                    if (ret_conn == 0)
                    {
                        ret = new PmcHelper().ReadPmcRange(flib, item.AdrType, item.StartNum, item.DwordQuantity, ref data);
                    }
                }

                if (ret.Item1 == 0)
                {
                    datas.Add(item.AdrType, data);
                }
            }

            foreach (var item in paraModel.Decompilers)
            {
                string data    = "";
                string ret_dec = "";
                if (datas.ContainsKey(item.AdrType))
                {
                    ret_dec = new PmcHelper().DecompilerReadPmcInfo(datas[item.AdrType], item, ref data);
                }
                // var ret_dec = PmcHelper.DecompilerReadPmcInfo(datas[item.AdrType], item, ref data);
                if (ret_dec != null)
                {
                    message = ret_dec;
                }
                else
                {
                    res.Add(new ReadPmcResultItemModel()
                    {
                        Id    = item.Id,
                        Value = data
                    });
                }
            }
            GetResultEvent?.Invoke(new BaseCNCResultModel <ReadPmcResultItemModel>()
            {
                Value = res, Id = ""
            });
            return(message);
        }
Пример #4
0
        private string ReadMacroHandle(ref ushort flib, string para)
        {
            string message = null;

            var paraModel = JsonConvert.DeserializeObject <ReadMacroModel>(para);
            var res       = new List <ReadMacroResultItemModel>();

            foreach (var item in paraModel.Readers)
            {
                var datas = new double[item.Quantity];

                var ret = new MacroHelper().ReadMacroRange(flib, item.StartNum, item.Quantity, ref datas);
                if (ret.Item1 == -16)
                {
                    var ret_conn = ConnectHelper.BuildConnect(ref flib, m_ip, m_port, m_timeout);

                    if (ret_conn == 0)
                    {
                        ret = new MacroHelper().ReadMacroRange(flib, item.StartNum, item.Quantity, ref datas);
                    }
                }
            }

            //foreach (var item in paraModel.Decompilers)
            //{
            //    double[] data = ;
            //    var ret_dec = MacroHelper.DecompilerReadMacroInfo(datas, item, ref data);
            //    if (ret_dec != null)
            //    {
            //        message = ret_dec;
            //    }
            //    else
            //    {
            //        res.Add(new ReadMacroResultItemModel()
            //        {
            //            Id = item.Id,
            //            Value = data
            //        });
            //    }
            //}
            GetResultEvent?.Invoke(new BaseCNCResultModel <ReadMacroResultItemModel>()
            {
                Value = res, Id = ""
            });

            return(message);
        }