void PropertyChangedHandler(object sender, PropertyChangedEventArgs e)
        {
            var id = GetPropertyID(sender, e.PropertyName);

            if (id != null)
            {
                // get the new property value
                if (!m_propertyDictionary.ContainsKey(id))
                {
                    // someone raised a property changed on something that isn't a DataItem so ignore it
                    return;
                }

                var propData = m_propertyDictionary[id];
                var newValue = propData.PropertyInfo.GetValue(sender, null);

                // Debug.WriteLine(string.Format("MTConnectProperty '{0}' value changed to '{1}'", e.PropertyName, newValue));
                lock (m_ignorePropertyChangeIDs)
                {
                    m_ignorePropertyChangeIDs.Add(id);
                    AgentInterface.PublishData(id, newValue);
                    m_ignorePropertyChangeIDs.Remove(id);
                }
            }
        }
        /// <summary>
        /// 서버에 성공적으로 종료되었다는 신호를 보낸다.
        /// </summary>
        private void sendCloseSignal()
        {
            // 종료 신호를 보낸다.
            string closeProcessCommand = "closeProcess";
            WinMessage_ClientToServer closeResponse = new WinMessage_ClientToServer(EXEKIND.TestScan, closeProcessCommand, null);

            AgentInterface.SendToServer(closeResponse, serverHandle);
            Log.Instance.SetLogLevel(string.Format("# Send To Server\n\tCommand : {0}\n\tParam : ", closeProcessCommand, ""));
        }
        /// <summary>
        /// 서버에 성공적으로 실행되었다는 신호를 보낸다.
        /// </summary>
        private void sendStartSignal()
        {
            string startSuccessCommand = "startSuccess";
            WinMessage_ClientToServer successResponse = new WinMessage_ClientToServer(EXEKIND.TestScan, startSuccessCommand, null);

            AgentInterface.SendToServer(successResponse, serverHandle);


            Log.Instance.SetLogLevel(string.Format("# Send To Server\n\tCommand : {0}\n\tParam : ", startSuccessCommand, ""));
        }
        public RLGlueExperimentWithAgent(Component agent)
            : base(agent)
        {
            AgentInterface agentInterface = (AgentInterface)typeof(RLGlueAgentInterface <,>).MakeGenericType(
                agent.ComponentType.StateSpaceType,
                agent.ComponentType.ActionSpaceType)
                                            .GetConstructor(new[] { typeof(Component) })
                                            .Invoke(new object[] { agent });

            this.clientAgent     = new ClientAgent(agentInterface);
            this.rlGlueInterface = (IRLGlueInterface)agentInterface;
        }
Exemple #5
0
        protected internal virtual AgentControllerInterface createAgent(Props agentProps)
        {
            AgentController controller = null;
            string          classname  = agentProps.getString("classname");

            if (classname.Length > 0)
            {
                if (classname.Equals("com.neokernel.xml.XMLStartupAgent"))
                {
                    classname = "Feng.NeoKernel.nk.LicenseFreeXMLStartupAgent";
                }

                if (!classname.Equals("com.neokernel.xml.XMLStartupAgent") && !classname.Equals("com.neokernel.nk.Trmntr"))
                {
                    this.println("Creating agent " + classname);
                }
                try
                {
                    AgentInterface         agent = null;
                    IClassFactoryInterface defaultClassFactory = (IClassFactoryInterface)agentProps.getProperty("class_factory");
                    if (defaultClassFactory == null)
                    {
                        defaultClassFactory = NK.DefaultClassFactory;
                    }
                    agent = (AgentInterface)defaultClassFactory.createInstance(classname);
                    Type type = agent.GetType();
                    if (!agentProps.hasProperty("name"))
                    {
                        string fullName = type.FullName;
                        int    num      = fullName.LastIndexOf('.');
                        if (num > 0)
                        {
                            fullName = fullName.Substring(num + 1);
                        }
                        agentProps.setProperty("name", fullName);
                    }
                    agentProps.setDefault("agent_id", this.NextAgentID);
                    agent.Props = agentProps;
                    controller  = new AgentController(agent);
                }
                catch (ArgumentException exception)
                {
                    this.error("Could not create Agent: " + classname, exception);
                }
                catch (ClassFactoryException exception2)
                {
                    this.error("Could not create Agent: " + classname, exception2);
                }
            }
            return(controller);
        }
        public void UpdateProperties()
        {
            if (AgentInterface == null)
            {
                Debug.WriteLine("HostedAdapterBase.UpdateProperties: AgentInterface == null");
                return;
            }

            var propName = string.Empty;

            if (m_propertyDictionary == null)
            {
                return;
            }

            var keys = m_propertyDictionary.Keys;

            foreach (var id in keys)
            {
                try
                {
                    var propertyInfo = m_propertyDictionary[id].PropertyInfo;
                    propName = propertyInfo.Name;

                    object value = propertyInfo.GetValue(m_propertyDictionary[id].Instance, null);
                    if (value == null)
                    {
                        AgentInterface.PublishData(id, null);
                    }
                    else
                    {
                        AgentInterface.PublishData(id, value);
                    }
                }
                catch (Exception ex)
                {
                    if (LogService != null)
                    {
                        LogService.Log(ex, this.GetType().Name + ".UpdateProperty:" + propName);
                    }

                    Debug.WriteLine("HostedAdapterBase::UpdateProperties Exception: " + ex.Message);
                    return;
                }
            }
            m_firstPublish = false;
        }
        private void btn_Save_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                MessageBox.Show(this, "이미지를 가져와야 합니다.");
                return;
            }

            string filePath = img.FilePath;

            if (!File.Exists(filePath))
            {
                MessageBox.Show(this, "이미지가 존재하지 않습니다.");
                return;
            }

            string imgbinary_base64 = Encode.ImgBinaryToBase64String(filePath);

            SendParam sendParam = new SendParam(img.ScanDate, filePath, imgbinary_base64);

            WinMessage_ClientToServer workCompleteResponse = new WinMessage_ClientToServer(EXEKIND.TestScan, "workComplete", sendParam);

            AgentInterface.SendToServer(workCompleteResponse, serverHandle);
        }
 protected RemoteWindow(string name, AgentInterface agent) : base(name, agent)
 {
     // _instance = new T();
 }
 public ClientAgent(AgentInterface agent)
 {
     this.agent       = agent;
     rlGlueConnection = new RlGlueConnection();
 }