예제 #1
0
        /// <summary>
        /// 按索引号设置宏变量的值
        /// </summary>
        /// <param name="no"></param>
        /// <param name="var"></param>
        /// <param name="clientNo"></param>
        /// <returns></returns>
        public Int32 HNC_MacroVarSetValue(Int32 no, SDataUnion var, Int16 clientNo)
        {
            int ret = -1;

            //if (var != null)
            {
                //if (name.Length > 0)
                {
                    //if (SetContentToRemoteRedisDB(database, key, hashField, content))
                    {
                        HNCAPI.Data.NC_SetValueMessage m = new HNCAPI.Data.NC_SetValueMessage();
                        m.Type  = "MacroVariable";
                        m.Index = 0;
                        m.Value = "{\"no\":\"" + no + "\"," + "\"var\":" + Newtonsoft.Json.JsonConvert.SerializeObject(var) + "}";
                        String message = m.ToString();
                        if (RedisConnectLocal != null)
                        {
                            String MachineSN = "";
                            GetKeyValueString(clientNo, "Machine", ref MachineSN);
                            if (MachineSN.Length > 0)
                            {
                                ISubscriber sub = RedisConnectLocal.GetSubscriber();
                                sub.Publish(MachineSN + ":SetValue", message);
                                ret = 0;
                            }
                        }
                    }
                }
            }
            return(ret);
        }
예제 #2
0
        /// <summary>
        /// 从下位机加载G代码程序
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="name"></param>
        /// <param name="clientNo"></param>
        /// <returns></returns>
        public Int32 HNC_SysCtrlSelectProg(Int32 ch, String name, Int16 clientNo)
        {
            int ret = -1;

            if (name != null)
            {
                if (name.Length > 0)
                {
                    //if (SetContentToRemoteRedisDB(database, key, hashField, content))
                    {
                        HNCAPI.Data.NC_SetValueMessage m = new HNCAPI.Data.NC_SetValueMessage();
                        m.Type  = "SysCtrlSelectProg";
                        m.Index = 0;
                        m.Value = "{\"ch\":\"" + ch + "\"," + "\"name\":\"" + name + "\"}";
                        String message = m.ToString();
                        if (RedisConnectLocal != null)
                        {
                            String MachineSN = "";
                            GetKeyValueString(clientNo, "Machine", ref MachineSN);
                            if (MachineSN.Length > 0)
                            {
                                ISubscriber sub = RedisConnectLocal.GetSubscriber();
                                sub.Publish(MachineSN + ":SetValue", message);
                                ret = 0;
                            }
                        }
                    }
                }
            }
            return(ret);
        }