public static string Apply(string input, string command)
        {
            switch (command)
            {
            case nameof(DiacriticsCommand):
                return(DiacriticsCommand.DiacriticsLogic(input, ToggleMode.Apply));

            case nameof(DoubleCommand):
                return(DoubleCommand.DoubleLogic(input, ToggleMode.Apply));

            case nameof(InvertCaseCommand):
                return(InvertCaseCommand.InvertCaseLogic(input));

            case nameof(PaddingCommand):
                return(PaddingCommand.PaddingLogic(input, ToggleMode.Apply));

            case nameof(ReverseCommand):
                return(ReverseCommand.ReverseLogic(input));

            case nameof(SurroundCommand):
                return(SurroundCommand.SurroundLogic(input, ToggleMode.Apply));

            default:
                return(input);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            await SurroundCommand.InitializeAsync(this);

            await ReverseCommand.InitializeAsync(this);

            await PaddingCommand.InitializeAsync(this);

            await InvertCaseCommand.InitializeAsync(this);

            await DiacriticsCommand.InitializeAsync(this);

            await DoubleCommand.InitializeAsync(this);

            await UppercaseCommand.InitializeAsync(this);

            await XxxxxCommand.InitializeAsync(this);

            await L337Command.InitializeAsync(this);

            await AlternateCaseCommand.InitializeAsync(this);

            await SponsorRequestHelper.CheckIfNeedToShowAsync();
        }
Beispiel #3
0
        public void OrderOfDoubleAndDiacriticsDoesMatterButCanRemoveInEitherOrder()
        {
            var original = "Original String";

            // Apply both changes
            var doubleFirst = DoubleCommand.DoubleLogic(original, ToggleMode.Apply);

            doubleFirst = DiacriticsCommand.DiacriticsLogic(doubleFirst, ToggleMode.Apply);

            var diacriticsFirst = DiacriticsCommand.DiacriticsLogic(original, ToggleMode.Apply);

            diacriticsFirst = DoubleCommand.DoubleLogic(diacriticsFirst, ToggleMode.Apply);

            // Remove doubling first
            var doubleFirstRemoved = DoubleCommand.DoubleLogic(doubleFirst, ToggleMode.Reverse);

            doubleFirstRemoved = DiacriticsCommand.DiacriticsLogic(doubleFirstRemoved, ToggleMode.Reverse);

            var diacriticsFirstRemoved = DoubleCommand.DoubleLogic(diacriticsFirst, ToggleMode.Reverse);

            diacriticsFirstRemoved = DiacriticsCommand.DiacriticsLogic(diacriticsFirstRemoved, ToggleMode.Reverse);

            Assert.AreEqual(original, doubleFirstRemoved);
            Assert.AreEqual(original, diacriticsFirstRemoved);

            // Remove diacritics first
            doubleFirstRemoved = DiacriticsCommand.DiacriticsLogic(doubleFirst, ToggleMode.Reverse);
            doubleFirstRemoved = DoubleCommand.DoubleLogic(doubleFirstRemoved, ToggleMode.Reverse);

            diacriticsFirstRemoved = DiacriticsCommand.DiacriticsLogic(diacriticsFirst, ToggleMode.Reverse);
            diacriticsFirstRemoved = DoubleCommand.DoubleLogic(diacriticsFirstRemoved, ToggleMode.Reverse);

            Assert.AreEqual(original, doubleFirstRemoved);
            Assert.AreEqual(original, diacriticsFirstRemoved);
        }
Beispiel #4
0
        public void RemoveDoubleWhenAlsoHasDiacritics_ButFirstCharIsNotALetter()
        {
            var actual = DoubleCommand.DoubleLogic(
                ">a\u0306\u032Ea\u0306\u032Eb\u0306\u032Eb\u0306\u032Ec\u0306\u032Ec\u0306\u032Ed\u0306\u032Ed\u0306\u032Ee\u0306\u032Ee\u0306\u032E",
                ToggleMode.Reverse);

            Assert.AreEqual(">a\u0306\u032Eb\u0306\u032Ec\u0306\u032Ed\u0306\u032Ee\u0306\u032E", actual);
        }
Beispiel #5
0
        public void RemovePaddingWhenHasAlsoBeenDoubled()
        {
            var origin = "ab";

            var actual = PaddingCommand.PaddingLogic(origin, ToggleMode.Apply);

            actual = DoubleCommand.DoubleLogic(actual, ToggleMode.Apply);
            actual = PaddingCommand.PaddingLogic(actual, ToggleMode.Reverse);

            Assert.AreEqual("aabb", actual);
        }
Beispiel #6
0
        public void CallingApplyMultipleTimesHasNoEffect()
        {
            var origin = "Original String";

            var once = DoubleCommand.DoubleLogic(origin, ToggleMode.Apply);

            var twice = DoubleCommand.DoubleLogic(origin, ToggleMode.Apply);

            twice = DoubleCommand.DoubleLogic(twice, ToggleMode.Apply);

            Assert.AreEqual(once, twice);
        }
Beispiel #7
0
        public void OrderOfDoubleAndDiacriticsDoesMatter()
        {
            var original = "Original String";

            var doubleFirst = DoubleCommand.DoubleLogic(original, ToggleMode.Apply);

            doubleFirst = DiacriticsCommand.DiacriticsLogic(doubleFirst, ToggleMode.Apply);

            var diacriticsFirst = DiacriticsCommand.DiacriticsLogic(original, ToggleMode.Apply);

            diacriticsFirst = DoubleCommand.DoubleLogic(diacriticsFirst, ToggleMode.Apply);

            // This is because the diacritic used is based on the string length
            Assert.AreNotEqual(doubleFirst, diacriticsFirst);
        }
Beispiel #8
0
        public void Double_AddsWhereDoNotHave()
        {
            var origin = new List <string> {
                "not doubled", "DDoouubblleedd", "also not doubled"
            };

            var sut = DoubleCommand.CreateForTesting();

            var actual = sut.TestActingOnMultipleStrings(origin);

            var expected = new List <string> {
                "nnoott ddoouubblleedd", "DDoouubblleedd", "aallssoo nnoott ddoouubblleedd"
            };

            Assert.That.StringListsAreEqual(expected, actual);
        }
Beispiel #9
0
        public void Double_WithSurround_RemovesWhereHave()
        {
            var origin = new List <string> {
                "[! DDoouubblleedd !]", "[! not doubled !]", "[! AAllssoo ddoouubblleedd !]"
            };

            var sut = DoubleCommand.CreateForTesting();

            var actual = sut.TestActingOnMultipleStrings(origin);

            var expected = new List <string> {
                "[! Doubled !]", "[! not doubled !]", "[! Also doubled !]"
            };

            Assert.That.StringListsAreEqual(expected, actual);
        }
 /// <summary>
 ///  主站遥控命令 双命令
 /// </summary>
 /// <param name="cot">传输原因</param>
 /// <param name="dco">单命令</param>
 /// <param name="objectAddr">信息对象地址</param>
 private void SendMasterCommand(CauseOfTransmissionList cot, DoubleCommand dco, UInt32 objectAddr)
 {
     try
     {
         var id = TypeIdentification.C_DC_NA_1;//遥控命令
         eventTypeIDManager.AddEventProcess(new EventProperty(id));
         var frame = new MasterCommand(appMessageManager.TransmitSequenceNumber, appMessageManager.RealReceiveSequenceNumber,
                                       id, cot, appMessageManager.ASDUADdress, objectAddr, dco.DCO);
         var array = frame.GetAPDUDataArray();
         MainTypeIProcess(array, array.Length, appMessageManager.WaitTime, id);
         appMessageManager.UpdateTransmitSequenceNumber();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "SendMasterCommand主站遥控命令");
     }
 }
Beispiel #11
0
        public void CanAddAndRemoveToggleActionsInDifferentOrder()
        {
            var origin = "Original String";

            var modifiedStep1  = SurroundCommand.SurroundLogic(origin, ToggleMode.Apply);
            var modifiedStep2  = DiacriticsCommand.DiacriticsLogic(modifiedStep1, ToggleMode.Apply);
            var modifiedStep3  = DoubleCommand.DoubleLogic(modifiedStep2, ToggleMode.Apply);
            var modifiedStep4  = ReverseCommand.ReverseLogic(modifiedStep3);
            var modifiedStep5  = PaddingCommand.PaddingLogic(modifiedStep4, ToggleMode.Apply);
            var modifiedStep6  = InvertCaseCommand.InvertCaseLogic(modifiedStep5);
            var modifiedStep7  = DiacriticsCommand.DiacriticsLogic(modifiedStep6, ToggleMode.Reverse);
            var modifiedStep8  = SurroundCommand.SurroundLogic(modifiedStep7, ToggleMode.Reverse);
            var modifiedStep9  = DoubleCommand.DoubleLogic(modifiedStep8, ToggleMode.Reverse);
            var modifiedStep10 = ReverseCommand.ReverseLogic(modifiedStep9);
            var modifiedStep11 = InvertCaseCommand.InvertCaseLogic(modifiedStep10);
            var finalResult    = PaddingCommand.PaddingLogic(modifiedStep11, ToggleMode.Reverse);

            Assert.AreEqual(origin, finalResult);
        }
Beispiel #12
0
        public void HandlesEmptyString_Reverse()
        {
            var actual = DoubleCommand.DoubleLogic(string.Empty, ToggleMode.Reverse);

            Assert.AreEqual(string.Empty, actual);
        }
Beispiel #13
0
        public void SpacesAtStartAndEndAreIgnoredWhenRemovingDoubles()
        {
            var actual = DoubleCommand.DoubleLogic(" AA cc ", ToggleMode.Reverse);

            Assert.AreEqual(" A c ", actual);
        }
Beispiel #14
0
        public void SpacesAreNotDoubled()
        {
            var actual = DoubleCommand.DoubleLogic("A c", ToggleMode.Apply);

            Assert.AreEqual("AA cc", actual);
        }
Beispiel #15
0
        public void PartialDoublesAreDoubled()
        {
            var actual = DoubleCommand.DoubleLogic("AAbc", ToggleMode.Apply);

            Assert.AreEqual("AAAAbbcc", actual);
        }
Beispiel #16
0
        public void RemoveDoubles()
        {
            var actual = DoubleCommand.DoubleLogic("aabbcc", ToggleMode.Reverse);

            Assert.AreEqual("abc", actual);
        }
Beispiel #17
0
        public void MakeDouble()
        {
            var actual = DoubleCommand.DoubleLogic("abc", ToggleMode.Apply);

            Assert.AreEqual("aabbcc", actual);
        }
Beispiel #18
0
        public void NonLettersArentDoubled()
        {
            var actual = DoubleCommand.DoubleLogic("1234$%^&", ToggleMode.Apply);

            Assert.AreEqual("1234$%^&", actual);
        }
Beispiel #19
0
        public void RemoveDoublingWhenHasAlsoBeenPadded()
        {
            var actual = DoubleCommand.DoubleLogic("a-a-b-b", ToggleMode.Reverse);

            Assert.AreEqual("a-b", actual);
        }
Beispiel #20
0
        public void DoubleWhenAlreadyPadded()
        {
            var actual = DoubleCommand.DoubleLogic("d-o-u-b-l-e m-e", ToggleMode.Apply);

            Assert.AreEqual("d-d-o-o-u-u-b-b-l-l-e-e m-m-e-e", actual);
        }
Beispiel #21
0
        public void DoubleWhenAlreadySurrounded()
        {
            var actual = DoubleCommand.DoubleLogic("[! double me !]", ToggleMode.Apply);

            Assert.AreEqual("[! ddoouubbllee mmee !]", actual);
        }
Beispiel #22
0
        public void DoubleWhenAlreadyHasDiacritics()
        {
            var actual = DoubleCommand.DoubleLogic("a\u0302\u032Db\u0302\u032Dc\u0302\u032Dd\u0302\u032De\u0302\u032D", ToggleMode.Apply);

            Assert.AreEqual("a\u0302\u032Da\u0302\u032Db\u0302\u032Db\u0302\u032Dc\u0302\u032Dc\u0302\u032Dd\u0302\u032Dd\u0302\u032De\u0302\u032De\u0302\u032D", actual);
        }
Beispiel #23
0
        /// <summary>
        /// 更新遥控状态,更新相应的按钮状态。
        /// Todo:地址更新需要同步,这限制了灵活性
        /// </summary>
        /// <param name="apdu">APDU帧</param>
        private void UpdateTelecontrolState(APDU apdu)
        {
            try
            {
                UInt32 objectAddr = ElementTool.CombinationByte(apdu.ASDU.InformationObject[0], apdu.ASDU.InformationObject[1], apdu.ASDU.InformationObject[2]);
                var    dc         = new DoubleCommand(apdu.ASDU.InformationObject[3]);
                switch (objectAddr)
                {
                //开关控制
                case Telecontrol.BasicAddress:
                {
                    if ((dc.DCS == DCOState.On) && (dc.SE == SelectExecuteOption.Select))
                    {
                        //合闸 选择
                        controlReayActionState.ActionCloseEnabled = true;
                        controlReayActionState.ReadyCloseEnabled  = false;
                        MakeLogMessage(apdu, "", "合闸预制-确认", LogType.Telecontrol);
                    }
                    else if ((dc.DCS == DCOState.On) && (dc.SE == SelectExecuteOption.Execute))
                    {
                        //合闸 执行
                        controlReayActionState.ActionCloseEnabled = false;
                        controlReayActionState.ReadyCloseEnabled  = true;
                        MakeLogMessage(apdu, "", "合闸执行-确认", LogType.Telecontrol);
                    }
                    if ((dc.DCS == DCOState.Off) && (dc.SE == SelectExecuteOption.Select))
                    {
                        //分闸 选择
                        controlReayActionState.ActionOpenEnabled = true;
                        controlReayActionState.ReadyOpenEnabled  = false;
                        MakeLogMessage(apdu, "", "分闸预制-确认", LogType.Telecontrol);
                    }
                    else if ((dc.DCS == DCOState.Off) && (dc.SE == SelectExecuteOption.Execute))
                    {
                        //分闸 执行
                        controlReayActionState.ActionOpenEnabled = false;
                        controlReayActionState.ReadyOpenEnabled  = true;
                        MakeLogMessage(apdu, "", "分闸执行-确认", LogType.Telecontrol);
                    }

                    break;
                }

                //电池活化
                case (Telecontrol.BasicAddress + 1):
                {
                    break;
                }

                //复归
                case (Telecontrol.BasicAddress + 2):
                {
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "更新遥控状态");
            }
        }
Beispiel #24
0
        public void CanHandleNonAscii()
        {
            var actual = DoubleCommand.DoubleLogic("mrläcey", ToggleMode.Apply);

            Assert.AreEqual("mmrrllääcceeyy", actual);
        }
        BuildInfoObj(
            Int32 asdu,
            Int32 addr,
            Double value,
            Boolean sbo               = false,
            Int32 cmdqualif           = 0,
            QualityDescriptor quality = null,
            CP56Time2a time_tag       = null,
            Double kconv1             = 1,
            Double kconv2             = 0,
            Boolean transient         = false
            )
        {
            InformationObject sc = null;

            if (time_tag == null)
            {
                time_tag = new CP56Time2a(DateTime.Now);
            }
            else
            { // has time tag, so change ASDU if necessary to embed a timetag
                var maptowithcp56time = new Dictionary <TypeID, TypeID>();
                maptowithcp56time.Add(TypeID.M_SP_NA_1, TypeID.M_SP_TB_1);
                maptowithcp56time.Add(TypeID.M_DP_NA_1, TypeID.M_DP_TB_1);
                maptowithcp56time.Add(TypeID.M_ST_NA_1, TypeID.M_ST_TB_1);
                maptowithcp56time.Add(TypeID.M_BO_NA_1, TypeID.M_BO_TB_1);
                maptowithcp56time.Add(TypeID.M_ME_NA_1, TypeID.M_ME_TD_1);
                maptowithcp56time.Add(TypeID.M_ME_NB_1, TypeID.M_ME_TE_1);
                maptowithcp56time.Add(TypeID.M_ME_NC_1, TypeID.M_ME_TF_1);
                maptowithcp56time.Add(TypeID.M_IT_NA_1, TypeID.M_IT_TB_1);
                if (maptowithcp56time.TryGetValue((TypeID)asdu, out var newasdu))
                {
                    asdu = (Int32)newasdu;
                }
            }

            Boolean bval;
            Int32   ival;
            UInt32  uival;

            switch ((TypeID)asdu)
            {
            case TypeID.M_SP_NA_1:     // 1
                bval = value != 0 ? true : false;
                if (kconv1 == -1)
                {
                    bval = !bval;
                }
                sc =
                    new SinglePointInformation(addr,
                                               bval,
                                               quality);
                break;

            case TypeID.M_SP_TB_1:     // 30
                bval = value != 0 ? true : false;
                if (kconv1 == -1)
                {
                    bval = !bval;
                }
                sc =
                    new SinglePointWithCP56Time2a(addr,
                                                  bval,
                                                  quality,
                                                  time_tag
                                                  );
                break;

            case TypeID.M_DP_NA_1:     // 3
                if (transient)
                {
                    sc =
                        new DoublePointInformation(addr,
                                                   DoublePointValue.INTERMEDIATE,
                                                   quality);
                }
                else
                if (kconv1 == -1)
                {
                    sc =
                        new DoublePointInformation(addr,
                                                   value != 0 ? DoublePointValue.OFF : DoublePointValue.ON,
                                                   quality);
                }
                else
                {
                    sc =
                        new DoublePointInformation(addr,
                                                   value != 0 ? DoublePointValue.ON : DoublePointValue.OFF,
                                                   quality);
                }
                break;

            case TypeID.M_DP_TB_1:     // 31
                if (transient)
                {
                    sc =
                        new DoublePointWithCP56Time2a(addr,
                                                      DoublePointValue.INTERMEDIATE,
                                                      quality,
                                                      time_tag);
                }
                else
                if (kconv1 == -1)
                {
                    sc =
                        new DoublePointWithCP56Time2a(addr,
                                                      value != 0 ? DoublePointValue.OFF : DoublePointValue.ON,
                                                      quality,
                                                      time_tag);
                }
                else
                {
                    sc =
                        new DoublePointWithCP56Time2a(addr,
                                                      value != 0 ? DoublePointValue.ON : DoublePointValue.OFF,
                                                      quality,
                                                      time_tag);
                }
                break;

            case TypeID.M_ST_NA_1:     // 5
                value = value * kconv1 + kconv2;
                if (value > 63)
                {
                    value            = 63;
                    quality.Overflow = true;
                }
                else
                if (value < -64)
                {
                    value            = -64;
                    quality.Overflow = true;
                }
                sc = new StepPositionInformation(addr,
                                                 System.Convert.ToInt16(value),
                                                 transient,
                                                 quality);
                break;

            case TypeID.M_ST_TB_1:     // 32
                value = value * kconv1 + kconv2;
                if (value > 63)
                {
                    value            = 63;
                    quality.Overflow = true;
                }
                else
                if (value < -64)
                {
                    value            = -64;
                    quality.Overflow = true;
                }
                sc = new StepPositionWithCP56Time2a(addr,
                                                    System.Convert.ToInt16(value),
                                                    transient,
                                                    quality,
                                                    time_tag);
                break;

            case TypeID.M_ME_NA_1:     // 9
                value = value * kconv1 + kconv2;
                if (value > 32767)
                {
                    value            = 32767;
                    quality.Overflow = true;
                }
                else
                if (value < -32768)
                {
                    value            = -32768;
                    quality.Overflow = true;
                }
                sc = new MeasuredValueNormalized(addr,
                                                 System.Convert.ToInt16(value),
                                                 quality);
                break;

            case TypeID.M_ME_ND_1:     // 21
                value = value * kconv1 + kconv2;
                if (value > 32767)
                {
                    value            = 32767;
                    quality.Overflow = true;
                }
                else
                if (value < -32768)
                {
                    value            = -32768;
                    quality.Overflow = true;
                }
                sc = new MeasuredValueNormalizedWithoutQuality(addr,
                                                               System.Convert.ToInt16(value));
                break;

            case TypeID.M_ME_TD_1:     // 34
                value = value * kconv1 + kconv2;
                if (value > 32767)
                {
                    value            = 32767;
                    quality.Overflow = true;
                }
                else
                if (value < -32768)
                {
                    value            = -32768;
                    quality.Overflow = true;
                }
                sc = new MeasuredValueNormalizedWithCP56Time2a(addr,
                                                               System.Convert.ToInt16(value),
                                                               quality,
                                                               time_tag);
                break;

            case TypeID.M_ME_NB_1:     // 11
                value = value * kconv1 + kconv2;
                if (value > 32767)
                {
                    value            = 32767;
                    quality.Overflow = true;
                }
                else
                if (value < -32768)
                {
                    value            = -32768;
                    quality.Overflow = true;
                }
                sc = new MeasuredValueScaled(addr,
                                             System.Convert.ToInt16(value),
                                             quality);
                break;

            case TypeID.M_ME_TE_1:     // 35
                value = value * kconv1 + kconv2;
                if (value > 32767)
                {
                    value            = 32767;
                    quality.Overflow = true;
                }
                else
                if (value < -32768)
                {
                    value            = -32768;
                    quality.Overflow = true;
                }
                sc = new MeasuredValueScaledWithCP56Time2a(addr,
                                                           System.Convert.ToInt16(value),
                                                           quality,
                                                           time_tag);
                break;

            case TypeID.M_ME_NC_1:     // 13
                value = value * kconv1 + kconv2;
                sc    = new MeasuredValueShort(addr,
                                               System.Convert.ToSingle(value),
                                               quality);
                break;

            case TypeID.M_ME_TF_1:     // 36
                value = value * kconv1 + kconv2;
                sc    = new MeasuredValueShortWithCP56Time2a(addr,
                                                             System.Convert.ToSingle(value),
                                                             quality,
                                                             time_tag);
                break;

            case TypeID.M_IT_NA_1:     //15
                break;

            case TypeID.M_IT_TB_1:     // 37
                break;

            case TypeID.M_PS_NA_1:     // 20
                Log(" TODO Packed single point information with status change detection! ");
                break;

            case TypeID.M_EP_TD_1:     // 38
                break;

            case TypeID.M_EP_TE_1:     // 39
                break;

            case TypeID.M_EP_TF_1:     // 40
                break;

            case TypeID.M_BO_NA_1:     // 7
                uival = System.Convert.ToUInt32(value);
                if (kconv1 == -1)
                {
                    uival = ~uival;
                }
                sc = new Bitstring32(addr, uival, quality);
                break;

            case TypeID.M_BO_TB_1:     // 33
                uival = System.Convert.ToUInt32(value);
                if (kconv1 == -1)
                {
                    uival = ~uival;
                }
                sc = new Bitstring32WithCP56Time2a(addr, uival, quality, time_tag);
                break;

            case TypeID.C_SC_NA_1:     // 45
                bval = value != 0 ? true : false;
                if (kconv1 == -1)
                {
                    bval = !bval;
                }
                sc =
                    new SingleCommand(addr,
                                      bval,
                                      sbo,
                                      cmdqualif);
                break;

            case TypeID.C_DC_NA_1:     // 46
                if (kconv1 == -1)
                {
                    ival = value != 0 ? System.Convert.ToInt32(DoublePointValue.OFF) : System.Convert.ToInt32(DoublePointValue.ON);
                }
                else
                {
                    ival = value != 0 ? System.Convert.ToInt32(DoublePointValue.ON) : System.Convert.ToInt32(DoublePointValue.OFF);
                }
                sc =
                    new DoubleCommand(addr,
                                      ival,
                                      sbo,
                                      cmdqualif);
                break;

            case TypeID.C_RC_NA_1:     // 47
                if (kconv1 == -1)
                {
                    sc =
                        new StepCommand(addr,
                                        value >= 1
                                    ? StepCommandValue.LOWER
                                    : StepCommandValue.HIGHER,
                                        sbo,
                                        cmdqualif);
                }
                else
                {
                    sc =
                        new StepCommand(addr,
                                        value >= 1
                                    ? StepCommandValue.HIGHER
                                    : StepCommandValue.LOWER,
                                        sbo,
                                        cmdqualif);
                }
                break;

            case TypeID.C_SE_NA_1:     // 48
                value = value * kconv1 + kconv2;
                if (value > 32767)
                {
                    value = 32767;
                }
                else
                if (value < -32768)
                {
                    value = -32768;
                }
                sc =
                    new SetpointCommandNormalized(addr,
                                                  System.Convert.ToInt16(value),
                                                  new SetpointCommandQualifier(sbo, 0));
                break;

            case TypeID.C_SE_NB_1:     // 49
                value = value * kconv1 + kconv2;
                if (value > 32767)
                {
                    value = 32767;
                }
                else
                if (value < -32768)
                {
                    value = -32768;
                }
                sc =
                    new SetpointCommandScaled(addr,
                                              new ScaledValue(System.Convert.ToInt16(value)),
                                              new SetpointCommandQualifier(sbo, 0));
                break;

            case TypeID.C_SE_NC_1:     // 50
                value = value * kconv1 + kconv2;
                sc    =
                    new SetpointCommandShort(addr,
                                             System.Convert.ToSingle(value),
                                             new SetpointCommandQualifier(sbo, 0));
                break;

            case TypeID.C_BO_NA_1:     // 51
                uival = System.Convert.ToUInt32(value);
                if (kconv1 == -1)
                {
                    uival = ~uival;
                }
                sc =
                    new Bitstring32Command(addr,
                                           uival);
                break;

            case TypeID.C_SC_TA_1:     //  58
                bval = value != 0 ? true : false;
                if (kconv1 == -1)
                {
                    bval = !bval;
                }
                sc =
                    new SingleCommandWithCP56Time2a(addr,
                                                    bval,
                                                    sbo,
                                                    cmdqualif,
                                                    time_tag);
                break;

            case TypeID.C_DC_TA_1:     // 59
                if (kconv1 == -1)
                {
                    ival = value != 0 ? System.Convert.ToInt32(DoublePointValue.OFF) : System.Convert.ToInt32(DoublePointValue.ON);
                }
                else
                {
                    ival = value != 0 ? System.Convert.ToInt32(DoublePointValue.ON) : System.Convert.ToInt32(DoublePointValue.OFF);
                }
                sc =
                    new DoubleCommandWithCP56Time2a(addr,
                                                    ival,
                                                    sbo,
                                                    cmdqualif,
                                                    time_tag);
                break;

            case TypeID.C_RC_TA_1:     // 60
                if (kconv1 == -1)
                {
                    sc =
                        new StepCommandWithCP56Time2a(addr,
                                                      value >= 1
                                    ? StepCommandValue.LOWER
                                    : StepCommandValue.HIGHER,
                                                      sbo,
                                                      cmdqualif,
                                                      time_tag);
                }
                else
                {
                    sc =
                        new StepCommandWithCP56Time2a(addr,
                                                      value >= 1
                                    ? StepCommandValue.HIGHER
                                    : StepCommandValue.LOWER,
                                                      sbo,
                                                      cmdqualif,
                                                      time_tag);
                }
                break;

            case TypeID.C_SE_TA_1:     // 61
                value = value * kconv1 + kconv2;
                if (value > 32767)
                {
                    value = 32767;
                }
                else
                if (value < -32768)
                {
                    value = -32768;
                }
                sc =
                    new SetpointCommandNormalizedWithCP56Time2a(addr,
                                                                System.Convert.ToInt16(value),
                                                                new SetpointCommandQualifier(sbo, 0),
                                                                time_tag);
                break;

            case TypeID.C_SE_TB_1:     // 62
                value = value * kconv1 + kconv2;
                if (value > 32767)
                {
                    value = 32767;
                }
                else
                if (value < -32768)
                {
                    value = -32768;
                }
                sc =
                    new SetpointCommandScaledWithCP56Time2a(addr,
                                                            new ScaledValue(System.Convert.ToInt16(value)),
                                                            new SetpointCommandQualifier(sbo, 0),
                                                            time_tag);
                break;

            case TypeID.C_SE_TC_1:     // 63
                value = value * kconv1 + kconv2;
                sc    =
                    new SetpointCommandShortWithCP56Time2a(addr,
                                                           System.Convert.ToSingle(value),
                                                           new SetpointCommandQualifier(sbo, 0),
                                                           time_tag);
                break;

            case TypeID.C_BO_TA_1:     // 64
                uival = System.Convert.ToUInt32(value);
                if (kconv1 == -1)
                {
                    uival = ~uival;
                }
                sc =
                    new Bitstring32CommandWithCP56Time2a(addr,
                                                         uival,
                                                         time_tag);
                break;

            case TypeID.C_IC_NA_1:     // 100
                sc =
                    new InterrogationCommand(0,
                                             System.Convert.ToByte(cmdqualif));
                break;

            case TypeID.C_CI_NA_1:     // 101
                sc =
                    new CounterInterrogationCommand(0,
                                                    System.Convert.ToByte(cmdqualif));
                break;

            case TypeID.C_RD_NA_1:     // 102
                sc = new ReadCommand(addr);
                break;

            case TypeID.C_CS_NA_1:     // 103
                sc = new ClockSynchronizationCommand(0, time_tag);
                break;

            case TypeID.C_RP_NA_1:     // 105
                sc =
                    new ResetProcessCommand(addr,
                                            System.Convert.ToByte(cmdqualif));
                break;

            case TypeID.C_TS_TA_1:     // 107
                sc =
                    new TestCommandWithCP56Time2a(System
                                                  .Convert
                                                  .ToUInt16(value),
                                                  time_tag);
                break;

            case TypeID.P_ME_NA_1:     // 110
                value = value * kconv1 + kconv2;
                if (value > 32767)
                {
                    value = 32767;
                }
                else
                if (value < -32768)
                {
                    value = -32768;
                }
                sc =
                    new ParameterNormalizedValue(System
                                                 .Convert
                                                 .ToInt32(addr),
                                                 System.Convert.ToInt32(value),
                                                 System.Convert.ToByte(cmdqualif));
                break;

            case TypeID.P_ME_NB_1:     // 111
                value = value * kconv1 + kconv2;
                if (value > 32767)
                {
                    value = 32767;
                }
                else
                if (value < -32768)
                {
                    value = -32768;
                }
                sc =
                    new ParameterScaledValue(addr,
                                             new ScaledValue(System.Convert.ToInt16(value)),
                                             System.Convert.ToByte(cmdqualif));
                break;

            case TypeID.P_ME_NC_1:     // 112
                value = value * kconv1 + kconv2;
                sc    =
                    new ParameterFloatValue(addr,
                                            System.Convert.ToSingle(value),
                                            System.Convert.ToByte(cmdqualif));
                break;

            case TypeID.P_AC_NA_1:     // 113
                sc =
                    new ParameterActivation(System.Convert.ToInt32(addr),
                                            System.Convert.ToByte(cmdqualif));
                break;

            default:
                break;
            }
            return(sc);
        }
Beispiel #26
0
        public void CanHandleCyrillic()
        {
            var actual = DoubleCommand.DoubleLogic("матт", ToggleMode.Apply);

            Assert.AreEqual("ммаатттт", actual);
        }