/// <summary>
 /// Initializes a new instance of SubscriptionInfo.
 /// Default construtor provided for serialization purposes only
 /// </summary>
 public SubscriptionInfo()
 {
     this.variableInfo = null;
     this.moduleName = null;
     this.writerModule = null;
     this.subscriptionType = SharedVariableSubscriptionType.None;
     this.reportType = SharedVariableReportType.None;
 }
        /// <summary>
        /// Initializes a new instance of SubscriptionInfo
        /// </summary>
        /// <param name="variableInfo">The object which contains information about the shared variable related to the subscription</param>
        /// <param name="moduleName">The name of the subscriber module</param>
        /// <param name="subscriptionType">The subscription type for the subscriber module</param>
        /// <param name="reportType">The report type for the subscription of the subscriber module</param>
        /// <param name="writerModule">The name of the writer module for subscription types which allows to set an specific module</param>
        public SubscriptionInfo(ISharedVariableInfo variableInfo, string moduleName,
			SharedVariableSubscriptionType subscriptionType, SharedVariableReportType reportType, string writerModule)
        {
            this.VariableInfo = variableInfo;
            this.ModuleName = moduleName;
            this.SubscriptionType = subscriptionType;
            this.ReportType = reportType;
            this.WriterModule = writerModule;
        }
        /// <summary>
        /// Initializes a new instance of SharedVariableReport
        /// </summary>
        /// <param name="variableInfo">The information of the related shared variable</param>
        /// <param name="serializedData">The serialized value of the shared variable</param>
        /// <param name="reportType">The type of the report</param>
        /// <param name="subscriptionType">The type of the subscription</param>
        /// <param name="writer"> The name of the module which performed the write/create operation</param>
        public SharedVariableReport(ISharedVariableInfo variableInfo, string serializedData,
			SharedVariableReportType reportType, SharedVariableSubscriptionType subscriptionType, string writer)
        {
            if (variableInfo == null)
                throw new ArgumentNullException();
            this.serializedData = serializedData;
            this.variableInfo = variableInfo;
            this.reportType = reportType;
            this.subscriptionType = subscriptionType;
            this.writer = writer;
        }
 /// <summary>
 /// Initializes a new instance of SubscriptionInfo
 /// Construtor provided for serialization purposes only
 /// </summary>
 /// <param name="variableInfo">The object which contains information about the shared variable related to the subscription</param>
 internal SubscriptionInfo(ISharedVariableInfo variableInfo)
 {
     this.VariableInfo = variableInfo;
     this.moduleName = null;
     this.subscriptionType = SharedVariableSubscriptionType.None;
     this.reportType = SharedVariableReportType.None;
     this.writerModule = null;
 }
        /// <summary>
        /// Initializes a new instance of SubscriptionInfo
        /// </summary>
        /// <param name="variableInfo">The object which contains information about the shared variable related to the subscription</param>
        /// <param name="moduleName">The name of the subscriber module</param>
        /// <param name="subscriptionType">The subscription type for the subscriber module</param>
        /// <param name="reportType">The report type for the subscription of the subscriber module</param>
        public SubscriptionInfo(ISharedVariableInfo variableInfo, string moduleName,
			SharedVariableSubscriptionType subscriptionType, SharedVariableReportType reportType)
            : this(variableInfo, moduleName, subscriptionType, reportType, null)
        {
        }
        private static bool GetVariableInfo(ref string parameters, out ISharedVariableInfo info, out string data, out Exception ex)
        {
            SharedVariableInfo varInfo;
            string type;
            bool isArray;
            int size;
            string name;
            int cc;

            info = null;
            ex = null;
            data = null;
            varInfo = new SharedVariableInfo();

            // 1. Get variable type
            cc = 0;
            if (!GetVariableType(ref parameters, ref cc, out type, out isArray, out size, out ex))
                return false;
            varInfo.TypeName = type;
            varInfo.IsArray = isArray;
            varInfo.Length = size;

            // 2. Get variable name
            if (!GetVariableName(ref parameters, ref cc, out name, out ex))
                return false;
            varInfo.Name = name;

            // 3. Get variable data
            if (!GetVariableData(ref parameters, ref cc, out data, out ex))
                return false;

            info = varInfo;
            return true;
        }
        private static void SerializeSVInfo(StringBuilder sb, ISharedVariableInfo info)
        {
            // 1. Append variable type
            sb.Append(info.TypeName);
            if (info.IsArray)
            {
                sb.Append('[');
                if (info.Length > 0)
                    sb.Append(info.Length);
                sb.Append(']');
            }

            // 2. Append variable name
            sb.Append(' ');
            sb.Append(info.Name);
        }
        private static void SerializeWriters(StringBuilder sb, ISharedVariableInfo info)
        {
            if ((info.AllowedWriters == null) || (info.AllowedWriters.Length < 1))
                return;

            sb.Append(" writers={");
            sb.Append(info.AllowedWriters[0]);
            for (int i = 1; i < info.AllowedWriters.Length; ++i)
            {
                sb.Append(',');
                sb.Append(info.AllowedWriters[i]);
            }
            sb.Append('}');
        }
        private static void SerializeSubscriptions(StringBuilder sb, ISharedVariableInfo info)
        {
            if ((info.Subscriptions == null) || (info.Subscriptions.Length < 1))
                return;

            sb.Append(" subscriptions={");
            SerializeSubscription(sb, info.Subscriptions[0]);
            for (int i = 1; i < info.Subscriptions.Length; ++i)
            {
                sb.Append(',');
                SerializeSubscription(sb, info.Subscriptions[i]);
            }
            sb.Append('}');
        }
 private static void SerializeCreationTime(StringBuilder sb, ISharedVariableInfo info)
 {
     sb.Append(" creationTime={");
     sb.Append(info.CreationTime.ToString("yyyy-MM-dd hh:mm:ss"));
     sb.Append('}');
 }
        /// <summary>
        /// Serializes an ISharedVariableInfo object to a string
        /// </summary>
        /// <param name="info">The ISharedVariableInfo object to serialize</param>
        /// <param name="serializedData">When this method returns contains the string representation of the
        /// object if the serialization succeded, or false if the serialization failed</param>
        /// <returns>true if the serialization succeded, false otherwise</returns>
        public static bool Serialize(ISharedVariableInfo info, out string serializedData)
        {
            serializedData = null;
            if (info == null)
                return false;
            StringBuilder sb = new StringBuilder(4096);

            // 1. Append variable information
            SerializeSVInfo(sb, info);

            // 1. Append creation time
            SerializeCreationTime(sb, info);

            // 3. Append writers
            SerializeWriters(sb, info);

            // 4. Append subscriptions information
            SerializeSubscriptions(sb, info);

            serializedData = sb.ToString();
            return true;
        }
Example #12
0
 /// <summary>
 /// Initializes a new instance of SubscriptionInfo
 /// </summary>
 /// <param name="variableInfo">The object which contains information about the shared variable related to the subscription</param>
 /// <param name="moduleName">The name of the subscriber module</param>
 /// <param name="subscriptionType">The subscription type for the subscriber module</param>
 /// <param name="reportType">The report type for the subscription of the subscriber module</param>
 public SubscriptionInfo(ISharedVariableInfo variableInfo, string moduleName,
                         SharedVariableSubscriptionType subscriptionType, SharedVariableReportType reportType)
     : this(variableInfo, moduleName, subscriptionType, reportType, null)
 {
 }
Example #13
0
 private static void SerializeCreationTime(StringBuilder sb, ISharedVariableInfo info)
 {
     sb.Append(" creationTime={");
     sb.Append(info.CreationTime.ToString("yyyy-MM-dd hh:mm:ss"));
     sb.Append('}');
 }