Beispiel #1
0
        public MapleStream(bool pOutbound, ushort pBuild, byte pLocale, byte[] pIV, byte pSubVersion, bool pLoginServer)
        {
            mOutbound     = pOutbound;
            Build         = pBuild;
            Locale        = pLocale;
            isLoginServer = pLoginServer;

            if (mOutbound)
            {
                mAES = new MapleAES(Build, Locale, pIV, pSubVersion);
            }
            else
            {
                mAES = new MapleAES((ushort)(0xFFFF - Build), Locale, pIV, pSubVersion);
            }

            if ((Locale == MapleLocale.TESPIA && Build == 40) ||
                (Locale == MapleLocale.SOUTH_EAST_ASIA && Build == 15))
            {
                // WvsBeta
                _transformMethod = TransformMethod.MAPLE_CRYPTO | TransformMethod.SHIFT_IV;
                _usesByteHeader  = true;
            }
            else if (Locale == MapleLocale.KOREA_TEST && Build == 255)
            {
                // KMSB (Modified client)
                _transformMethod = TransformMethod.OLD_KMS_CRYPTO | TransformMethod.SHIFT_IV_OLD;
                _usesByteHeader  = true;
                _usesOldHeader   = true;
            }
            else if (
                Locale == MapleLocale.TAIWAN ||
                Locale == MapleLocale.CHINA ||
                Locale == MapleLocale.TESPIA ||
                Locale == MapleLocale.JAPAN ||
                (Locale == MapleLocale.GLOBAL && (short)Build >= 149 && (short)Build < 193) ||
                (Locale == MapleLocale.KOREA && Build >= 221) ||
                (Locale == MapleLocale.SOUTH_EAST_ASIA && Build >= 144) ||
                (Locale == MapleLocale.EUROPE && Build >= 115))
            {
                // TWMS / CMS / CMST / JMS / GMS (>= 149)
                _transformMethod = TransformMethod.AES | TransformMethod.SHIFT_IV | TransformMethod.GMS_NEW;
            }
            else if (Locale == MapleLocale.KOREA || Locale == MapleLocale.KOREA_TEST)
            {
                // KMS / KMST
                _transformMethod = TransformMethod.KMS_CRYPTO;
            }
            else if (Locale == MapleLocale.GLOBAL && (short)Build >= 193)
            {
                _transformMethod = TransformMethod.AES | TransformMethod.SHIFT_IV | TransformMethod.GMS_NEW;
            }
            else
            {
                // All others lol
                _transformMethod = TransformMethod.AES | TransformMethod.MAPLE_CRYPTO | TransformMethod.SHIFT_IV;
            }

            Console.WriteLine("Using transform methods: {0}", _transformMethod);
        }
Beispiel #2
0
 /// <summary>
 /// DatumTranformStage constructor for a gridshift transform
 /// </summary>
 public DatumTransformStage(string strFrom, string strTo, Spheroid sphFrom, Spheroid sphTo, string strTableName, bool bApplyTableInv)
 {
     From          = strFrom;
     To            = strTo;
     FromSph       = sphFrom;
     ToSph         = sphTo;
     Tm            = TransformMethod.GridShift;
     TableName     = strTableName;
     ApplyTableInv = bApplyTableInv;
 }
Beispiel #3
0
 /// <summary>
 /// DatumTranformStage constructor for a geocentric transform
 /// </summary>
 public DatumTransformStage(string strFrom, string strTo, Spheroid sphFrom, Spheroid sphTo, double dx, double dy, double dz)
 {
     From    = strFrom;
     To      = strTo;
     FromSph = sphFrom;
     ToSph   = sphTo;
     Dx      = dx;
     Dy      = dy;
     Dz      = dz;
     Tm      = TransformMethod.Param3;
 }
Beispiel #4
0
        private void Changes(TransformMethod transform)
        {
            transform(trackBar_W.Value, trackBar_H.Value, trackBar_Y.Value, trackBar_X.Value, rotate_trackBar.Value);

            form.pictureBox.Refresh();

            if (!changes_checkBox.Checked)
            {
                Layers.CurrentLayer.Foreground.ApplyChangesTransform();
                form.pictureBox.Image = Layers.CurrentLayer.Foreground.EditImage;
                form.PreviewSizeChange();
            }
        }
Beispiel #5
0
        public MapleStream(bool pOutbound, ushort pBuild, byte pLocale, byte[] pIV, byte pSubVersion)
        {
            mOutbound = pOutbound;
            Build = pBuild;
            Locale = pLocale;

            if (mOutbound)
                mAES = new MapleAES(Build, Locale, pIV, pSubVersion);
            else
                mAES = new MapleAES((ushort)(0xFFFF - Build), Locale, pIV, pSubVersion);

            if ((Locale == MapleLocale.TESPIA && Build == 40) ||
                (Locale == MapleLocale.SOUTH_EAST_ASIA && Build == 15))
            {
                // WvsBeta
                _transformMethod = TransformMethod.MAPLE_CRYPTO | TransformMethod.SHIFT_IV;
                _usesByteHeader = true;
            }
            else if (Locale == MapleLocale.KOREA_TEST && Build == 255)
            {
                // KMSB (Modified client)
                _transformMethod = TransformMethod.OLD_KMS_CRYPTO | TransformMethod.SHIFT_IV_OLD;
                _usesByteHeader = true;
                _usesOldHeader = true;
            }
            else if (
                Locale == MapleLocale.TAIWAN ||
                Locale == MapleLocale.CHINA ||
                Locale == MapleLocale.TESPIA ||
                Locale == MapleLocale.JAPAN ||
                (Locale == MapleLocale.GLOBAL && (short)Build >= 149) ||
                (Locale == MapleLocale.KOREA && Build >= 221) ||
                (Locale == MapleLocale.SOUTH_EAST_ASIA && Build >= 144) ||
                (Locale == MapleLocale.EUROPE && Build >= 115))
            {
                // TWMS / CMS / CMST / JMS / GMS (>= 149)
                _transformMethod = TransformMethod.AES | TransformMethod.SHIFT_IV;
            }
            else if (Locale == MapleLocale.KOREA || Locale == MapleLocale.KOREA_TEST)
            {
                // KMS / KMST
                _transformMethod = TransformMethod.KMS_CRYPTO;
            }
            else
            {
                // All others lol
                _transformMethod = TransformMethod.AES | TransformMethod.MAPLE_CRYPTO | TransformMethod.SHIFT_IV;
            }

            Console.WriteLine("Using transform methods: {0}", _transformMethod);
        }
Beispiel #6
0
 /// <summary>
 /// DatumTranformStage constructor for a 7-parameter transform
 /// </summary>
 public DatumTransformStage(string strFrom, string strTo, Spheroid sphFrom, Spheroid sphTo, double dx, double dy, double dz, double rx, double ry, double rz, double ds)
 {
     From    = strFrom;
     To      = strTo;
     FromSph = sphFrom;
     ToSph   = sphTo;
     Tm      = TransformMethod.Param7;
     Dx      = dx;
     Dy      = dy;
     Dz      = dz;
     Rx      = rx;
     Ry      = ry;
     Rz      = rz;
     Ds      = ds;
 }
Beispiel #7
0
        private static List <string> RetrieveSource(TransformMethod method, bool debugMode, out byte[] rsaBlob, out string token)
        {
            return(new List <string>()
            {
                RetrieveFileText("DeviceInfo.txt"),
                RetrieveFileText("DeviceType.txt"),
                RetrieveFileText("MachineInformation.txt"),

                //Replace values in validator text
                method.Replace(RetrieveFileText("Validator.txt"),
                               RetrieveFileText("TokenGeneration.txt"),
                               RetrieveFileBytes("KnownHash.txt"),
                               debugMode,
                               out rsaBlob, out token)
            });
        }
Beispiel #8
0
        static void Transform()
        {
            var list = new List <int> {
                1, 2, 3, 4, 5
            };

            var method = new TransformMethod();

            method.SetStrategy(new DoubleTransform());
            method.SetList(list);
            Console.WriteLine(string.Join(", ", method.Transform()));

            method.SetStrategy(new PowerTransform(2));
            method.SetList(list);
            Console.WriteLine(string.Join(", ", method.Transform()));
        }
Beispiel #9
0
 /// <summary>
 /// DatumTransfromStage copy constructor
 /// </summary>
 /// <param name="dts"></param>
 public DatumTransformStage(DatumTransformStage dts)
 {
     From          = dts.From;
     To            = dts.To;
     FromSph       = dts.FromSph;
     ToSph         = dts.ToSph;
     Tm            = dts.Tm;
     Dx            = dts.Dx;
     Dy            = dts.Dy;
     Dz            = dts.Dz;
     Rx            = dts.Rx;
     Ry            = dts.Ry;
     Rz            = dts.Rz;
     Ds            = dts.Ds;
     TableName     = dts.TableName;
     ApplyTableInv = dts.ApplyTableInv;
 }
Beispiel #10
0
 //Constructor
 public TexDesc()
 {
     unchecked {
         image               = null;
         source              = null;
         clampMode           = TexClampMode.WRAP_S_WRAP_T;
         filterMode          = TexFilterMode.FILTER_TRILERP;
         flags               = (ushort)0;
         maxAnisotropy       = (ushort)0;
         uvSet               = (uint)0;
         ps2L                = (short)0;
         ps2K                = (short)-75;
         unknown1            = (ushort)0;
         hasTextureTransform = false;
         scale               = 1.0, 1.0;
         rotation            = 0.0f;
         transformMethod     = (TransformMethod)0;
     }
 }
        private void Decrypt(byte[] pBuffer, ushort pBuild, byte pLocale, TransformMethod pTransformLocale)
        {
            if ((pTransformLocale & TransformMethod.AES) != 0) mAES.TransformAES(pBuffer);

            if ((pTransformLocale & TransformMethod.MAPLE_CRYPTO) != 0)
            {
                for (int index1 = 1; index1 <= 6; ++index1)
                {
                    byte firstFeedback = 0;
                    byte secondFeedback = 0;
                    byte length = (byte)(pBuffer.Length & 0xFF);
                    if ((index1 % 2) == 0)
                    {
                        for (int index2 = 0; index2 < pBuffer.Length; ++index2)
                        {
                            byte temp = pBuffer[index2];
                            temp -= 0x48;
                            temp = (byte)(~temp);
                            temp = RollLeft(temp, length & 0xFF);
                            secondFeedback = temp;
                            temp ^= firstFeedback;
                            firstFeedback = secondFeedback;
                            temp -= length;
                            temp = RollRight(temp, 3);
                            pBuffer[index2] = temp;
                            --length;
                        }
                    }
                    else
                    {
                        for (int index2 = pBuffer.Length - 1; index2 >= 0; --index2)
                        {
                            byte temp = pBuffer[index2];
                            temp = RollLeft(temp, 3);
                            temp ^= 0x13;
                            secondFeedback = temp;
                            temp ^= firstFeedback;
                            firstFeedback = secondFeedback;
                            temp -= length;
                            temp = RollRight(temp, 4);
                            pBuffer[index2] = temp;
                            --length;
                        }
                    }
                }
            }

            if ((pTransformLocale & TransformMethod.KMS_CRYPTO) != 0) mAES.TransformKMS(pBuffer);
            if ((pTransformLocale & TransformMethod.OLD_KMS_CRYPTO) != 0) mAES.TransformOldKMS(pBuffer);

            if ((pTransformLocale & TransformMethod.SHIFT_IV) != 0) mAES.ShiftIV();
            if ((pTransformLocale & TransformMethod.SHIFT_IV_OLD) != 0) mAES.ShiftIVOld();
        }
        public override void WriteJson(JsonWriter writer,
                                       object untypedValue,
                                       JsonSerializer serializer)
        {
            if (untypedValue == null)
            {
                serializer.Serialize(writer,
                                     null);

                return;
            }

            TransformMethod value = (TransformMethod)untypedValue;

            switch (value)
            {
            case TransformMethod.Exp:
                serializer.Serialize(writer,
                                     "exp");

                return;

            case TransformMethod.Linear:
                serializer.Serialize(writer,
                                     "linear");

                return;

            case TransformMethod.Log:
                serializer.Serialize(writer,
                                     "log");

                return;

            case TransformMethod.Max:
                serializer.Serialize(writer,
                                     "max");

                return;

            case TransformMethod.Mean:
                serializer.Serialize(writer,
                                     "mean");

                return;

            case TransformMethod.Median:
                serializer.Serialize(writer,
                                     "median");

                return;

            case TransformMethod.Min:
                serializer.Serialize(writer,
                                     "min");

                return;

            case TransformMethod.Poly:
                serializer.Serialize(writer,
                                     "poly");

                return;

            case TransformMethod.Pow:
                serializer.Serialize(writer,
                                     "pow");

                return;

            case TransformMethod.Quad:
                serializer.Serialize(writer,
                                     "quad");

                return;

            case TransformMethod.Value:
                serializer.Serialize(writer,
                                     "value");

                return;
            }

            throw new Exception("Cannot marshal type TransformMethod");
        }
        public IChannel BaseChannelConvert(I_BaseChannelInfo t_channel)
        {
            #region IEPEChannelInfo
            if (t_channel is T1_IEPEChannelInfo)
            {
                T1_IEPEChannelInfo channel          = t_channel as T1_IEPEChannelInfo;
                IEPEChannelInfo    i_channel        = new IEPEChannelInfo();
                CalibrationlInfo   calibrationlInfo = JsonConvert.DeserializeObject <CalibrationlInfo>(channel.CalibrationlInfo);
                i_channel.VelocityCalibration     = calibrationlInfo.VelocityCalibration;
                i_channel.DisplacementCalibration = calibrationlInfo.DisplacementCalibration;
                OtherInfo otherInfo = JsonConvert.DeserializeObject <OtherInfo>(channel.OtherInfo);
                i_channel.RPMCardNum        = otherInfo.RPMCardNum;
                i_channel.RPMSlotNum        = otherInfo.RPMSlotNum;
                i_channel.RPMCHNum          = otherInfo.RPMCHNum;
                i_channel.IsMultiplication  = otherInfo.IsMultiplication;
                i_channel.MultiplicationCor = otherInfo.MultiplicationCor;
                i_channel.IsSaveWaveToSD    = otherInfo.IsSaveWaveToSD;
                i_channel.IsUploadWave      = otherInfo.IsUploadWave;
                i_channel.DefaultRPM        = otherInfo.DefaultRPM;
                VibrationAddition vibrationAddition = JsonConvert.DeserializeObject <VibrationAddition>(channel.VibrationAddition);
                i_channel.TPDirCategory = vibrationAddition.TPDirCategory;
                i_channel.TPDirCode     = vibrationAddition.TPDirCode;
                i_channel.BiasVoltHigh  = vibrationAddition.BiasVoltHigh;
                i_channel.BiasVoltLow   = vibrationAddition.BiasVoltLow;
                i_channel.Sensitivity   = vibrationAddition.Sensitivity;

                i_channel.T_IEPEChannelInfo = channel;
                return(i_channel);
            }
            #endregion

            #region EddyCurrentDisplacementChannelInfo
            if (t_channel is T1_EddyCurrentDisplacementChannelInfo)
            {
                T1_EddyCurrentDisplacementChannelInfo channel   = t_channel as T1_EddyCurrentDisplacementChannelInfo;
                EddyCurrentDisplacementChannelInfo    i_channel = new EddyCurrentDisplacementChannelInfo();
                OtherInfo otherInfo = JsonConvert.DeserializeObject <OtherInfo>(channel.OtherInfo);
                i_channel.RPMCardNum        = otherInfo.RPMCardNum;
                i_channel.RPMSlotNum        = otherInfo.RPMSlotNum;
                i_channel.RPMCHNum          = otherInfo.RPMCHNum;
                i_channel.IsMultiplication  = otherInfo.IsMultiplication;
                i_channel.MultiplicationCor = otherInfo.MultiplicationCor;
                i_channel.IsSaveWaveToSD    = otherInfo.IsSaveWaveToSD;
                i_channel.IsUploadWave      = otherInfo.IsUploadWave;
                i_channel.DefaultRPM        = otherInfo.DefaultRPM;
                VibrationAddition vibrationAddition = JsonConvert.DeserializeObject <VibrationAddition>(channel.VibrationAddition);
                i_channel.TPDirCategory = vibrationAddition.TPDirCategory;
                i_channel.TPDirCode     = vibrationAddition.TPDirCode;
                i_channel.BiasVoltHigh  = vibrationAddition.BiasVoltHigh;
                i_channel.BiasVoltLow   = vibrationAddition.BiasVoltLow;
                i_channel.Sensitivity   = vibrationAddition.Sensitivity;

                i_channel.T_EddyCurrentDisplacementChannelInfo = channel;
                return(i_channel);
            }
            #endregion

            #region EddyCurrentKeyPhaseChannelInfo
            if (t_channel is T1_EddyCurrentKeyPhaseChannelInfo)
            {
                T1_EddyCurrentKeyPhaseChannelInfo channel   = t_channel as T1_EddyCurrentKeyPhaseChannelInfo;
                EddyCurrentKeyPhaseChannelInfo    i_channel = new EddyCurrentKeyPhaseChannelInfo();
                ThresholdInfo thresholdInfo = JsonConvert.DeserializeObject <ThresholdInfo>(channel.ThresholdInfo);
                i_channel.ThresholdVolt         = thresholdInfo.ThresholdVolt;
                i_channel.HysteresisVolt        = thresholdInfo.HysteresisVolt;
                i_channel.ThresholdModeCategory = thresholdInfo.ThresholdModeCategory;
                i_channel.ThresholdModeCode     = thresholdInfo.ThresholdModeCode;
                VibrationAddition vibrationAddition = JsonConvert.DeserializeObject <VibrationAddition>(channel.VibrationAddition);
                i_channel.TPDirCategory = vibrationAddition.TPDirCategory;
                i_channel.TPDirCode     = vibrationAddition.TPDirCode;
                i_channel.BiasVoltHigh  = vibrationAddition.BiasVoltHigh;
                i_channel.BiasVoltLow   = vibrationAddition.BiasVoltLow;
                i_channel.Sensitivity   = vibrationAddition.Sensitivity;
                RPMChannelInfo rPMChannelInfo = JsonConvert.DeserializeObject <RPMChannelInfo>(channel.RPMChannelInfo);
                i_channel.CalibrationCor = rPMChannelInfo.CalibrationCor;
                i_channel.IsNotch        = rPMChannelInfo.IsNotch;
                i_channel.AverageNumber  = rPMChannelInfo.AverageNumber;
                i_channel.TeethNumber    = rPMChannelInfo.TeethNumber;

                i_channel.T_EddyCurrentKeyPhaseChannelInfo = channel;
                return(i_channel);
            }
            #endregion

            #region EddyCurrentTachometerChannelInfo
            if (t_channel is T1_EddyCurrentTachometerChannelInfo)
            {
                T1_EddyCurrentTachometerChannelInfo channel   = t_channel as T1_EddyCurrentTachometerChannelInfo;
                EddyCurrentTachometerChannelInfo    i_channel = new EddyCurrentTachometerChannelInfo();
                ThresholdInfo thresholdInfo = JsonConvert.DeserializeObject <ThresholdInfo>(channel.ThresholdInfo);
                i_channel.ThresholdVolt         = thresholdInfo.ThresholdVolt;
                i_channel.HysteresisVolt        = thresholdInfo.HysteresisVolt;
                i_channel.ThresholdModeCategory = thresholdInfo.ThresholdModeCategory;
                i_channel.ThresholdModeCode     = thresholdInfo.ThresholdModeCode;
                VibrationAddition vibrationAddition = JsonConvert.DeserializeObject <VibrationAddition>(channel.VibrationAddition);
                i_channel.TPDirCategory = vibrationAddition.TPDirCategory;
                i_channel.TPDirCode     = vibrationAddition.TPDirCode;
                i_channel.BiasVoltHigh  = vibrationAddition.BiasVoltHigh;
                i_channel.BiasVoltLow   = vibrationAddition.BiasVoltLow;
                i_channel.Sensitivity   = vibrationAddition.Sensitivity;
                RPMChannelInfo rPMChannelInfo = JsonConvert.DeserializeObject <RPMChannelInfo>(channel.RPMChannelInfo);
                i_channel.CalibrationCor = rPMChannelInfo.CalibrationCor;
                i_channel.IsNotch        = rPMChannelInfo.IsNotch;
                i_channel.AverageNumber  = rPMChannelInfo.AverageNumber;
                i_channel.TeethNumber    = rPMChannelInfo.TeethNumber;
                RPMCouplingInfo rPMCouplingInfo = JsonConvert.DeserializeObject <RPMCouplingInfo>(channel.RPMCouplingInfo);
                i_channel.RPMCouplingCategory = rPMCouplingInfo.RPMCouplingCategory;
                i_channel.RPMCouplingCode     = rPMCouplingInfo.RPMCouplingCode;

                i_channel.T_EddyCurrentTachometerChannelInfo = channel;
                return(i_channel);
            }
            #endregion

            #region DigitTachometerChannelInfo
            if (t_channel is T1_DigitTachometerChannelInfo)
            {
                T1_DigitTachometerChannelInfo channel   = t_channel as T1_DigitTachometerChannelInfo;
                DigitTachometerChannelInfo    i_channel = new DigitTachometerChannelInfo();
                RPMChannelInfo rPMChannelInfo           = JsonConvert.DeserializeObject <RPMChannelInfo>(channel.RPMChannelInfo);
                i_channel.CalibrationCor = rPMChannelInfo.CalibrationCor;
                i_channel.IsNotch        = rPMChannelInfo.IsNotch;
                i_channel.AverageNumber  = rPMChannelInfo.AverageNumber;
                i_channel.TeethNumber    = rPMChannelInfo.TeethNumber;

                i_channel.T_DigitTachometerChannelInfo = channel;
                return(i_channel);
            }
            #endregion

            #region AnalogRransducerInChannelInfo
            if (t_channel is T1_AnalogRransducerInChannelInfo)
            {
                T1_AnalogRransducerInChannelInfo channel   = t_channel as T1_AnalogRransducerInChannelInfo;
                AnalogRransducerInChannelInfo    i_channel = new AnalogRransducerInChannelInfo();
                TransformMethod transformMethod            = JsonConvert.DeserializeObject <TransformMethod>(channel.TransformMethod);
                i_channel.EquationCategory = transformMethod.EquationCategory;
                i_channel.EquationCode     = transformMethod.EquationCode;

                i_channel.T_AnalogRransducerInChannelInfo = channel;
                return(i_channel);
            }
            #endregion

            #region RelayChannelInfo
            if (t_channel is T1_RelayChannelInfo)
            {
                T1_RelayChannelInfo channel   = t_channel as T1_RelayChannelInfo;
                RelayChannelInfo    i_channel = new RelayChannelInfo();

                i_channel.T_RelayChannelInfo = channel;
                return(i_channel);
            }
            #endregion

            #region DigitRransducerInChannelInfo
            if (t_channel is T1_DigitRransducerInChannelInfo)
            {
                T1_DigitRransducerInChannelInfo channel   = t_channel as T1_DigitRransducerInChannelInfo;
                DigitRransducerInChannelInfo    i_channel = new DigitRransducerInChannelInfo();
                TransformMethod transformMethod           = JsonConvert.DeserializeObject <TransformMethod>(channel.TransformMethod);
                i_channel.EquationCategory = transformMethod.EquationCategory;
                i_channel.EquationCode     = transformMethod.EquationCode;
                DigitRransducerInfo digitRransducerInfo = JsonConvert.DeserializeObject <DigitRransducerInfo>(channel.DigitRransducerInfo);
                digitRransducerInfo.SwitchCategory    = digitRransducerInfo.SwitchCategory;
                digitRransducerInfo.SwitchCode        = digitRransducerInfo.SwitchCode;
                digitRransducerInfo.ModBusFunCategory = digitRransducerInfo.ModBusFunCategory;
                digitRransducerInfo.ModBusFunCode     = digitRransducerInfo.ModBusFunCode;

                i_channel.T_DigitRransducerInChannelInfo = channel;
                return(i_channel);
            }
            #endregion

            #region DigitRransducerOutChannelInfo
            if (t_channel is T1_DigitRransducerOutChannelInfo)
            {
                T1_DigitRransducerOutChannelInfo channel   = t_channel as T1_DigitRransducerOutChannelInfo;
                DigitRransducerOutChannelInfo    i_channel = new DigitRransducerOutChannelInfo();
                TransformMethod transformMethod            = JsonConvert.DeserializeObject <TransformMethod>(channel.TransformMethod);
                i_channel.EquationCategory = transformMethod.EquationCategory;
                i_channel.EquationCode     = transformMethod.EquationCode;
                DigitRransducerInfo digitRransducerInfo = JsonConvert.DeserializeObject <DigitRransducerInfo>(channel.DigitRransducerInfo);
                digitRransducerInfo.SwitchCategory    = digitRransducerInfo.SwitchCategory;
                digitRransducerInfo.SwitchCode        = digitRransducerInfo.SwitchCode;
                digitRransducerInfo.ModBusFunCategory = digitRransducerInfo.ModBusFunCategory;
                digitRransducerInfo.ModBusFunCode     = digitRransducerInfo.ModBusFunCode;
                SourceChannelInfo sourceChannelInfo = JsonConvert.DeserializeObject <SourceChannelInfo>(channel.SourceChannelInfo);
                i_channel.SourceCardNum  = sourceChannelInfo.SourceCardNum;
                i_channel.SourceSlotNum  = sourceChannelInfo.SourceSlotNum;
                i_channel.SourceCHNum    = sourceChannelInfo.SourceCHNum;
                i_channel.SourceSubCHNum = sourceChannelInfo.SourceSubCHNum;

                i_channel.T_DigitRransducerOutChannelInfo = channel;
                return(i_channel);
            }
            #endregion

            #region AnalogRransducerOutChannelInfo
            if (t_channel is T1_AnalogRransducerOutChannelInfo)
            {
                T1_AnalogRransducerOutChannelInfo channel   = t_channel as T1_AnalogRransducerOutChannelInfo;
                AnalogRransducerOutChannelInfo    i_channel = new AnalogRransducerOutChannelInfo();
                TransformMethod transformMethod             = JsonConvert.DeserializeObject <TransformMethod>(channel.TransformMethod);
                i_channel.EquationCategory = transformMethod.EquationCategory;
                i_channel.EquationCode     = transformMethod.EquationCode;
                SourceChannelInfo sourceChannelInfo = JsonConvert.DeserializeObject <SourceChannelInfo>(channel.SourceChannelInfo);
                i_channel.SourceCardNum  = sourceChannelInfo.SourceCardNum;
                i_channel.SourceSlotNum  = sourceChannelInfo.SourceSlotNum;
                i_channel.SourceCHNum    = sourceChannelInfo.SourceCHNum;
                i_channel.SourceSubCHNum = sourceChannelInfo.SourceSubCHNum;

                i_channel.T_AnalogRransducerOutChannelInfo = channel;
                return(i_channel);
            }
            #endregion

            #region WirelessScalarChannelInfo
            if (t_channel is T1_WirelessScalarChannelInfo)
            {
                T1_WirelessScalarChannelInfo channel   = t_channel as T1_WirelessScalarChannelInfo;
                WirelessScalarChannelInfo    i_channel = new WirelessScalarChannelInfo();
                TransformMethod transformMethod        = JsonConvert.DeserializeObject <TransformMethod>(channel.TransformMethod);
                i_channel.EquationCategory = transformMethod.EquationCategory;
                i_channel.EquationCode     = transformMethod.EquationCode;

                i_channel.T_WirelessScalarChannelInfo = channel;
                return(i_channel);
            }
            #endregion

            #region WirelessVibrationChannelInfo
            if (t_channel is T1_WirelessVibrationChannelInfo)
            {
                T1_WirelessVibrationChannelInfo channel   = t_channel as T1_WirelessVibrationChannelInfo;
                WirelessVibrationChannelInfo    i_channel = new WirelessVibrationChannelInfo();
                CalibrationlInfo calibrationlInfo         = JsonConvert.DeserializeObject <CalibrationlInfo>(channel.CalibrationlInfo);
                i_channel.VelocityCalibration     = calibrationlInfo.VelocityCalibration;
                i_channel.DisplacementCalibration = calibrationlInfo.DisplacementCalibration;
                OtherInfo otherInfo = JsonConvert.DeserializeObject <OtherInfo>(channel.OtherInfo);
                i_channel.RPMCardNum        = otherInfo.RPMCardNum;
                i_channel.RPMSlotNum        = otherInfo.RPMSlotNum;
                i_channel.RPMCHNum          = otherInfo.RPMCHNum;
                i_channel.IsMultiplication  = otherInfo.IsMultiplication;
                i_channel.MultiplicationCor = otherInfo.MultiplicationCor;
                i_channel.IsSaveWaveToSD    = otherInfo.IsSaveWaveToSD;
                i_channel.IsUploadWave      = otherInfo.IsUploadWave;
                i_channel.DefaultRPM        = otherInfo.DefaultRPM;
                VibrationAddition vibrationAddition = JsonConvert.DeserializeObject <VibrationAddition>(channel.VibrationAddition);
                i_channel.TPDirCategory = vibrationAddition.TPDirCategory;
                i_channel.TPDirCode     = vibrationAddition.TPDirCode;
                i_channel.BiasVoltHigh  = vibrationAddition.BiasVoltHigh;
                i_channel.BiasVoltLow   = vibrationAddition.BiasVoltLow;
                i_channel.Sensitivity   = vibrationAddition.Sensitivity;

                i_channel.T_WirelessVibrationChannelInfo = channel;
                return(i_channel);
            }
            #endregion
            return(null);
        }
Beispiel #14
0
        private void Decrypt(byte[] pBuffer, TransformMethod pTransformLocale)
        {
            if ((pTransformLocale & TransformMethod.AES) != 0)
            {
                mAES.TransformAES(pBuffer);
            }

            if ((pTransformLocale & TransformMethod.MAPLE_CRYPTO) != 0)
            {
                for (int index1 = 1; index1 <= 6; ++index1)
                {
                    byte firstFeedback  = 0;
                    byte secondFeedback = 0;
                    byte length         = (byte)(pBuffer.Length & 0xFF);
                    if ((index1 % 2) == 0)
                    {
                        for (int index2 = 0; index2 < pBuffer.Length; ++index2)
                        {
                            byte temp = pBuffer[index2];
                            temp           -= 0x48;
                            temp            = (byte)(~temp);
                            temp            = RollLeft(temp, length & 0xFF);
                            secondFeedback  = temp;
                            temp           ^= firstFeedback;
                            firstFeedback   = secondFeedback;
                            temp           -= length;
                            temp            = RollRight(temp, 3);
                            pBuffer[index2] = temp;
                            --length;
                        }
                    }
                    else
                    {
                        for (int index2 = pBuffer.Length - 1; index2 >= 0; --index2)
                        {
                            byte temp = pBuffer[index2];
                            temp            = RollLeft(temp, 3);
                            temp           ^= 0x13;
                            secondFeedback  = temp;
                            temp           ^= firstFeedback;
                            firstFeedback   = secondFeedback;
                            temp           -= length;
                            temp            = RollRight(temp, 4);
                            pBuffer[index2] = temp;
                            --length;
                        }
                    }
                }
            }

            if ((pTransformLocale & TransformMethod.KMS_CRYPTO) != 0)
            {
                mAES.TransformKMS(pBuffer);
            }
            if ((pTransformLocale & TransformMethod.OLD_KMS_CRYPTO) != 0)
            {
                mAES.TransformOldKMS(pBuffer);
            }

            if ((pTransformLocale & TransformMethod.SHIFT_IV) != 0)
            {
                mAES.ShiftIV();
            }
            if ((pTransformLocale & TransformMethod.SHIFT_IV_OLD) != 0)
            {
                mAES.ShiftIVOld();
            }
        }
 /// <summary>
 /// DatumTranformStage constructor for a geocentric transform
 /// </summary>
 public DatumTransformStage(string strFrom, string strTo, Spheroid sphFrom, Spheroid sphTo, double dx, double dy, double dz)
 {
     From = strFrom;
     To = strTo;
     FromSph = sphFrom;
     ToSph = sphTo;
     Dx = dx;
     Dy = dy;
     Dz = dz;
     Tm = TransformMethod.Param3;
 }
 /// <summary>
 /// DatumTransfromStage copy constructor
 /// </summary>
 /// <param name="dts"></param>
 public DatumTransformStage(DatumTransformStage dts)
 {
     From = dts.From;
     To = dts.To;
     FromSph = dts.FromSph;
     ToSph = dts.ToSph;
     Tm = dts.Tm;
     Dx = dts.Dx;
     Dy = dts.Dy;
     Dz = dts.Dz;
     Rx = dts.Rx;
     Ry = dts.Ry;
     Rz = dts.Rz;
     Ds = dts.Ds;
     TableName = dts.TableName;
     ApplyTableInv = dts.ApplyTableInv;
 }
 /// <summary>
 /// DatumTranformStage constructor for a 7-parameter transform
 /// </summary>
 public DatumTransformStage(string strFrom, string strTo, Spheroid sphFrom, Spheroid sphTo, double dx, double dy, double dz, double rx, double ry, double rz, double ds)
 {
     From = strFrom;
     To = strTo;
     FromSph = sphFrom;
     ToSph = sphTo;
     Tm = TransformMethod.Param7;
     Dx = dx;
     Dy = dy;
     Dz = dz;
     Rx = rx;
     Ry = ry;
     Rz = rz;
     Ds = ds;
 }
 /// <summary>
 /// DatumTranformStage constructor for a gridshift transform
 /// </summary>
 public DatumTransformStage(string strFrom, string strTo, Spheroid sphFrom, Spheroid sphTo, string strTableName, bool bApplyTableInv)
 {
     From = strFrom;
     To = strTo;
     FromSph = sphFrom;
     ToSph = sphTo;
     Tm = TransformMethod.GridShift;
     TableName = strTableName;
     ApplyTableInv = bApplyTableInv;
 }