예제 #1
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);
        }
예제 #2
0
 /// <summary>
 /// Raises the WriteNotification event
 /// </summary>
 /// <param name="report">The SharedVariableSubscriptionReport object which contain the report information</param>
 protected virtual void OnWriteNotification(SharedVariableSubscriptionReport <T> report)
 {
     if (WriteNotification != null)
     {
         try
         {
             WriteNotification(report);
         }
         catch { }
     }
 }
예제 #3
0
 /// <summary>
 /// Raises the ValueChanged event
 /// </summary>
 /// <param name="report">The SharedVariableSubscriptionReport object which contain the report information</param>
 protected virtual void OnValueChanged(SharedVariableSubscriptionReport <T> report)
 {
     //if ((this.ValueChanged != null) && (report.ReportType != SharedVariableReportType.Notify) && (bufferedData == previousBufferedData))
     if ((this.ValueChanged != null) && (report.ReportType != SharedVariableReportType.Notify))
     {
         try
         {
             ValueChanged(report);
         }
         catch { }
     }
 }