Esempio n. 1
0
        }           //	end ProcessCommandLine

        public int BuildAddressSpace()
        {
            try
            {
                MyCreator creator = (MyCreator)Application.Instance.Creator;

                //	DA
                DaAddressSpaceRoot daRoot = Application.Instance.DaAddressSpaceRoot;
                m_daSimulationElement1              = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement();
                m_daSimulationElement1.Name         = "simulation1";
                m_daSimulationElement1.AccessRights = EnumAccessRights.READWRITEABLE;
                m_daSimulationElement1.Datatype     = typeof(System.Int32);
                m_daSimulationElement1.IoMode       = EnumIoMode.POLL;
                daRoot.AddChild(m_daSimulationElement1);

                m_daSimulationElement2              = (MyDaAddressSpaceElement)creator.CreateMyDaAddressSpaceElement();
                m_daSimulationElement2.Name         = "simulation2";
                m_daSimulationElement2.AccessRights = EnumAccessRights.READWRITEABLE;
                m_daSimulationElement2.Datatype     = typeof(System.Int32);
                m_daSimulationElement2.IoMode       = EnumIoMode.POLL;
                daRoot.AddChild(m_daSimulationElement2);
            }
            catch (Exception exc)
            {
                Trace(
                    EnumTraceLevel.ERR,
                    EnumTraceGroup.USER1,
                    "OpcServer.BuildAddressSpace",
                    exc.ToString());
                return((int)EnumResultCode.E_FAIL);
            }               //	end try...catch

            return((int)EnumResultCode.S_OK);
        }           //	end BuildAddressSpace
Esempio n. 2
0
        public void HandleRequests()
        {
            lock (m_requestsJanitor)
            {
                foreach (MyRequest request in m_requests)
                {
                    if (request.ProgressRequestState(EnumRequestState.PENDING, EnumRequestState.INPROGRESS))
                    {
                        MyDaAddressSpaceElement element = request.AddressSpaceElement as MyDaAddressSpaceElement;
                        if (element == null)
                        {
                            request.Result = EnumResultCode.E_FAIL;
                        }
                        else
                        {
                            switch (request.TransactionType)
                            {
                            case EnumTransactionType.READ:
                                if (request.PropertyId == 0)
                                {
                                    ValueQT cacheValue = null;
                                    request.Result = (EnumResultCode)element.GetCacheValue(ref cacheValue);
                                    request.Value  = cacheValue;
                                }
                                else
                                {
                                    element.GetPropertyValue(request);
                                }                                           //  end if ... else
                                break;

                            case EnumTransactionType.WRITE:
                                if (request.PropertyId == 0)
                                {
                                    ValueQT newValue = request.Value;
                                    request.Result = (EnumResultCode)element.ValueChanged(newValue);
                                }
                                else
                                {
                                    request.Result = EnumResultCode.E_BADRIGHTS;
                                }                                           //  end if ... else
                                break;

                            default:
                                break;
                            } //  end switch
                        }     //  end if ... else
                    }         //  end if ... else
                    request.Complete();
                }             //  end forech
                m_requests.Clear();
            }                 //  end lock
        }                     //  end HandleRequests