Definition of ICS data structure.
コード例 #1
0
        /// <summary>
        /// Insert state value into state dictionary.
        /// </summary>
        /// <param name="s">State object.</param>
        /// <returns>State value index in container.</returns>
        private int InsertStateDict(State s)
        {
            if (s != null && s.PropList != null && s.PropList.PropValues != null && s.PropList.PropValues.Count > 0)
            {
                int index = AdapterHelper.GetICSStateIndex();
                ICSStateData data = new ICSStateData();
                for (int i = 0; i < s.PropList.PropValues.Count; i++)
                {
                    PropValue value = s.PropList.PropValues[i];

                    VarPropTypePropValue varPropTypePropValue = value as VarPropTypePropValue;
                    AdapterHelper.Site.Assert.IsNotNull(varPropTypePropValue, "The VarPropTypePropValue should not be null.");

                    if (value.PropType == 0x0102 && varPropTypePropValue.PropInfo.PropID == 0x67D2)
                    {
                        // PidTagCnsetRead
                        data.PidTagCnsetRead = varPropTypePropValue.ValueArray;
                    }
                    else if (value.PropType == 0x0102 && varPropTypePropValue.PropInfo.PropID == 0x6796)
                    {
                        // PidTagCnsetSeen
                        data.PidTagCnsetSeen = varPropTypePropValue.ValueArray;
                    }
                    else if (value.PropType == 0x0102 && varPropTypePropValue.PropInfo.PropID == 0x67DA)
                    {
                        // PidTagCnsetSeenFAI
                        data.PidTagCnsetSeenFAI = varPropTypePropValue.ValueArray;
                    }
                    else if (value.PropType == 0x003 && varPropTypePropValue.PropInfo.PropID == 0x4017)
                    {
                        // PidTagIdsetGiven
                        data.PidTagIdsetGiven = varPropTypePropValue.ValueArray;
                    }
                    else
                    {
                        AdapterHelper.Site.Assert.Fail("Invalid property, its ID is {0} and type is {1}.", value.PropInfo.PropID.ToString("X4"), value.PropType.ToString("X4"));
                    }
                }

                this.icsStateContainer.Add(index, data);
                return index;
            }
            else
            {
                AdapterHelper.Site.Assert.Fail("Invalid input state, ensure the state not null and have more than one PropValue in its PropList.");
                return -1;
            }
        }
コード例 #2
0
        /// <summary>
        /// Upload of an ICS state property into the synchronization context.
        /// </summary>
        /// <param name="serverId">A 32-bit signed integer represent the Identity of server.</param>
        /// <param name="uploadContextHandleIndex">The synchronization context handle</param>
        /// <param name="icsPropertyType">Property tags of the ICS state properties.</param>
        /// <param name="isPidTagIdsetGivenInputAsInter32"> identifies Property tags as PtypInteger32.</param>
        /// <param name="icsStateIndex">The index of the ICS State.</param>
        /// <returns>The ICS state property is upload to the server successfully or not.</returns>
        public RopResult SynchronizationUploadState(int serverId, int uploadContextHandleIndex, ICSStateProperties icsPropertyType, bool isPidTagIdsetGivenInputAsInter32, int icsStateIndex)
        {
            // Initialize ROP data.
            RopResult result = RopResult.InvalidParameter;
            uint synUploadContextHandle = this.handleContainer[uploadContextHandleIndex];
            ICSStateData uploadICSState = new ICSStateData();
            if (icsStateIndex != 0)
            {
                uploadICSState = this.icsStateContainer[icsStateIndex];
            }
            else
            {
                uploadICSState.PidTagCnsetRead = new byte[0];
                uploadICSState.PidTagCnsetSeen = new byte[0];
                uploadICSState.PidTagCnsetSeenFAI = new byte[0];
                uploadICSState.PidTagIdsetGiven = new byte[0];
            }

            byte[] currentICSPropertyValue;

            // Construct ROP request.
            RopSynchronizationUploadStateStreamBeginRequest synchronizationUploadStateStreamBeginRequest;
            synchronizationUploadStateStreamBeginRequest.RopId = 0x75;
            synchronizationUploadStateStreamBeginRequest.LogonId = 0x00;
            synchronizationUploadStateStreamBeginRequest.InputHandleIndex = 0x00;
            uint stateProperty = 0;

            // propertyId and propertyTypId should be joined up. So propertyId should be move left 16 positions for propertyTypeID.
            switch (icsPropertyType)
            {
                case ICSStateProperties.PidTagCnsetRead:

                    // PidTagCnsetRead propertyId 0x67DA, propertyTypeId 0x0102
                    stateProperty = (uint)((0x67D2 << 16) | 0x0102);
                    currentICSPropertyValue = new byte[uploadICSState.PidTagCnsetRead.Length];
                    currentICSPropertyValue = uploadICSState.PidTagCnsetRead;
                    break;
                case ICSStateProperties.PidTagCnsetSeen:

                    // PidTagCnsetSeen propertyId 0x6796, propertyTypeId 0x0102
                    stateProperty = (uint)((0x6796 << 16) | 0x0102);
                    currentICSPropertyValue = new byte[uploadICSState.PidTagCnsetSeen.Length];
                    currentICSPropertyValue = uploadICSState.PidTagCnsetSeen;
                    break;
                case ICSStateProperties.PidTagCnsetSeenFAI:

                    // PidTagCnsetSeenFAI propertyId 0x67DA, propertyTypeId 0x0102
                    stateProperty = (uint)((0x67DA << 16) | 0x0102);
                    currentICSPropertyValue = new byte[uploadICSState.PidTagCnsetSeenFAI.Length];
                    currentICSPropertyValue = uploadICSState.PidTagCnsetSeenFAI;
                    break;
                case ICSStateProperties.PidTagIdsetGiven:

                    // PidTagIdsetGiven propertyId 0x4017, propertyTypeId 0x003
                    stateProperty = (uint)((0x4017 << 16) | 0x0102);
                    if (isPidTagIdsetGivenInputAsInter32)
                    {
                        stateProperty = (uint)((0x4017 << 16) | 0x0003);
                    }

                    currentICSPropertyValue = new byte[uploadICSState.PidTagIdsetGiven.Length];
                    currentICSPropertyValue = uploadICSState.PidTagIdsetGiven;
                    break;
                default:
                    currentICSPropertyValue = new byte[0];
                    break;
            }

            synchronizationUploadStateStreamBeginRequest.TransferBufferSize = (uint)currentICSPropertyValue.Length;
            synchronizationUploadStateStreamBeginRequest.StateProperty = stateProperty;

            // Send the RopSynchronizationUploadStateStreamBegin request and get response from server.
            RopSynchronizationUploadStateStreamBeginResponse synchronizationUploadStateStreamBeginResponse = (RopSynchronizationUploadStateStreamBeginResponse)this.Process(serverId, synchronizationUploadStateStreamBeginRequest, synUploadContextHandle);
            result = (RopResult)synchronizationUploadStateStreamBeginResponse.ReturnValue;

            if (result == RopResult.Success)
            {
                // Verify ROP SynchronizationUploadStateStreamBegin
                this.VerifyRopSynchronizationUploadStateStreamBegin(synchronizationUploadStateStreamBeginResponse);
                if (isPidTagIdsetGivenInputAsInter32)
                {
                    this.VerifyServerAcceptPidTagIdsetGivenPtypInteger32(result);
                }
            }
            else
            {
                return result;
            }

            // Construct the RopSynchronizationUploadStateStreamContinue request.
            RopSynchronizationUploadStateStreamContinueRequest synchronizationUploadStateStreamContinueRequest;
            synchronizationUploadStateStreamContinueRequest.RopId = 0x76;
            synchronizationUploadStateStreamContinueRequest.LogonId = 0x00;
            synchronizationUploadStateStreamContinueRequest.InputHandleIndex = 0x00;
            synchronizationUploadStateStreamContinueRequest.StreamDataSize = (uint)currentICSPropertyValue.Length;
            synchronizationUploadStateStreamContinueRequest.StreamData = currentICSPropertyValue;

            // Send the RopSynchronizationUploadStateStreamContinue request.
            RopSynchronizationUploadStateStreamContinueResponse synchronizationUploadStateStreamContinueResponse = (RopSynchronizationUploadStateStreamContinueResponse)this.Process(serverId, synchronizationUploadStateStreamContinueRequest, synUploadContextHandle);
            result = (RopResult)synchronizationUploadStateStreamContinueResponse.ReturnValue;

            if (result == RopResult.Success)
            {
                // Verify ROP SynchronizationUploadStateStreamContinue
                this.VerifyRopSynchronizationUploadStateStreamContinue(synchronizationUploadStateStreamContinueResponse);
            }
            else
            {
                return result;
            }

            // Construct the RopSynchronizationUploadStateStreamEnd request.
            RopSynchronizationUploadStateStreamEndRequest synchronizationUploadStateStreamEndRequest;
            synchronizationUploadStateStreamEndRequest.RopId = 0x77;
            synchronizationUploadStateStreamEndRequest.LogonId = 0x00;
            synchronizationUploadStateStreamEndRequest.InputHandleIndex = 0x00;

            RopSynchronizationUploadStateStreamEndResponse synchronizationUploadStateStreamEndResponse = (RopSynchronizationUploadStateStreamEndResponse)this.Process(serverId, synchronizationUploadStateStreamEndRequest, synUploadContextHandle);
            result = (RopResult)synchronizationUploadStateStreamEndResponse.ReturnValue;

            if (result == RopResult.Success)
            {
                // Verify ROP SynchronizationUploadStateStreamEnd
                this.VerifyRopSynchronizationUploadStateStreamEnd(synchronizationUploadStateStreamEndResponse);
            }

            return result;
        }