Пример #1
0
        public FutabaMDM166A_AdvancedSetupForm(LedDisplay ld)
        {
            InitializeComponent();

            this.ld = ld;       // get the current leddisplay for color and other settings
            bits    = 0;        // empty display
        }
Пример #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            audioPlayingDetector   = new AudioStatusDetector(DataFlow.Render);
            audioCapturingDetector = new AudioStatusDetector(DataFlow.Capture);
            form = new OnAirForm();
            form.OnTick(Timer);
            form.OnClose(Close);
            var logger = new ConsoleLogger(LogLevel.Debug);

            display = new LedDisplay(logger);
            Application.Run(form);
        }
Пример #3
0
        /// <summary>
        /// 停止声光报警动作
        /// 停止当前预案动作,然后恢复上一预案动作
        /// </summary>
        /// <param name="plan"></param>
        public static void Stop(Plan plan)
        {
            var actionId      = plan.PlanTrigger != null ? plan.PlanTrigger.AlarmLogId.Value : plan.PlanId;
            var outTimeAction = s_SoundLightActionRecords.FirstOrDefault(t => t.ActionId.Equals(actionId));

            if (outTimeAction != null && outTimeAction.Actions != null && outTimeAction.Actions.Count > 0)
            {
                _logger.LogInformation("停止声光报警动作 Begin...");
                ASCSApi    api = null;
                List <int> soundLightDeviceCode = new List <int>();
                foreach (var action in outTimeAction.Actions)
                {
                    action.SoundLightControl.Audio      = string.Empty;
                    action.SoundLightControl.Ledbitmask = 0;
                    action.SoundLightControl.Message    = string.Empty;
                    api = new ASCSApi(action.Ascs);
                    _logger.LogInformation("下发停止声光报警联动协议: \r\n:{0}", JsonUtility.CamelCaseSerializeObject(action.SoundLightControl));
                    api.SendSoundLightAction(action.SoundLightControl);
                    soundLightDeviceCode.Add(action.SoundLightControl.DeviceCode);
                }
                LedDisplay ledDisopay = new LedDisplay()
                {
                    Flag         = 2,
                    Text         = string.Empty,
                    TerminalCode = soundLightDeviceCode.ToArray()
                };
                _logger.LogInformation("下发恢复声光报警时间显示: \r\n:{0}", JsonUtility.CamelCaseSerializeObject(ledDisopay));
                api.ControLedDisplayl(ledDisopay);
                s_SoundLightActionRecords.Remove(outTimeAction);
                _logger.LogInformation("停止声光报警动作 End...");

                //执行下动作
                if (s_SoundLightActionRecords.Count > 0)
                {
                    _logger.LogInformation("恢复播放上一声光报警动作 begin!!");
                    var record = s_SoundLightActionRecords.Last();
                    foreach (var action in record.Actions)
                    {
                        api = new ASCSApi(action.Ascs);
                        api.SendSoundLightAction(action.SoundLightControl);
                    }
                    _logger.LogInformation("恢复播放上一声光报警动作 end!!");
                }
                else
                {
                    _logger.LogInformation("当前没有要恢复的声光报警动作");
                }
            }
        }
        static void Main(string[] args)
        {
            LedDisplay display = new LedDisplay(32, 16, SerialPort.GetPortNames()[0]);

            display.OpenSerial();

            display.DrawBitmap(new Bitmap("bitmap.bmp"), 0, 0, 32, 16);
            display.RefreshDisplay();

            for (byte i = 255; i > 0; i -= 5)
            {
                Console.WriteLine("Brightness: " + i);
                display.SetBrightness(i);
                Thread.Sleep(250);
            }
        }
        static void Main(string[] args)
        {
            LedDisplay display = new LedDisplay(32, 16, SerialPort.GetPortNames()[0]);

            display.OpenSerial();
            display.SetBrightness(175);

            while (true)
            {
                display.ClearDisplay();

                String time = DateTime.Now.ToString("HH:mm");
                display.DrawString(0, 4, LedColor.Red, time, 0, Fonts.Font6X8);

                display.RefreshDisplay();
                Thread.Sleep(2000);
            }
        }
Пример #6
0
        static void Main(string[] args)
        {
            LedDisplay display = new LedDisplay(32, 16, SerialPort.GetPortNames()[0]);

            display.OpenSerial();

            display.SetBrightness(120);
            display.FillDisplay(LedColor.White);
            display.RefreshDisplay();
            Thread.Sleep(1000);

            Console.WriteLine("Drawing Lines");
            display.DrawLine(0, 0, 5, 10, LedColor.Red);
            display.DrawLine(5, 0, 10, 10, LedColor.Green);
            display.DrawLine(10, 0, 15, 10, LedColor.Blue);
            display.RefreshDisplay();
            Thread.Sleep(1000);

            Console.WriteLine("Drawing circles");
            display.ClearDisplay();
            display.DrawCircle(12, 6, 5, LedColor.Yellow);
            display.RefreshDisplay();
            Thread.Sleep(1000);

            Console.WriteLine("Drawing rectangles");
            display.ClearDisplay();
            display.DrawRectangle(0, 0, 10, 12, LedColor.Orange, LedColor.Cyan);
            display.DrawRectangle(15, 0, 18, 4, LedColor.Purple);
            display.RefreshDisplay();
            Thread.Sleep(1000);


            Console.WriteLine("Drawing text");
            String time = DateTime.Now.ToString("HH:mm");

            display.ClearDisplay();
            display.DrawString(0, 0, LedColor.Blue, time, 0, Fonts.Font6X8);
            display.RefreshDisplay();

            Console.ReadKey();
        }
Пример #7
0
 /// <summary>
 /// LED 文字显示控制
 /// </summary>
 /// <param name="ledDisplay"></param>
 /// <returns></returns>
 public HttpRequestResult ControLedDisplayl(LedDisplay ledDisplay)
 {
     //if (ASCS == null)
     //    throw new Exception("请配置哨位中心服务!");
     try
     {
         string url = string.Format(@"http://{0}:{1}/ASCS/LedDisplay  ",
                                    ASCS.EndPoints[0].IPAddress, ASCS.EndPoints[0].Port);
         _logger.LogInformation("LED文字显示控制 Begin.\r\nUrl:{0}.\r\nProtocol:{1}", url, JsonUtility.CamelCaseSerializeObject(ledDisplay));
         var result = HttpClientHelper.Post <LedDisplay>(ledDisplay, url, Encoding.GetEncoding("gb2312"));
         _logger.LogInformation("LED文字显示控制 End ,return {0}", result);
         return(result);
     }
     catch (Exception ex)
     {
         return(new HttpRequestResult()
         {
             Success = false, ResultText = ex.Message
         });
     }
 }
        static void Main(string[] args)
        {
            int  frames    = 5000;
            bool benchmark = true; // Set to false if you want to loop forever

            LedDisplay display = new LedDisplay(32, 16, SerialPort.GetPortNames()[0]);

            display.OpenSerial();

            // Prepare pallete
            LedColor[] palette = new LedColor[360];
            for (int x = 0; x < 360; x++)
            {
                int r, g, b;
                HsvToRgb(x, 1.0, 1.0, out r, out g, out b);
                palette[x] = new LedColor {
                    R = (byte)r,
                    G = (byte)g,
                    B = (byte)b
                };
            }

            int[,] cls = null;
            int start = Environment.TickCount;
            int i     = 0;

            while (i < frames)
            {
                int w = 32;
                int h = 16;

                if (cls == null)
                {
                    cls = new int[w, h];
                    for (int x = 0; x < w; x++)
                    {
                        for (int y = 0; y < h; y++)
                        {
                            cls[x, y] = (int)(
                                128.0 + (128.0 * Math.Sin(x / 2.0))
                                + 128.0 + (128.0 * Math.Sin(y / 4.0))
                                + 128.0 +
                                (128.0 * Math.Sin(Math.Sqrt(((x - w / 2.0) * (x - w / 2.0) + (y - h / 2.0) * (y - h / 2.0))) / 2.0))
                                + 128.0 + (128.0 * Math.Sin(Math.Sqrt((x * x + y * y)) / 2.0))
                                ) / 4;
                        }
                    }
                }

                int paletteShift = Convert.ToInt32(Environment.TickCount / 5);
                for (int x = 0; x < w; x++)
                {
                    for (int y = 0; y < h; y++)
                    {
                        display.DrawPixel(x, y, palette[(cls[x, y] + paletteShift) % 360]);
                    }
                }

                display.RefreshDisplay();
                if (benchmark)
                {
                    i++;
                }
            }

            int    elapsed   = Environment.TickCount - start;
            double fps       = frames / (elapsed / 1000.0);
            double bits      = (fps * ((32 * 16 * 3) + 1) * 8) / 1000;
            double bandwidth = (bits / 12000) * 100;

            Console.WriteLine("Time elapsed: " + elapsed);
            Console.WriteLine("Frames per second: " + fps);
            Console.WriteLine("kb/s: " + bits + " (" + bandwidth + "% of maximum theoritical serial output)");
            Console.ReadKey();
        }
Пример #9
0
        public Trainer(ET3400Settings settings, PictureBox displayTarget)
        {
            Memory            = new int[65536];
            Breakpoints       = new BreakpointCollection();
            Settings          = settings;
            Watches           = new List <Watch>();
            MemoryMapManager  = new MemoryMapManager();
            MemoryMapEventBus = new MemoryMapEventBus();


            _mc6820 = new MC6820();
            _debugConsoleAdapter       = new DebugConsoleAdapter();
            _mc6820.OnPeripheralWrite += OnPeripheralWrite;
            _mc6820.OnPeripheralRead  += OnPeripheralRead;

            Settings.SettingsUpdated += (sender, args) =>
            {
                Runner.Recalibrate();
            };

            State = new Cpu6800State();

            Emulator = new Cpu6800
            {
                State = State,

                ReadMem = address =>
                {
                    address = address & 0xFFFF;

                    if (address >= 0x1000 && address <= 0x1003)
                    {
                        //_mc6820.RegisterSelect(address & 3);
                        //return _mc6820.Get();
                        return(_mc6820.Get(address & 3));
                    }

                    //foreach (var watch in Watches.ToList())
                    //{
                    //    if (watch.EventType == EventType.Read)
                    //    {
                    //        //if (watch.Address == address)
                    //        //{

                    //        //}
                    //        watch.Action(new WatchEventArgs() { Address = address });
                    //    }
                    //}

                    return(Memory[address]);
                },

                WriteMem = (address, value) =>
                {
                    address = address & 0xFFFF;

                    foreach (var watch in Watches.ToList())
                    {
                        if (watch.EventType == EventType.Write)
                        {
                            //if (watch.Address == address)
                            //{

                            //}

                            watch.Action(new WatchEventArgs()
                            {
                                Address = address
                            });
                        }
                    }

                    if (address >= 0x1000 && address <= 0x1003)
                    {
                        //_mc6820.RegisterSelect(address & 3);
                        //_mc6820.Set(value);
                        _mc6820.Set(address & 3, value);
                        return;
                    }

                    if (address >= 0x1400 && address <= 0x1BFF)
                    {
                        // Prevent writing to ROM-mapped space
                        return;
                    }

                    if (address >= 0x1C00 && address <= 0x23FF)
                    {
                        // Prevent writing to ROM-mapped space
                        return;
                    }

                    if (address >= 0xFC00)
                    {
                        // Prevent writing to ROM-mapped space
                        return;
                    }

                    // Limit writing to RAM addresses only?
                    Memory[address] = value;
                }
            };

            //Runner = new StandardRunner(this);
            Runner = new CycleExactRunner(this);

            _display        = new LedDisplay(displayTarget, this);
            Runner.OnSleep += OnSleep;

            // Set keyboard mapped memory 'high'
            Memory[0xC003] = 0xFF;
            Memory[0xC005] = 0xFF;
            Memory[0xC006] = 0xFF;
        }
Пример #10
0
        /// <summary>
        /// 生成卷烟品牌的图片
        /// 其中每5个品牌为一个组
        /// 图片640的宽度只能放下5个品牌名称
        /// </summary>
        /// <param name="picture"></param>
        /// <param name="startledgroup">起始组</param>
        /// <param name="endledgroup">结束组</param>
        /// <param name="filename">保存文件名</param>
        /// <returns></returns>
        public bool CreateCigNamePic(PictureBox picture, int startledgroup, int endledgroup, string filename)
        {
            try
            {
                Bitmap image = new Bitmap(640, 192);
                int    left  = image.Height / 2 - 18;
                int    top   = -image.Width / 2;
                //创建Graphics类对象
                Graphics g = Graphics.FromImage(image);
                //设置旋转中心点
                g.TranslateTransform(image.Width / 2, image.Height / 2);
                //设置旋转角度
                g.RotateTransform(-90);


                LedDisplay ledDisplay = new LedDisplay();
                ledDisplay.GetLedLineboxs();


                //将文本生成到图片框内
                int leftoffset = 1;
                for (int i = startledgroup; i <= endledgroup; i++)
                {
                    //按组获取显示的名称拼成字符串
                    string ledstring = ledDisplay.GetCigNames(i);

                    int topmove = 0;
                    foreach (char c in ledstring)
                    {
                        //画名称
                        g.DrawString(c.ToString(), Font, new SolidBrush(Color.Red), left - ((leftoffset - 1) * 16), top + topmove);
                        topmove += 16;
                    }
                    leftoffset++;

                    //LED屏有问题必须写空两行再写 
                    int j = 1;
                    if (i == 2 || i == 8)
                    {
                        //写两行空白字符
                        while (j++ <= 2)
                        {
                            //空白字符
                            ledstring = "                                        ";

                            topmove = 0;
                            foreach (char c in ledstring)
                            {
                                //画名称
                                g.DrawString(c.ToString(), Font, new SolidBrush(Color.Red), left - ((leftoffset - 1) * 16), top + topmove);
                                topmove += 16;
                            }
                            leftoffset++;
                        }
                    }
                }
                g.ResetTransform();


                //显示生成的图片
                picture.Image = (Image)image;
                picture.Image.Save(filename, ImageFormat.Bmp);


                Stream path = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
                Image  img  = new Bitmap(path);
                picture.Image = img;
                path.Close();
                path.Dispose();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }