Пример #1
0
 public void                     writeSnapshot(bool aCancelOnError)
 {
     foreach (KeyValuePair <int, object> lKeyValue in mRecords)
     {
         if (mItemBrowser.getItemAccess(lKeyValue.Key).HasFlag(EAccess.WRITE))
         {
             try
             {
                 mItemBrowser.writeItemValue(lKeyValue.Key, lKeyValue.Value);
             }
             catch (Exception lExc)
             {
                 string lMessage = "Error writing Item '" + mItemBrowser.getItemNameByHandle(lKeyValue.Key) + "'. " + lExc.Message;
                 if (aCancelOnError)
                 {
                     throw new InvalidOperationException(lMessage, lExc);
                 }
                 else
                 {
                     Log.Error(lMessage, lExc.ToString());
                 }
             }
         }
         else
         {
             string lMessage = "No access for writing Item '" + mItemBrowser.getItemNameByHandle(lKeyValue.Key) + "'. ";
             if (aCancelOnError)
             {
                 throw new InvalidOperationException(lMessage);
             }
             else
             {
                 Log.Error(lMessage);
             }
         }
     }
 }
        public void                                         getItemValues(out int[] aItemHandles, out object[] aItemValues)
        {
            bool lValueChanged = mValueChanged;

            mValueChanged = false;

            List <int>    lHandles = new List <int>();
            List <object> lValues  = new List <object>();

            if (mOnItemHandle != -1)
            {
                lHandles.Add(mOnItemHandle);
                lValues.Add(mOn);
            }

            if (mPowerItemHandle != -1)
            {
                if (!lValueChanged || mPowerChanged)
                {
                    mPowerChanged = false;
                    lHandles.Add(mPowerItemHandle);
                    lValues.Add(mPower);
                }
            }

            if (mAlarmItemHandle != -1)
            {
                if (!lValueChanged || mAlarmChanged)
                {
                    mAlarmChanged = false;
                    lHandles.Add(mAlarmItemHandle);
                    lValues.Add(mAlarm);
                }
            }

            if (mRemoteItemHandle != -1)
            {
                if (!lValueChanged || mRemoteChanged)
                {
                    if (mItemBrowser.getItemAccess(mRemoteItemHandle).HasFlag(EAccess.WRITE))
                    {
                        mRemoteChanged = false;
                        lHandles.Add(mRemoteItemHandle);
                        lValues.Add(mRemote);
                    }
                }
            }

            if (mOnBtnItemHandle != -1)
            {
                if (!lValueChanged || mOnBtnChanged)
                {
                    mOnBtnChanged = false;
                    lHandles.Add(mOnBtnItemHandle);
                    lValues.Add(mOnBtn);
                }
            }

            if (mOffBtnItemHandle != -1)
            {
                if (!lValueChanged || mOffBtnChanged)
                {
                    mOffBtnChanged = false;
                    lHandles.Add(mOffBtnItemHandle);
                    lValues.Add(mOffBtn);
                }
            }

            aItemHandles = lHandles.ToArray();
            aItemValues  = lValues.ToArray();
        }