Пример #1
0
        /// <summary>
        /// Encodes a Camera Command from the given Values
        /// </summary>
        /// <param name="ObjectIdentifier">The Object to bind the PositionRefrence to</param>
        /// <param name="movementSpeed">The speed of movement requested</param>
        /// <param name="movementMode">The mode of movement requested</param>
        /// <param name="postionValue">The position amount requested</param>
        /// <returns>A Variable which contains the encoded command</returns>
        public static Variable EncodeCameraCommand(String ObjectIdentifier, byte?movementSpeed, PositionRefrence movementMode, Int32 positionValue)
        {
            //Build Object
            if (string.IsNullOrEmpty(ObjectIdentifier))
            {
                ObjectIdentifier = "1.3.6.1.4.1.1206.4.2.7.4.1";
            }
            Variable result = new Variable();

            result.Identifier = ObjectIdentifier;
            result.TypeCode   = SnmpType.OctetString;
            result.Value.Add((byte)movementMode);
            result.Value.Add((byte)movementSpeed);
            //result.Value.Add((byte)Postion);
            //result.Value.AddRange(BasicEncodingRules.EncodeInteger32(postionValue, false, false));
            //while (result.Value.Count < 4) result.Value.Add(0x00);

            if (movementMode == PositionRefrence.StopMovement || movementMode == PositionRefrence.Continious)
            {
                while (result.Value.Count < 4)
                {
                    result.Value.Add(0x00);
                }
            }
            else
            {
                //result.Value.AddRange(BitConverter.GetBytes(Convert.ToInt16(postionValue)));
                result.Value.AddRange(BasicEncodingRules.EncodeInteger32(positionValue, false, false));
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        /// Resets a DMS
        /// </summary>
        /// <param name="messengerSession">The messengerSession to perform the transaction on</param>
        /// <returns>The Variable which represents the result of the transaction</returns>
        public static Variable DmsReset(SnmpMessenger messengerSession)
        {
            Variable dmsSWReset = new Variable("1.3.6.1.4.1.1206.4.2.3.6.2");

            dmsSWReset.TypeCode = SnmpType.Integer32;
            dmsSWReset.Value    = BasicEncodingRules.EncodeInteger32(1, false, false);
            dmsSWReset          = messengerSession.Set(dmsSWReset).Bindings[0];
            return(dmsSWReset);
        }
Пример #3
0
        /// <summary>
        /// Stores the current position as the given preset number in the camera
        /// </summary>
        /// <param name="presetNumber">The presetNumber to set in the camera</param>
        /// <param name="messengerSession">The managerSession to perform the transaction on</param>
        /// <returns>The ProtocolDataUnit returned from the transaction</returns>
        public static ProtocolDataUnit StorePresetPosition(int presetNumber, SnmpMessenger messengerSession)
        {
            Variable result = new Variable("1.3.6.1.4.1.1206.4.2.7.3.2")
            {
                TypeCode = SnmpType.Integer32,
                Value    = BasicEncodingRules.EncodeInteger32(presetNumber, false, false)
            };

            return(messengerSession.Set(result));
        }
Пример #4
0
        /// <summary>
        /// Directs the DMS to perform a pixel test
        /// </summary>
        /// <param name="messengerSession">The messengerSession to perform the transaction</param>
        /// <returns>A Variable indicating the amount of rows in in the BadPixel table</returns>
        public static Variable ActivatePixelTest(SnmpMessenger messengerSession)
        {
            Variable pixelTestActivation = new Variable("1.3.6.1.4.1.1206.4.2.3.9.7.4.0");

            pixelTestActivation.TypeCode = SnmpType.Integer32;
            pixelTestActivation.Value    = BasicEncodingRules.EncodeInteger32((int)NTCIP.pixelFailureDetectionType.MessageDisplay, false, false);
            pixelTestActivation          = messengerSession.Set(pixelTestActivation).Bindings[0];

            while ((NTCIP.pixelFailureDetectionType)pixelTestActivation.ToInt32() == NTCIP.pixelFailureDetectionType.MessageDisplay)
            {
                System.Threading.Thread.Sleep(1000);
                pixelTestActivation = messengerSession.Get(pixelTestActivation.Identifier).Bindings[0];
            }

            Variable pixelFailureTableNumRows = new Variable("1.3.6.1.4.1.1206.4.2.3.9.7.2.0");

            pixelFailureTableNumRows = messengerSession.Get(pixelFailureTableNumRows.Identifier).Bindings[0];
            return(pixelFailureTableNumRows);
        }
Пример #5
0
        /// <summary>
        /// Modifies a Message in the DMS
        /// </summary>
        /// <param name="multiString">The new value for the multiString</param>
        /// <param name="priority">The new priority for the multiString</param>
        /// <param name="messageNumber">The messageNumber to modify</param>
        /// <param name="messageMemoryType">The type of memory to store multiString in</param>
        /// <param name="messengerSession">The messengerSession to perform the request on</param>
        /// <returns>The Crc16 of the Modified Message</returns>
        public static UInt32 ModifyMessage(String multiString, String owner, byte?priority, byte?messageNumber, dmsMessageMemoryType?messageMemoryType, SnmpMessenger messengerSession)
        {
            messageMemoryType = messageMemoryType.HasValue ? messageMemoryType.Value : dmsMessageMemoryType.Changeable;
            messageNumber     = messageNumber.HasValue ? messageNumber.Value : (byte)1;
            priority          = priority.HasValue ? priority.Value : (byte)255;
            if (string.IsNullOrEmpty(owner))
            {
                owner = Environment.MachineName;
            }

            string oidPrefix  = "1.3.6.1.4.1.1206.4.2.3.5.8.1.";
            string oidPostfix = "." + (int)messageMemoryType + "." + messageNumber.ToString();

            //Variable dmsMessageStatus = messengerSession.Get("1.3.6.1.4.1.1206.4.2.3.5.8.1.5.3.1").Bindings[0];
            Variable dmsMessageStatus = messengerSession.Get(oidPrefix + (int)DmsMessageEntry.dmsMessageStatus + oidPostfix).Bindings[0];

            if ((NTCIP.dmsMessageStatus)dmsMessageStatus.ToInt32() != NTCIP.dmsMessageStatus.NotUsed
                &&
                (NTCIP.dmsMessageStatus)dmsMessageStatus.ToInt32() != NTCIP.dmsMessageStatus.NotUsedReq)
            {
                dmsMessageStatus.Value = BasicEncodingRules.EncodeInteger32((int)NTCIP.dmsMessageStatus.NotUsedReq, false, false);
                dmsMessageStatus       = messengerSession.Set(dmsMessageStatus).Bindings[0];
            }

            dmsMessageStatus.Value = BasicEncodingRules.EncodeInteger32((int)NTCIP.dmsMessageStatus.ModifyReq, false, false);
            dmsMessageStatus       = messengerSession.Set(dmsMessageStatus).Bindings[0];

            int attempt = 0;

            //standards....
            while ((NTCIP.dmsMessageStatus)dmsMessageStatus.ToInt32() != NTCIP.dmsMessageStatus.Modifying
                   &&
                   (NTCIP.dmsMessageStatus)dmsMessageStatus.ToInt32() != NTCIP.dmsMessageStatus.ModifyReq &&
                   attempt <= messengerSession.MaxRetries)
            {
                dmsMessageStatus = messengerSession.Get(dmsMessageStatus.Identifier).Bindings[0];
                attempt++;
            }

            Variable dmsMessageMultiString = new Variable();

            dmsMessageMultiString.Identifier = oidPrefix + (int)DmsMessageEntry.dmsMessageMultiString + oidPostfix;
            dmsMessageMultiString.TypeCode   = SnmpType.OctetString;
            dmsMessageMultiString.Value      = BasicEncodingRules.EncodeOctetString(multiString, false, false);

            Variable dmsMessageOwner = new Variable();

            dmsMessageOwner.Identifier = oidPrefix + (int)DmsMessageEntry.dmsMessageOwner + oidPostfix;
            dmsMessageOwner.TypeCode   = SnmpType.OctetString;
            dmsMessageOwner.Value      = BasicEncodingRules.EncodeOctetString(owner, false, false);

            Variable dmsMessageRunTimePriority = new Variable();

            dmsMessageRunTimePriority.Identifier = oidPrefix + (int)DmsMessageEntry.dmsMessageRunTimePriority + oidPostfix;
            dmsMessageRunTimePriority.TypeCode   = SnmpType.Integer32;
            dmsMessageRunTimePriority.Value      = BasicEncodingRules.EncodeInteger32(priority.Value, false, false);

            dmsMessageMultiString     = messengerSession.Set(dmsMessageMultiString).Bindings[0];
            dmsMessageOwner           = messengerSession.Set(dmsMessageOwner).Bindings[0];
            dmsMessageRunTimePriority = messengerSession.Set(dmsMessageRunTimePriority).Bindings[0];

            dmsMessageStatus.Value = BasicEncodingRules.EncodeInteger32((int)NTCIP.dmsMessageStatus.ValidateReq, false, false);

            dmsMessageStatus = messengerSession.Set(dmsMessageStatus).Bindings[0];

            while ((NTCIP.dmsMessageStatus)dmsMessageStatus.ToInt32() == NTCIP.dmsMessageStatus.Validating
                   ||
                   (NTCIP.dmsMessageStatus)dmsMessageStatus.ToInt32() == NTCIP.dmsMessageStatus.ValidateReq ||
                   dmsMessageStatus.ToInt32() == 255)
            {
                dmsMessageStatus = messengerSession.Get(dmsMessageStatus.Identifier).Bindings[0];
            }

            //Should check if valid here and if not valid get the reason why its not valid and report.
            if ((NTCIP.dmsMessageStatus)dmsMessageStatus.ToInt32() != NTCIP.dmsMessageStatus.Valid)
            {
                //needs steps here to determine error and return
                System.Threading.Thread.Sleep(0);
            }

            Variable dmsMessageCRC = new Variable();

            dmsMessageCRC.Identifier = oidPrefix + (int)DmsMessageEntry.dmsMessageCRC + oidPostfix;
            dmsMessageCRC            = messengerSession.Get(dmsMessageCRC.Identifier).Bindings[0];

            return(dmsMessageCRC.ToUInt32());
        }