예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RigidArgs"/> struct.
 /// </summary>
 /// <param name="sourceModel"> The source model used in a rigid registration.</param>
 /// <param name="targetModel">The target model used in a rigid registration.</param>
 /// <param name="mappingAlgorithm">The point mapping algorithm used in a rigid registration.</param>
 /// <param name="numberOfIterations">The number of iterations.</param>
 public RigidArgs(Model3DFile sourceModel, Model3DFile targetModel, IPointMapping mappingAlgorithm, int numberOfIterations)
 {
     this.SourceModel        = sourceModel;
     this.TargetModel        = targetModel;
     this.MappingAlgorithm   = mappingAlgorithm;
     this.NumberOfIterations = numberOfIterations;
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RigidRegistration"/> class and sets a mapping algorithm and max number of iterations.
 /// </summary>
 /// <param name="pointMapping">The mapping algorithm.</param>
 /// <param name="numberOfIterations">The number of iterations.</param>
 public RigidRegistration(IPointMapping pointMapping, int numberOfIterations)
 {
     Log.Info("Creating rigid registration.");
     this.pointMapping       = pointMapping;
     this.rotation           = new Kabsch();
     this.numberOfIterations = numberOfIterations;
 }
예제 #3
0
        /// <summary>
        /// Read Hold Register Rely
        /// Fucntion:0x03
        /// </summary>
        /// <param name="address">40001~49999</param>
        /// <param name="count">less than 128</param>
        /// <returns></returns>
        private byte[] readHoldRegisterRely(int address, int count)
        {
            byte[] dataBuffer = new byte[count * 2];
            byte[] relyBuffer = new byte[count * 2 + 3]; //addtion SlaveId,Function,Count
            IPointMapping <ushort> _ushortMapping = _mapping as IPointMapping <ushort>;


            var ushortData = new ushort[count];

            for (int i = 0; i < count; i++)
            {
                var addressString = string.Format("{0:D5}", address + i + 1 + 40000);//地址偏移+1
                if (_mapping.Find(addressString))
                {
                    ushortData[i] = _ushortMapping.GetValue(addressString)[0];
                }
                else
                {
                    return(errorRely(FunctionCode.ReadHoldRegister, ErrorCode.LllegalDataAddress));
                };
            }
            dataBuffer = UnsafeNetConvert.UShortsToBytes(ushortData, ByteOrder.BigEndian);

            relyBuffer[0] = (byte)_salveId;
            relyBuffer[1] = (byte)FunctionCode.ReadHoldRegister;
            relyBuffer[2] = (byte)dataBuffer.Length;
            Array.Copy(dataBuffer, 0, relyBuffer, 3, dataBuffer.Length);
            return(relyBuffer);
        }
예제 #4
0
        /// <summary>
        /// byte型点注册
        /// </summary>
        /// <param name="points"></param>
        /// <param name="mapping"></param>
        public static void Register(ref PointDeviceCollcet points, IPointMapping <byte> mapping, ILog log)
        {
            List <DevicePoint <byte> > dupPoints = new List <DevicePoint <byte> >();//重复点名列表

            foreach (var point in points.BytePoints)
            {
                if (mapping.Find(point.Name))
                {
                    dupPoints.Add(point);
                    log.ErrorLog(string.Concat("Point Register Error:Duplication point name <", point.Name, ">"));
                }
                else
                {
                    mapping.Register(point.Name, point);
                }
            }
            foreach (var point in dupPoints)
            {
                points.BytePoints.Remove(point);
            }
        }