Exemple #1
0
        public bool HNC_NetFileSend(string localPath, string filename)
        {
            if (!File.Exists(localPath))
            {
                throw new FileNotFoundException("G代码文件未找到!", localPath);
            }
            if (string.IsNullOrWhiteSpace(filename))
            {
                throw new ArgumentException("文件名不能为空!");
            }
            var list = new List <string>();

            using (var sr = new StreamReader(localPath, Encoding.Default))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    if (!string.IsNullOrWhiteSpace(line))
                    {
                        list.Add(line);
                    }
                }
            }
            WriteList("GCodeFileSent:" + @"h/lnc8/prog/" + filename, list);
            var message = new NCMessage
            {
                Type    = "File",
                SubType = "h/lnc8/prog",
                Index   = 0,
                Value   = filename,
            };

            return(Publish(message.ToString()));
        }
Exemple #2
0
        /// <summary>
        /// 设置刀补
        /// </summary>
        /// <param name="toolVal">补偿值(标准值-测量值)</param>
        /// <param name="toolNO">刀具编号(从1开始)</param>
        /// <param name="type">(1:X向,2:Z向)??(1:长度,2:长度磨损,3:半径,4:半径磨损)</param>
        /// <returns>是否成功</returns>
        public bool HNC_ToolSetValue(double toolVal, int toolNO, int type)
        {
            var message = new NCMessage
            {
                Type  = "ToolSet",
                Value = JsonConvert.SerializeObject(new { toolVal, toolNO, type }),
            };

            return(Publish(message.ToString()));
        }
Exemple #3
0
        public bool HNC_NetFileRemove(string destinationPath)
        {
            var message = new NCMessage
            {
                Type  = "File",
                Index = 1,
                Value = destinationPath
            };

            return(Publish(message.ToString()));
        }
Exemple #4
0
        public bool HNC_NetFileCheck(string localPath, string destinationPath)
        {
            var message = new NCMessage
            {
                Type    = "File",
                SubType = destinationPath,
                Index   = 2,
                Value   = localPath.Split('\\').LastOrDefault(),
            };

            return(Publish(message.ToString()));
        }
Exemple #5
0
        private bool Publish(HncRegType type, int index, int value, int NCMessageFunction)
        {
            var message = new NCMessage
            {
                Type  = "Register",
                Index = NCMessageFunction,
                Value = JsonConvert.SerializeObject(
                    new
                {
                    regType = Enum.GetName(typeof(HncRegType), type).Replace("REG_TYPE_", ""),
                    index,
                    value,
                }),
            };

            return(Publish(message.ToString()));
        }