protected void ShouterNameEntered(object sender, PopUpEventArgs <string, PopUpResult> e)
        {
            if (e.PopUpResult == PopUpResult.Ok)
            {
                var prompt  = (MessagePrompt)sender;
                var textBox = (TextBox)prompt.Body;

                var newName = textBox.Text;
                var group   = currentGroup;

                if (group.Shouters != null && group.Shouters.Any(s => s.Name == newName))
                {
                    MessageBox.Show("Sorry, there's already someone in the group with that name", "So Unoriginal!", MessageBoxButton.OK);
                }
                else
                {
                    var newShouter = new Shouter();
                    newShouter.Name = newName;

                    if (group.AddShouter(newShouter))
                    {
                        NavigationService.Navigate(new Uri(string.Format("/Pages/AddEditGroup.xaml?groupId={0}&x={1}", currentGroup.GroupId, Utility.CacheBreaker()), UriKind.Relative));
                    }
                }
            }
        }
Beispiel #2
0
        protected void ShouterNameEntered(object sender, PopUpEventArgs <string, PopUpResult> e)
        {
            if (e.PopUpResult == PopUpResult.Ok)
            {
                var prompt  = (MessagePrompt)sender;
                var textBox = (TextBox)prompt.Body;

                var newName = textBox.Text;

                var group = appSettings.CurrentGroup;

                if (group.Shouters.Any(s => s.Name == newName))
                {
                    MessageBox.Show("Sorry, there's already someone in the group with that name", "So Unoriginal!", MessageBoxButton.OK);
                }
                else
                {
                    var newShouter = new Shouter();
                    newShouter.Name = newName;

                    if (group.AddShouter(newShouter))
                    {
                        RefreshGroups();
                    }
                }
            }
        }
Beispiel #3
0
        static void Main( string[] args )
        {
            IShoutable shouter = new Shouter();

              Skeleton skeleton = new Skeleton( 6010, shouter );
              skeleton.Start();
        }
        private void ContactName_Tap(object sender, GestureEventArgs e)
        {
            if (currentGroup == null)
            {
                SaveOrUpdateGroup(false);
            }

            var group = currentGroup;

            var textBox = sender as TextBlock;

            var newShouter = new Shouter();
            var memberName = textBox.Text.Split(' ');
            var abbrName   = new StringBuilder();

            // Format the name so we get their full first name and the first letter of any following names. e.g. MichaelDS
            foreach (var name in memberName)
            {
                abbrName.Append(abbrName.Length < 1 ? name : name.Substring(0, 1));
            }
            newShouter.Name = abbrName.ToString();
            group.AddShouter(newShouter);

            ApplicationBar.IsVisible = true;
            AddContacts.Visibility   = Visibility.Collapsed;
            NavigationService.Navigate(new Uri(string.Format("/Pages/AddEditGroup.xaml?groupId={0}&x={1}", group.GroupId, Utility.CacheBreaker()), UriKind.Relative));
        }
Beispiel #5
0
 public void ShoutIt()
 {
     try
     {
         var     activity = CrossCurrentActivity.Current.Activity;
         Shouter shout    = new Shouter(activity);
         shout.ShoutHello(_isToast);
     }
     catch { }
 }
 private static void Main(string[] args)
 {
     using (var logWriter = CreateStandardOutputLogWriter())
     {
         var shouter = new Shouter(logWriter);
         while (true)
         {
             shouter.Shout(new System.Threading.CancellationToken());
         }
     }
 }
Beispiel #7
0
        public static int DevGndPins(Shouter shouter)
        {
            var  onScreen = "n/f = increase pinnumber by 1/10; p/b = decrease pinnumber by 1/10; q = quit!";
            byte p        = 0;
            var  quit     = false;

            while (!quit)
            {
                var tr  = new PinTranslator(40, 40, 0);
                var zif = new ZIFSocket(40);
                zif.SetAll(true);
                using (var td = TopDevice.Create(shouter))
                {
                    td.SetVccLevel(0x2D);
                    td.ApplyGnd(tr.ToZIF, new Pin {
                        Number = 40
                    });
                    td.ApplyVcc(tr.ToZIF, new Pin {
                        Number = 20
                    });
                    td.PullUpsEnable(true);
                    td.WriteZIF(zif, "");
                    Console.WriteLine(onScreen);
                    switch (Console.ReadKey().Key)
                    {
                    case ConsoleKey.N:
                        p++;
                        break;

                    case ConsoleKey.F:
                        p += 10;
                        break;

                    case ConsoleKey.P:
                        p--;
                        break;

                    case ConsoleKey.B:
                        p -= 10;
                        break;

                    case ConsoleKey.Q:
                        quit = true;
                        break;

                    default:
                        Console.WriteLine(onScreen);
                        break;
                    }
                }
            }
            return(0);
        }
Beispiel #8
0
        public Test()
        {
            _httpMessageHandler = new MockMessageHandler();
            _logStream          = new MemoryStream();
            var init = Shouter.Initializer.CreateDefault();

            init.LogWriter         = CreateLogWriter(_logStream);
            init.HttpClient        = new HttpClient(_httpMessageHandler);
            _pubsub                = init.PubsubService;
            init.SubscriptionName += "-test";
            init.ProjectId         = Environment.GetEnvironmentVariable("GOOGLE_PROJECT_ID");
            _topicPath             = $"projects/{init.ProjectId}/topics/{init.SubscriptionName}-topic";
            _subscriptionPath      = $"projects/{init.ProjectId}/subscriptions/{init.SubscriptionName}";
            CreateTopicAndSubscriptionOnce();
            ClearSubscription();
            _shouter = new Shouter(init);
        }
Beispiel #9
0
        /// <summary>
        /// Uploads the ictest.bin FPGA-program to the device.
        /// </summary>
        /// <param name="fileName">The name of the file.</param>
        /// <remarks>
        /// I don't fully understand all of the stuff going on in this method, as I have
        /// just used an USB-sniffer to see what TopWin6 does when uploading ictest.bin.
        /// </remarks>
        private void UpLoadFPGAProgramTopWin6Style(string fileName)
        {
            // Prelude of black magic
            BulkDevice.SendPackage(5, new byte[] { 0x0A, 0x1B, 0x00 }, "???");
            BulkDevice.SendPackage(5, new byte[] { 0x0E, 0x21, 0x00, 0x00 }, "Start bitstream upload");
            BulkDevice.SendPackage(5, new byte[] { 0x07 }, "Some kind of finish-up/execute command?");
            BulkDevice.RecievePackage(5, "Some values that maby should be validated in some way");

            var fpgaProgram = new FPGAProgram(fileName);
            var bytesToSend = PackFPGABytes(fpgaProgram.Payload).SelectMany(x => x).ToArray();

            Shouter.ShoutLine(5, fpgaProgram.ToString());
            BulkDevice.SendPackage(5, bytesToSend, "Uploading file: {0}", fileName);

            // Postlude of black magic
            BulkDevice.SendPackage(5, new byte[] { 0x0E, 0x12, 0x00, 0x00 }, "Set Vpp boost off");
            BulkDevice.SendPackage(5, new byte[] { 0x1B }, "???");
            // Why 2 times???
            BulkDevice.SendPackage(5, new byte[] { 0x0E, 0x12, 0x00, 0x00 }, "Set Vpp boost off");
            BulkDevice.SendPackage(5, new byte[] { 0x1B }, "???");
            BulkDevice.SendPackage(5, new byte[] { 0x0E, 0x13, 0x32, 0x00 }, "Set Vcc = 5V");
            BulkDevice.SendPackage(5, new byte[] { 0x1B }, "???");
            BulkDevice.SendPackage(5, new byte[] { 0x0E, 0x15, 0x00, 0x00 }, "Clear all Vcc assignments");
            // Why no 0x1B here???
            BulkDevice.SendPackage(5, new byte[] { 0x0E, 0x17, 0x00, 0x00 }, "Clear all ??? assignments");
            // Why no 0x1B here???
            BulkDevice.SendPackage(5, new byte[] { 0x0A, 0x1D, 0x86 }, "???");
            BulkDevice.SendPackage(5, new byte[] { 0x0E, 0x16, 0x00, 0x00 }, "Clear all Gnd assignments");
            var clueless = new byte[]
            {
                0x3E, 0x00, 0x3E, 0x01, 0x3E, 0x02, 0x3E, 0x03, 0x3E, 0x04, 0x3E, 0x05, 0x3E, 0x06, 0x3E, 0x07,
                0x3E, 0x08, 0x3E, 0x09, 0x3E, 0x0A, 0x3E, 0x0B, 0x3E, 0x0C, 0x3E, 0x0D, 0x3E, 0x0E, 0x3E, 0x0F,
                0x3E, 0x10, 0x3E, 0x11, 0x3E, 0x12, 0x3E, 0x13, 0x3E, 0x14, 0x3E, 0x15, 0x3E, 0x16, 0x3E, 0x17,
                0x07
            };

            BulkDevice.SendPackage(5, clueless, "I´m clueless on this one atm");
            BulkDevice.RecievePackage(5, "Properly answer to clueless that maby should be validated in some way");
            // Again?
            BulkDevice.SendPackage(5, new byte[] { 0x0E, 0x12, 0x00, 0x00 }, "Set Vpp boost off");
            BulkDevice.SendPackage(5, new byte[] { 0x1B }, "???");
            // Again, again???
            BulkDevice.SendPackage(5, new byte[] { 0x0E, 0x12, 0x00, 0x00 }, "Set Vpp boost off");
        }
Beispiel #10
0
        /// <summary>
        /// Entry point for the 'vector' category of commands.
        /// </summary>
        /// <param name="shouter">The shouter instance.</param>
        /// <param name="args">Command line argumsnts</param>
        /// <returns>Exit code. 0 is fine; all other is bad.</returns>
        private static int Vector(Shouter shouter, List <string> args)
        {
            if (args.Count == 1)
            {
                args.Insert(0, "help");
                Help(shouter, args);
                return(0);
            }

            switch (args[1])
            {
            case "test":
                return(Kernel.VectorTest(shouter, args[2]));

            default:
                shouter.ShoutLine(1, "Unknown vector command {0}", args[1]);
                return(1);
            }
        }
Beispiel #11
0
        protected void ShoutLoop()
        {
            // Configue a LogWriter to write to the Windows Event Log.
            var eventLog = new EventLog("Application", ".", "ShoutService");
            var eventLogTraceListener = new FormattedEventLogTraceListener(eventLog)
            {
                Filter = new SeverityFilter(new TraceEventType[] {
                    TraceEventType.Error, TraceEventType.Information, TraceEventType.Warning
                })
            };
            var config = new LoggingConfiguration();

            config.AddLogSource("All", SourceLevels.All, true)
            .AddTraceListener(eventLogTraceListener);
            // A using statement ensures the log gets flushed when this process exits.
            using (var logWriter = new LogWriter(config))
            {
                var shouter = new Shouter(logWriter);
                do
                {
                    shouter.Shout(cancellationTokenSource.Token);
                } while (!cancellationTokenSource.Token.IsCancellationRequested);
            }
        }
Beispiel #12
0
        // Verbosity:
        // 0 totally silent
        // 1 only display fatal errors ie exceptions resulting in abort
        // 2 startup message and few messages
        // 3 ...
        // 4 ...
        // 5 all messages

        /// <summary>
        /// Main entry point for the whole application.
        /// </summary>
        /// <param name="args">Command line arguments.</param>
        /// <returns>Exit code. 0 is fine; all other is bad.</returns>
        public static int Main(string[] args)
        {
            var timestamp = DateTime.Now;
            var shouter   = new Shouter(3);

            try
            {
                var cleanedArgs = new List <string>();
                var options     = new Dictionary <string, string>();
                for (var i = 0; i < args.Length; i++)
                {
                    if (args[i].StartsWith("-"))
                    {
                        if (i == args.Length - 1 || args[i + 1].StartsWith("-"))
                        {
                            throw new U2PaException("Syntax error: option {0} provided without an argument.", args[i]);
                        }
                        options.Add(args[i].TrimStart('-'), args[i + 1]);
                        i++;
                    }
                    else
                    {
                        cleanedArgs.Add(args[i]);
                    }
                }

                if (cleanedArgs.Count == 0 || cleanedArgs[0] == "help")
                {
                    return(Help(shouter, cleanedArgs));
                }

                if (options.ContainsKey("v"))
                {
                    shouter.VerbosityLevel = Int32.Parse(options["v"]);
                }
                else if (options.ContainsKey("verbosity"))
                {
                    shouter.VerbosityLevel = Int32.Parse(options["verbosity"]);
                }

                shouter.ShoutLine(2, "************* U2Pa (C) Elgen 2012 }};-P ***************");
                shouter.ShoutLine(2, "* Alternative software for Top Universal Programmers *");
                shouter.ShoutLine(2, "******************************************************");
                shouter.ShoutLine(2, "Verbosity level: {0}", shouter.VerbosityLevel);
                shouter.ShoutLine(2, "OS: {0}", OsDetector.Platform);
                shouter.ShoutLine(2, "U2Pa initiated at {0}", timestamp);

                var returnCode = 0;
                switch (cleanedArgs[0])
                {
                case "rom":
                    returnCode = Rom(shouter, cleanedArgs);
                    break;

                case "sram":
                    returnCode = SRam(shouter, cleanedArgs);
                    break;

                case "prog":
                    returnCode = Prog(shouter, cleanedArgs);
                    break;

                case "bdump":
                    returnCode = BDump(shouter, cleanedArgs);
                    break;

                case "vector":
                    returnCode = Vector(shouter, cleanedArgs);
                    break;

                case "help":
                    returnCode = Help(shouter, cleanedArgs);
                    break;

                case "dev":
                    returnCode = Dev(shouter, cleanedArgs);
                    break;
                }

                shouter.ShoutLine(2, "Elapsed time: {0}", DateTime.Now - timestamp);

                return(returnCode);
            }
            catch (Exception e)
            {
                shouter.ShoutLine(1, "Fatal error: {0}", e.Message);
                shouter.ShoutLine(5, "Exception:\n{0}", e);
                return(1);
            }
        }
Beispiel #13
0
        /// <summary>
        /// Reads an EPROM.
        /// </summary>
        /// <param name="eprom">The EPROM type.</param>
        /// <param name="progressBar">The progress bar.</param>
        /// <param name="bytes">The list that accumulates the read bytes.</param>
        /// <param name="fromAddress">Start reading this address.</param>
        /// <param name="totalNumberOfAdresses">The total number of adesses.</param>
        /// <returns>The next adress to be read.</returns>
        public int ReadEprom(
            Eprom eprom,
            ProgressBar progressBar,
            IList <byte> bytes,
            int fromAddress,
            int totalNumberOfAdresses)
        {
            const int rewriteCount = 5;
            const int rereadCount  = 5;

            Shouter.ShoutLine(2, "Reading EPROM{0}", eprom.Type);
            SetVccLevel(eprom.VccLevel);
            var translator = eprom.GetPinTranslator(ZIFType);

            ApplyVcc(translator.ToZIF, eprom.VccPins);
            ApplyGnd(translator.ToZIF, eprom.GndPins);
            PullUpsEnable(true);

            var zif           = new ZIFSocket(ZIFType);
            var returnAddress = fromAddress;

            Shouter.ShoutLine(2, "Now reading bytes...");
            progressBar.Init();
            foreach (var address in Enumerable.Range(fromAddress, totalNumberOfAdresses - fromAddress))
            {
                zif.SetAll(true);
                zif.Disable(eprom.GndPins, translator.ToZIF);
                zif.Enable(eprom.Constants, translator.ToZIF);
                zif.Enable(eprom.ChipEnable, translator.ToZIF);
                zif.Enable(eprom.OutputEnable, translator.ToZIF);

                eprom.SetAddress(zif, returnAddress = address);


                ZIFSocket resultZIF = null;
                var       result    = ReadSoundness.TryRewrite;

                for (var i = 0; i < rewriteCount; i++)
                {
                    if (result == ReadSoundness.SeemsToBeAOkay)
                    {
                        break;
                    }

                    if (result == ReadSoundness.TryRewrite)
                    {
                        if (i > 0)
                        {
                            progressBar.Shout("A: {0}; WS: {1}ms", address.ToString("X4"), 100 * i);
                        }
                        WriteZIF(zif, String.Format("A: {0}", address.ToString("X4")));
                        if (i > 0)
                        {
                            Thread.Sleep(100 * i);
                        }
                        result = ReadSoundness.TryReread;
                    }

                    for (var j = 0; j < rereadCount; j++)
                    {
                        if (result != ReadSoundness.TryReread)
                        {
                            break;
                        }

                        if (j > 0)
                        {
                            progressBar.Shout("A: {0}; WS: {1}ms; RS: {2}ms", address.ToString("X4"), 100 * i, 100 * (j * i));
                            Thread.Sleep(100 * (j * i));
                        }
                        var readZifs = ReadZIF(String.Format("for address {0}", address.ToString("X4")));
                        result = Tools.AnalyzeEpromReadSoundness(readZifs, eprom, address, out resultZIF);
                        if (j == rereadCount - 1)
                        {
                            result = ReadSoundness.TryRewrite;
                        }
                        if (result == ReadSoundness.SeemsToBeAOkay && j > 0)
                        {
                            progressBar.Shout("Address: {0} read }};-P", address.ToString("X4"));
                        }
                    }
                }

                if (result != ReadSoundness.SeemsToBeAOkay)
                {
                    return(returnAddress);
                }

                foreach (var b in eprom.GetData(resultZIF))
                {
                    bytes.Add(b);
                }

                progressBar.Progress();
            }
            return(returnAddress + 1);
        }