Exemplo n.º 1
0
 /// <summary>
 /// Rises the ReportReceived event
 /// </summary>
 /// <param name="report">The report data received from Blackboard</param>
 protected virtual void OnReportReceived(SharedVariableReport report)
 {
     if (this.ReportReceived != null)
     {
         this.ReportReceived(this, report);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the SharedVariable object with data provided from the blackboard due to a subscription
        /// </summary>
        /// <param name="svReport">The report which contains the information for update</param>
        /// <param name="ex">When this method returns contains null if the variable was updated successfully, or the exception to be thrown if the update failed</param>
        /// <returns>true if variable was updated successfully, false otherwise</returns>
        internal override bool Update(SharedVariableReport svReport, out Exception ex)
        {
            OnReportReceived(svReport);
            if (!IsValidUpdateData(svReport.VariableInfo.TypeName, svReport.VariableInfo.IsArray, svReport.VariableInfo.Length, svReport.VariableInfo.Name, out ex))
            {
                return(false);
            }

            T value;
            T oldValue = BufferedData;

            if (!UpdateValue(svReport.SerializedData, svReport.Writer, out value, out ex))
            {
                return(false);
            }
            SharedVariableSubscriptionReport <T> report;

            //report = new SharedVariableSubscriptionReport<T>(this, reportType, subscriptionType, writer, value, reportString);
            report = new SharedVariableSubscriptionReport <T>(this, svReport.ReportType, svReport.SubscriptionType, svReport.Writer, value);

            OnWriteNotification(report);
            // Check if value changed
            IComparable <T> cValue = value as IComparable <T>;

            if ((cValue != null) && (cValue.CompareTo(oldValue) != 0))
            {
                OnValueChanged(report);
            }
            else if (!System.Collections.Generic.EqualityComparer <T> .Default.Equals(oldValue, value))
            {
                OnValueChanged(report);
            }
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates the SharedVariable object with data provided from the blackboard due to a subscription
        /// </summary>
        /// <param name="variableType">The type of the variable specified by blackboard</param>
        /// <param name="variableName">The name of the variable specified by blackboard</param>
        /// <param name="isArray">Value that indicates if the variable specified by blackboard is an array</param>
        /// <param name="arraySize">The size of the variable specified by blackboard if it is an array</param>
        /// <param name="sData">The serialized data contained in the report</param>
        /// <param name="reportType">The type of report</param>
        /// <param name="subscriptionType">The type of subscription</param>
        /// <param name="writer">The name of the module which performed the write/create operation</param>
        /// <param name="ex">When this method returns contains null if the variable was updated successfully, or the exception to be thrown if the update failed</param>
        /// <returns>true if variable was updated successfully, false otherwise</returns>
        internal bool Update(string variableType, bool isArray, int arraySize, string variableName, string sData, SharedVariableReportType reportType,
                             SharedVariableSubscriptionType subscriptionType, string writer, out Exception ex)
        {
            SharedVariableReport report;
            SharedVariableInfo   variableInfo;

            variableInfo = new SharedVariableInfo(variableType, variableName, isArray, arraySize);
            report       = new SharedVariableReport(variableInfo, sData, reportType, subscriptionType, writer);
            return(Update(report, out ex));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Generates a SharedVariableReport object from a Response object
        /// </summary>
        /// <param name="response">The Response object to be used to generate the report</param>
        /// <param name="report">When this method returns contains the SharedVariableReport object
        /// extracted from the response if the parse operation was completed successfully, null otherwise</param>
        /// <param name="ex">When this method returns contains null if the parse operation was completed successfully,
        /// or the exception to be thrown if the operation failed</param>
        /// <returns>A SharedVariableReport object created from the Response object</returns>
        internal static bool CreateFromResponse(Response response, out SharedVariableReport report, out Exception ex)
        {
            string parameters;
            string data;

            string writer;
            SharedVariableReportType       reportType;
            SharedVariableSubscriptionType subscriptionType;
            ISharedVariableInfo            varInfo;

            report = null;
            ex     = null;

            parameters = response.Parameters;
            // 1. Get writer
            if (!GetWriter(ref parameters, out writer, out ex))
            {
                return(false);
            }

            // 2. Get subscription type
            if (!GetSubscriptionType(ref parameters, out subscriptionType, out ex))
            {
                return(false);
            }

            // 3. Get report type.
            if (!GetReportType(ref parameters, out reportType, out ex))
            {
                return(false);
            }

            // 4. Get variable info
            if (!GetVariableInfo(ref parameters, out varInfo, out data, out ex))
            {
                return(false);
            }

            // 5. Create the report
            report = new SharedVariableReport(varInfo, data, reportType, subscriptionType, writer);
            return(true);
        }
        /// <summary>
        /// Generates a SharedVariableReport object from a Response object
        /// </summary>
        /// <param name="response">The Response object to be used to generate the report</param>
        /// <param name="report">When this method returns contains the SharedVariableReport object
        /// extracted from the response if the parse operation was completed successfully, null otherwise</param>
        /// <param name="ex">When this method returns contains null if the parse operation was completed successfully,
        /// or the exception to be thrown if the operation failed</param>
        /// <returns>A SharedVariableReport object created from the Response object</returns>
        internal static bool CreateFromResponse(Response response, out SharedVariableReport report, out Exception ex)
        {
            string parameters;
            string data;

            string writer;
            SharedVariableReportType reportType;
            SharedVariableSubscriptionType subscriptionType;
            ISharedVariableInfo varInfo;

            report = null;
            ex = null;

            parameters = response.Parameters;
            // 1. Get writer
            if (!GetWriter(ref parameters, out writer, out ex))
                return false;

            // 2. Get subscription type
            if(!GetSubscriptionType(ref parameters, out subscriptionType, out ex))
                return false;

            // 3. Get report type.
            if (!GetReportType(ref parameters, out reportType, out ex))
                return false;

            // 4. Get variable info
            if (!GetVariableInfo(ref parameters, out varInfo, out data, out ex))
                return false;

            // 5. Create the report
            report = new SharedVariableReport(varInfo, data, reportType, subscriptionType, writer);
            return true;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Updates the SharedVariable object with data provided from the blackboard due to a subscription
 /// </summary>
 /// <param name="svReport">The report which contains the information for update</param>
 /// <param name="ex">When this method returns contains null if the variable was updated successfully, or the exception to be thrown if the update failed</param>
 /// <returns>true if variable was updated successfully, false otherwise</returns>
 internal abstract bool Update(SharedVariableReport svReport, out Exception ex);