コード例 #1
0
ファイル: ReportGenerator.cs プロジェクト: fr830/OPCUA.NET
        public void Initialize()
        {
            m_dataset = new DataSet();

            m_dataset.Tables.Add("FluidLevelTests");
            m_dataset.Tables[0].Columns.Add(Opc.Ua.BrowseNames.EventId, typeof(string));
            m_dataset.Tables[0].Columns.Add(Opc.Ua.BrowseNames.Time, typeof(DateTime));
            m_dataset.Tables[0].Columns.Add(BrowseNames.NameWell, typeof(string));
            m_dataset.Tables[0].Columns.Add(BrowseNames.UidWell, typeof(string));
            m_dataset.Tables[0].Columns.Add(BrowseNames.TestDate, typeof(DateTime));
            m_dataset.Tables[0].Columns.Add(BrowseNames.TestReason, typeof(string));
            m_dataset.Tables[0].Columns.Add(BrowseNames.FluidLevel, typeof(double));
            m_dataset.Tables[0].Columns.Add(Opc.Ua.BrowseNames.EngineeringUnits, typeof(string));
            m_dataset.Tables[0].Columns.Add(BrowseNames.TestedBy, typeof(string));

            m_dataset.Tables.Add("InjectionTests");
            m_dataset.Tables[1].Columns.Add(Opc.Ua.BrowseNames.EventId, typeof(string));
            m_dataset.Tables[1].Columns.Add(Opc.Ua.BrowseNames.Time, typeof(DateTime));
            m_dataset.Tables[1].Columns.Add(BrowseNames.NameWell, typeof(string));
            m_dataset.Tables[1].Columns.Add(BrowseNames.UidWell, typeof(string));
            m_dataset.Tables[1].Columns.Add(BrowseNames.TestDate, typeof(DateTime));
            m_dataset.Tables[1].Columns.Add(BrowseNames.TestReason, typeof(string));
            m_dataset.Tables[1].Columns.Add(BrowseNames.TestDuration, typeof(double));
            m_dataset.Tables[1].Columns.Add(Opc.Ua.BrowseNames.EngineeringUnits, typeof(string));
            m_dataset.Tables[1].Columns.Add(BrowseNames.InjectedFluid, typeof(string));

            m_random = new Random();

            // look up the local timezone.
            TimeZone timeZone = TimeZone.CurrentTimeZone;

            m_timeZone        = new TimeZoneDataType();
            m_timeZone.Offset = (short)timeZone.GetUtcOffset(DateTime.Now).TotalMinutes;
            m_timeZone.DaylightSavingInOffset = timeZone.IsDaylightSavingTime(DateTime.Now);
        }
コード例 #2
0
ファイル: ReportGenerator.cs プロジェクト: yuriik83/UA-.NET
        public void Initialize()
        {
            m_dataset = new DataSet();

            m_dataset.Tables.Add("FluidLevelTests");
            m_dataset.Tables[0].Columns.Add(Opc.Ua.BrowseNames.EventId, typeof(string));
            m_dataset.Tables[0].Columns.Add(Opc.Ua.BrowseNames.Time, typeof(DateTime));
            m_dataset.Tables[0].Columns.Add(BrowseNames.NameWell, typeof(string));
            m_dataset.Tables[0].Columns.Add(BrowseNames.UidWell, typeof(string));
            m_dataset.Tables[0].Columns.Add(BrowseNames.TestDate, typeof(DateTime));
            m_dataset.Tables[0].Columns.Add(BrowseNames.TestReason, typeof(string));
            m_dataset.Tables[0].Columns.Add(BrowseNames.FluidLevel, typeof(double));
            m_dataset.Tables[0].Columns.Add(Opc.Ua.BrowseNames.EngineeringUnits, typeof(string));
            m_dataset.Tables[0].Columns.Add(BrowseNames.TestedBy, typeof(string));
            
            m_dataset.Tables.Add("InjectionTests");
            m_dataset.Tables[1].Columns.Add(Opc.Ua.BrowseNames.EventId, typeof(string));
            m_dataset.Tables[1].Columns.Add(Opc.Ua.BrowseNames.Time, typeof(DateTime));
            m_dataset.Tables[1].Columns.Add(BrowseNames.NameWell, typeof(string));
            m_dataset.Tables[1].Columns.Add(BrowseNames.UidWell, typeof(string));
            m_dataset.Tables[1].Columns.Add(BrowseNames.TestDate, typeof(DateTime));
            m_dataset.Tables[1].Columns.Add(BrowseNames.TestReason, typeof(string));
            m_dataset.Tables[1].Columns.Add(BrowseNames.TestDuration, typeof(double));
            m_dataset.Tables[1].Columns.Add(Opc.Ua.BrowseNames.EngineeringUnits, typeof(string));
            m_dataset.Tables[1].Columns.Add(BrowseNames.InjectedFluid, typeof(string));

            m_random = new Random();

            // look up the local timezone.
            TimeZone timeZone = TimeZone.CurrentTimeZone;
            m_timeZone = new TimeZoneDataType();
            m_timeZone.Offset = (short)timeZone.GetUtcOffset(DateTime.Now).TotalMinutes;
            m_timeZone.DaylightSavingInOffset = timeZone.IsDaylightSavingTime(DateTime.Now);
        }
コード例 #3
0
        /// <summary>
        /// Gets the result for the read operation.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="property">The property.</param>
        /// <param name="nodeToRead">The node to read.</param>
        /// <param name="value">The value.</param>
        /// <param name="diagnosticsMasks">The diagnostics masks.</param>
        /// <returns></returns>
        public ServiceResult GetResult(
            ISystemContext context,
            PropertyState property,
            ReadValueId nodeToRead,
            DataValue value,
            DiagnosticsMasks diagnosticsMasks)
        {
            DaItemState item = property.Parent as DaItemState;

            if (item == null)
            {
                return(StatusCodes.BadNodeIdUnknown);
            }

            if (nodeToRead.AttributeId != Attributes.Value)
            {
                return(StatusCodes.BadAttributeIdInvalid);
            }

            switch (property.SymbolicName)
            {
            case Opc.Ua.BrowseNames.EURange:
            {
                double high = this.GetPropertyValue <double>(Opc.Ua.Com.PropertyIds.HighEU, value, true);

                if (StatusCode.IsBad(value.StatusCode))
                {
                    return(value.StatusCode);
                }

                double low = this.GetPropertyValue <double>(Opc.Ua.Com.PropertyIds.LowEU, value, true);

                if (StatusCode.IsBad(value.StatusCode))
                {
                    return(value.StatusCode);
                }

                value.Value = new Range(high, low);
                break;
            }

            case Opc.Ua.BrowseNames.InstrumentRange:
            {
                double high = this.GetPropertyValue <double>(Opc.Ua.Com.PropertyIds.HighIR, value, true);

                if (StatusCode.IsBad(value.StatusCode))
                {
                    return(value.StatusCode);
                }

                double low = this.GetPropertyValue <double>(Opc.Ua.Com.PropertyIds.LowIR, value, true);

                if (StatusCode.IsBad(value.StatusCode))
                {
                    return(value.StatusCode);
                }

                value.Value = new Range(high, low);
                break;
            }

            case Opc.Ua.BrowseNames.EngineeringUnits:
            {
                string units = this.GetPropertyValue <string>(Opc.Ua.Com.PropertyIds.EngineeringUnits, value, true);

                if (StatusCode.IsBad(value.StatusCode))
                {
                    return(value.StatusCode);
                }

                value.Value = new EUInformation(units, Namespaces.ComInterop);
                break;
            }

            case Opc.Ua.BrowseNames.EnumStrings:
            {
                string[] strings = this.GetPropertyValue <string[]>(Opc.Ua.Com.PropertyIds.EuInfo, value, true);

                if (StatusCode.IsBad(value.StatusCode))
                {
                    return(value.StatusCode);
                }

                if (strings != null)
                {
                    LocalizedText[] texts = new LocalizedText[strings.Length];

                    for (int ii = 0; ii < texts.Length; ii++)
                    {
                        texts[ii] = new LocalizedText(strings[ii]);
                    }

                    value.Value = texts;
                }

                break;
            }

            case Opc.Ua.BrowseNames.LocalTime:
            {
                int timebias = this.GetPropertyValue <int>(Opc.Ua.Com.PropertyIds.TimeZone, value, true);

                if (StatusCode.IsBad(value.StatusCode))
                {
                    return(value.StatusCode);
                }

                TimeZoneDataType timeZone = new TimeZoneDataType();
                timeZone.Offset = (short)timebias;
                timeZone.DaylightSavingInOffset = false;

                value.Value = timeZone;
                break;
            }

            case Opc.Ua.BrowseNames.TrueState:
            {
                string description = this.GetPropertyValue <string>(Opc.Ua.Com.PropertyIds.CloseLabel, value, false);

                if (StatusCode.IsGood(value.StatusCode))
                {
                    value.Value = new LocalizedText(description);
                }

                break;
            }

            case Opc.Ua.BrowseNames.FalseState:
            {
                string description = this.GetPropertyValue <string>(Opc.Ua.Com.PropertyIds.OpenLabel, value, false);

                if (StatusCode.IsGood(value.StatusCode))
                {
                    value.Value = new LocalizedText(description);
                }

                break;
            }

            default:
            {
                return(StatusCodes.BadAttributeIdInvalid);
            }
            }

            // check if the property value is missing.
            if (value.StatusCode == StatusCodes.BadNotFound)
            {
                return(StatusCodes.BadNodeIdUnknown);
            }

            return(ApplyIndexRangeAndDataEncoding(context, nodeToRead, value));
        }