Esempio n. 1
0
        static void output(Morse m)
        {
            switch (m)
            {
            case Morse.DOT:
                controller.Write(ledPin1, PinValue.High);
                Thread.Sleep(dotTimeInMilliseconds);
                controller.Write(ledPin1, PinValue.Low);
                Thread.Sleep(endTimeInMilliseconds);
                break;

            case Morse.DASH:
                controller.Write(ledPin1, PinValue.High);
                Thread.Sleep(dashTimeInMilliseconds);
                controller.Write(ledPin1, PinValue.Low);
                Thread.Sleep(endTimeInMilliseconds);
                break;

            case Morse.INTER_LETTER_GAP:
                controller.Write(ledPin1, PinValue.Low);
                Thread.Sleep(endOfCharTimeInMilliseconds);
                break;

            case Morse.INTER_WORD_GAP:
                controller.Write(ledPin1, PinValue.Low);
                Thread.Sleep(endOfWordTimeInMilliseconds);
                break;
            }
        }
Esempio n. 2
0
    static void Main(string[] args)
    {
        const string text  = "abcde123x zz ";
        var          morse = new Morse(text);

        Console.WriteLine(morse.Code);
    }
        public void TestMorseEncoderWithValue()
        {
            string solution = "..-. .-. .- -. --.. .--- .- --. - .. -- -.- --- -- .--. .-.. . - - ...- . .-. .-- .- .... .-. .-.. --- ... - . -. - .- -..- .. --.- ..- . .-. -.. ..- .-. -.-. .... -... .- -.-- . .-. -. .---- ..--- ...-- ....- ..... -.... --... ---.. ----. ----- ";
            Morse  morse    = new Morse();
            string result   = morse.EncodeMessage("Franz jagt im komplett verwahrlosten Taxi quer durch Bayern. 1234567890");

            Assert.IsTrue(result == solution);
        }
        public void TestMorseEncoderWithWrongValue()
        {
            string wrongSolution = "- . ... - - . -..- -";
            Morse  morse         = new Morse();
            string result        = morse.EncodeMessage("test text");

            Assert.IsFalse(result == wrongSolution);
        }
Esempio n. 5
0
        public void TestMorseParsing(string testString)
        {
            // Arrange
            var morse = Morse.FromUnencodedString(testString);

            // Act and Assert
            Assert.IsTrue(morse.GetPossibleStrings().Contains(testString, StringComparer.OrdinalIgnoreCase));
        }
Esempio n. 6
0
        public void BtnSpace_Clicked(Object sender, System.EventArgs e)
        {
            LblMorse.Text += " ";
            char newLetter = Morse.MorseCoder(input);

            LblOutput.Text += newLetter;
            input           = "";
        }
Esempio n. 7
0
        public void costruisco_un_oggetto_Morse()
        {
            Morse m = new Morse();

            Assert.Equal <string>("...---...", m.Codifica("sos"));
            Assert.Equal <string>("...---...", m.Codifica("SOS"));
            Assert.Equal <string>("-.-....----", m.Codifica("Ciao"));
        }
Esempio n. 8
0
        public void TestMorseDecodeWrongChar()
        {
            string textToDecode = "- . .-. - .----    - . ... - ..---    - . ... - ...--";
            string solution     = "TEST1 TEST2 TEST3";
            Morse  morse        = new Morse();
            string result       = morse.DecodeMessage(textToDecode);

            Assert.IsFalse(result == solution);
        }
Esempio n. 9
0
 public void ASingleSignal()
 {
     CollectionAssert.AreEqual(new List <string> {
         "E"
     }, Morse.Possibilities("."));
     CollectionAssert.AreEqual(new List <string> {
         "A"
     }, Morse.Possibilities(".-"));
 }
Esempio n. 10
0
        public void TestMorseDecodeLetters()
        {
            string textToDecode = "TEST1 TEST2 TEST3";
            string solution     = "TEST1 TEST2 TEST3";
            Morse  morse        = new Morse();
            string result       = morse.DecodeMessage(textToDecode);

            Assert.IsFalse(result == solution);
        }
Esempio n. 11
0
 public void AWordWithASingleUnknownSignal()
 {
     CollectionAssert.AreEqual(new List <string> {
         "E", "T"
     }, Morse.Possibilities("?"));
     CollectionAssert.AreEqual(new List <string> {
         "I", "N"
     }, Morse.Possibilities("?."));
     CollectionAssert.AreEqual(new List <string> {
         "I", "A"
     }, Morse.Possibilities(".?"));
 }
Esempio n. 12
0
 public void DecodeInput(string inp)
 {
     if (!string.IsNullOrWhiteSpace(inp))
     {
         CodedTextStore += inp;
     }
     else if (!string.IsNullOrWhiteSpace(CodedTextStore))
     {
         DecodedText   += Morse.MorseCoder(CodedTextStore);
         CodedTextStore = string.Empty;
         message.Text   = DecodedText;
     }
 }
        public void IsExceptionHandled()
        {
            Morse morse = new Morse();

            try
            {
                morse.EncodeMessage(",.-");
            }
            catch (KeyNotFoundException)
            {
                Assert.Fail();
            }
        }
Esempio n. 14
0
        public static void Main(string[] args)
        {
            List <string> test = new List <string>()
            {
                "-", ".", "...", "-", "..", "-.", "--."
            };
            Morse  testing = new Morse();
            string _string = testing.ToWordLine(test);

            Console.WriteLine(_string);
            Alphabet _Test = new Alphabet();

            Console.WriteLine(_Test.ToMorsecode(_string));
            ToMorsewithSound morsewithsound = new ToMorsewithSound();

            morsewithsound.FromAlphabetForConsole(100, _string);
            Console.WriteLine(_string);
            testing.ToAlphabet(".");
        }
Esempio n. 15
0
    Morse TelegraphInput()
    {
        Morse setMorse = Morse.nul;

        if (timeInput == true)
        {
            if (teleInputTimer < ditMaxThreshold)
            {
                setMorse = Morse.dit;
            }

            else
            if (teleInputTimer < dahMaxThreshold)
            {
                setMorse = Morse.dah;
            }
        }

        return(setMorse);
    }
Esempio n. 16
0
        static void Main(string[] args)
        {
            string lang; //Русский или английский
            string f1 = @"D:\06.04\MorseN\bin\Debug\netcoreapp2.0\Input.txt";
            string f2 = @"D:\06.04\MorseN\bin\Debug\netcoreapp2.0\Output.txt";

            //string f3 = @"D:\06.04\MorseN\bin\Debug\netcoreapp2.0\Finale.txt";
            Console.WriteLine("RUS or ENG?");
            lang = Console.ReadLine();
            lang = lang.ToUpper();
            Morse morzeTranslate = new Morse(lang);

            Console.WriteLine(" 'In' Morse or 'Out' ");
            string choose;

            choose = Console.ReadLine();
            choose = choose.ToUpper();
            string temp1 = "";

            using (StreamReader s = new StreamReader(f1, true))
            {
                using (StreamWriter ff = new StreamWriter(f2))
                {
                    while ((temp1 = s.ReadLine()) != null)
                    {
                        if (choose == "IN")
                        {
                            ff.WriteLine(morzeTranslate.Morz(temp1));//Перевод данного текста в азбуку морза
                        }
                        if (choose == "OUT")
                        {
                            ff.WriteLine(morzeTranslate.MorseReverse(temp1));//Обратный перевод из азбуки морза в текст
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        static void Main(string[] args)
        {
            StreamReader f = new StreamReader("morse.csv", Encoding.UTF8);

            string[] lines      = f.ReadToEnd().Split('\n');
            Morse[]  morseTable = new Morse[lines.Length - 1];

            for (int i = 0; i < morseTable.Length; i++)
            {
                morseTable[i].DigestMorseCSV(lines[i]);
            }

            char c;

            Console.WriteLine("\t* * * *  M O R S E  * * * * \t\texit: *");
            do
            {
                c = Console.ReadKey(true).KeyChar;
                Console.WriteLine("{0} \t\t\t {1} \t\t\t {2}", c, SearchWord(morseTable, c), SearchCode(morseTable, c));
                Beep(SearchCode(morseTable, c));
            } while (c != '*');

            Console.ReadKey();
        }
Esempio n. 18
0
        public void codifico_sos()
        {
            Morse m = new Morse();

            Assert.Equal <string>("... --- ...", m.Codifica("sos"));
        }
Esempio n. 19
0
        public void decodifico_ciao()
        {
            Morse m = new Morse();

            Assert.Equal <string>("ciao", m.Decodifica("-.-. .. .- ---"));
        }
Esempio n. 20
0
        public void codifico_ciao()
        {
            Morse m = new Morse();

            Assert.Equal <string>("-.-. .. .- ---", m.Codifica("Ciao"));
        }
Esempio n. 21
0
        private void DecryptButton_Click(object sender, RoutedEventArgs e)
        {
            string inputText;

            if (inputField.IsEnabled == false)
            {
                inputText = fileContent;
            }
            else
            {
                inputText = inputField.Text.ToString();
            }
            string outText = string.Empty;

            switch (chooseType.Text)
            {
            case "Cezar":
                Cesar cesar = new Cesar();
                int   shift = GetShiftValue();
                if (shift == -1)
                {
                    break;
                }
                outText = cesar.Encryption(inputText, -shift);
                break;

            case "Kaczor":
                Kaczor duck = new Kaczor();
                outText = duck.Decryption(inputText);
                break;

            case "Morse'a":
                Morse morse = new Morse();
                outText = morse.Decrytption(inputText);
                break;

            case "Liczbowy":
                Numeric numeric = new Numeric();
                outText = numeric.Decrytption(inputText);
                break;

            case "Cyfrowy":
                Digital digital    = new Digital();
                int     shiftDigit = GetShiftValue();
                if (shiftDigit == -1)
                {
                    break;
                }
                string password;
                var    dialog = new InputBoxForNumericPass("Podaj hasło numeryczne");
                if (dialog.ShowDialog() == true)
                {
                    password = dialog.answer.Text.ToString();
                }
                else
                {
                    break;
                }
                outText = digital.Decryption(inputText, GetShiftValue(), password);
                break;

            case "Zamiennikowy":
                Zamiennikowy zamiennikowy = new Zamiennikowy();
                string       key          = GetEncryptKeyFromComboBox();
                if (key.Equals("Wybierz Klucz..."))
                {
                    break;
                }
                outText = zamiennikowy.Encryption(inputText, key);
                break;
            }
            if (inputField.IsEnabled != false)
            {
                outputField.Text = outText;
            }
            else
            {
                EncryptFile encryptFile = new EncryptFile();
                encryptFile.SaveNewFile(outText);
                SetEnableTextBox();
            }
        }
Esempio n. 22
0
        private static int ConvertToMorse(ToOptions o)
        {
            string?input;

            using (var stdin = new StreamReader(Console.OpenStandardInput())) {
                input = stdin.ReadToEnd().Trim();
            }

            if (string.IsNullOrWhiteSpace(input))
            {
                Exit("Input missing");
            }

            int ditDuration = (int)(60.0 / (50.0 * o.Wpm) * 1000.0);

            if (o.Verbose)
            {
                Console.WriteLine($"dit duration = {ditDuration}");
            }

            IReadOnlyList <IReadOnlyList <MorseSymbol> > code = MorseConverter.ToMorse(input !);

            foreach ((IReadOnlyList <MorseSymbol> Morse, char Char) in code.Zip(input.Concat(new[] { '/' })))
            {
                if (char.IsWhiteSpace(Char))
                {
                    if (o.Verbose)
                    {
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.Write("   ");
                    }
                    Thread.Sleep(3 * ditDuration);
                    continue;
                }
                if (o.Verbose)
                {
                    Console.Write(Char);
                    Console.Write(": ");
                }
                Console.Write(string.Join("", Morse.Select(m => m.ToMorseChar())));
                Console.Write(' ');
                if (o.Verbose)
                {
                    Console.WriteLine();
                }
                if (o.Play)
                {
                    foreach (MorseSymbol s in Morse)
                    {
                        AudioPlayer.PlayBeep(o.Frequency, s.Duration() * ditDuration);
                        Thread.Sleep((s.Duration() + 1) * ditDuration);
                    }
                    Thread.Sleep(3 * ditDuration);
                }
            }

            return(0);
        }
Esempio n. 23
0
 public Node Child(Morse morse)
 {
     return morse == Morse.Dot ? dot : dash;
 }
Esempio n. 24
0
 public Node ChildAndCreateIfNeeded(Morse morse)
 {
     if (morse == Morse.Dot) {
       if (dot == null)
     dot = new Node ();
       return dot;
     } else {
       if (dash == null)
     dash = new Node ();
       return dash;
     }
 }