public RequestProcessor(SchedulingCore scheduler, KnobSet knob, AudioCore audio, FileCore files)
 {
     _audio = audio;
     _knob = knob;
     _scheduler = scheduler;
     _fileSystem = files;
 }
        public LocalControlModule(ILCDCharDisplay display, IRotaryEncoder encoder, AudioCore audio)
        {
            LcmActivated = false; // this module is default in-active

            _display = display;
            _encoder = encoder;
            _audio = audio;
            Keyboard2.Clear();
            //Keyboard2.Clear();
        }
Ejemplo n.º 3
0
        public SchedulingCore(AudioCore audio, ILCDCharDisplay charDisplay, LocalControlModule lcm)
        {
            _audio = audio;
            _display = charDisplay;
            _lcm = lcm;

            MediaEntries = new ArrayList();
            LoadScheduleFile();

            var t = new Thread(ScheduleThread) { Priority = ThreadPriority.BelowNormal };
            t.Start();
        }
Ejemplo n.º 4
0
        public void AddItem(AudioCore.MediaEntry item, SchedulingCore.InsertMode insertMode, int index)
        {
            item.TaskSource = AudioCore.MediaEntry.Source.Knob;
            item.EndTime = TimeSpan.MinValue;

            if (index == -1)
            {
                lock (_lock)
                    KnobEntries.Add(item);

                SaveSchedule();

                return;
            }

            try
            {
                switch (insertMode)
                {
                    case SchedulingCore.InsertMode.After:
                        KnobEntries.Insert(index + 1, item);
                        break;

                    case SchedulingCore.InsertMode.Before:
                        KnobEntries.Insert(index, item);
                        break;

                    case SchedulingCore.InsertMode.Replace:
                        KnobEntries[index] = item;
                        break;
                }
            }
            catch
            {
                lock (_lock)
                    KnobEntries.Add(item);
            }

            SaveSchedule();
        }
Ejemplo n.º 5
0
        public KnobSet(IRotaryEncoder rotaryEncoder, ILCDCharDisplay charDisplay, AudioCore audio, SchedulingCore scheduler, LocalControlModule lcm)
        {
            PlayModeActivated = true;
            _audio = audio;
            _lcm = lcm;
            _currentButtonState = (ButtonState) (-1);
            _position = -1;
            _playingPosition = -1;
            _playing = false;
            _isKnobPressed = false;
            KnobEntries = new ArrayList();

            _encoder = rotaryEncoder;

            // TODO : Optimize is to not to install eventhandlers when knob is disabled by user settings
            // TODO : also no need to load the knob file
            _encoder.RotaryMoved += EncoderMoved;
            _encoder.ButtonStateChanged += EncoderButtonStateChanged;
            _encoder.RotaryMoved += _lcm.EncoderMoved;

            Parse();
        }
Ejemplo n.º 6
0
 public WebServer(SchedulingCore scheduler, KnobSet knob, AudioCore audio, FileCore files)
 {
     _processor = new RequestProcessor(scheduler, knob, audio, files);
 }
Ejemplo n.º 7
0
 private void OnPositionChanged(AudioCore.MediaEntry item)
 {
     if (PositionChanged != null)
         PositionChanged(item);
 }
Ejemplo n.º 8
0
        public void AddItem(AudioCore.MediaEntry item, InsertMode insertMode, int index)
        {
            item.TaskSource = AudioCore.MediaEntry.Source.Schedule;

            // B73 : 2014-10-20 Changed
            //            item.NextEligibility = DateTime.Now;
            //            if (PlaysNow(item) && item.Every == 0)
            //                item.NextEligibility = item.NextEligibility.Date.AddDays(1);

            DateTime n2;
            DateTime now = DateTime.Now;
            var startTime = new DateTime(now.Year, now.Month, now.Day) + new TimeSpan(item.StartTime.Ticks);

            if (item.Every != 0)
            {
                while (true)
                {
                    if (startTime > now)
                    {
                        n2 = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.TimeOfDay.Hours, startTime.TimeOfDay.Minutes, startTime.TimeOfDay.Seconds);
                        break;
                    }
                    startTime += new TimeSpan(0, item.Every, 0);
                }
            }
            else
            {
                n2 = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.TimeOfDay.Hours, startTime.TimeOfDay.Minutes, startTime.TimeOfDay.Seconds);
                if (n2 < now)
                    n2 += new TimeSpan(1, 0, 0, 0); // = startTime > DateTime.Now ? startTime : startTime.AddDays(1);
            }
            item.NextEligibility = n2;

            if (index == -1)
            {
                lock (_lockObject)
                    MediaEntries.Add(item);
            }
            else
            {
                try
                {
                    switch (insertMode)
                    {
                        case InsertMode.After:
                            lock (_lockObject)
                                MediaEntries.Insert(index + 1, item);
                            break;

                        case InsertMode.Before:
                            lock (_lockObject)
                                MediaEntries.Insert(index, item);
                            break;

                        case InsertMode.Replace:
                            lock (_lockObject)
                                MediaEntries[index] = item;
                            break;
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteException(ex, "item:" + item.Name + " insertmode:" + insertMode + " index:" + index);
                }
            }
            SaveSchedule();
        }
Ejemplo n.º 9
0
        // It is assumed that entry.NextEligibility is properly initialised to the first candidate date/time to play
        private bool PlaysNow(AudioCore.MediaEntry entry)
        {
            DateTime now = DateTime.Now;
            bool playsToday = false;

            if (entry.NextEligibility > now || entry.EndTime <= now.TimeOfDay) // this compare includes both date and time compare
            {
                //DebugHelper.DebugPrint("");
                // DebugHelper.Print(entry.Name + " No candidate. Needs to play on: " + entry.NextEligibility + "." + entry.NextEligibility.Millisecond + " and before: " + entry.EndTime);
                return false;
            }

            //DebugHelper.DebugPrint("");
            //DebugHelper.Print(entry.Name + " Candidate. Needs to play on:" + entry.NextEligibility + "." + entry.NextEligibility.Millisecond);
            //DebugHelper.DebugPrint("");

            switch (entry.Type)
            {
                case AudioCore.MediaEntry.PlayType.SpecificDate:
                    playsToday = now.Date == entry.PlayDate.Date;
                    break;
                case AudioCore.MediaEntry.PlayType.DayOfWeek:
                    playsToday = now.DayOfWeek == entry.PlayDay;
                    break;
                case AudioCore.MediaEntry.PlayType.Weekdays:
                    playsToday = (now.DayOfWeek != DayOfWeek.Sunday && now.DayOfWeek != DayOfWeek.Saturday);
                    break;
                case AudioCore.MediaEntry.PlayType.Weekends:
                    playsToday = (now.DayOfWeek == DayOfWeek.Sunday || now.DayOfWeek == DayOfWeek.Saturday);
                    break;
                case AudioCore.MediaEntry.PlayType.Interval:
                case AudioCore.MediaEntry.PlayType.Daily:
                    playsToday = true;
                    break;
            }
            if (!playsToday)
            {
                //DebugHelper.DebugPrint("Rejected NO proper day");
                return false;
            }
            //DebugHelper.DebugPrint("Day fits");
            return true;
        }
Ejemplo n.º 10
0
        public Scii()
        {
            _lcdDisplay = new CharDisplay();

            PrintScreen("Schedulon II", "by Technomad LLC");
            Thread.Sleep(1000);
            PrintScreen("Audio.", "       Anywhere.");
            Thread.Sleep(1000);
            _lcdDisplay.Clear();
            PrintScreen("Schedulon II");

            Log.LogFileName = Settings.FileSystem.RootDir + Settings.FileSystem.SystemDir + @"log\logfile.txt";
            Log.InsertBlankLine();
            Log.WriteString(LogMessageType.Info, "Application start");

            IRotaryEncoder rotaryEncoder = new RotaryEncoder();
            IAudioRecordPlayer audioplayer = new AudioPlayer();

            var audioCore = new AudioCore(audioplayer);
            audioCore.NowPlaying += OnNowPlaying;
            audioCore.NowRecording += OnNowRecording;

            var lcm = new LocalControlModule(_lcdDisplay, rotaryEncoder, audioCore);
            var schedulingCore = new SchedulingCore(audioCore, _lcdDisplay, lcm);

            var knobSet = new KnobSet(rotaryEncoder, _lcdDisplay, audioCore, schedulingCore, lcm);

            var fileCore = new FileCore();

            try
            {
                Settings.Load();
            }
            catch (Exception e)
            {
                Log.WriteException(e, "Error loading system settings. System locked");
                PrintScreen("System halted", "Settings error");
                Thread.Sleep(Timeout.Infinite);
            }

            if (Settings.Web.UseLlmnr)
            {
                _llmnr = new LinkLocalMultiCastNameResolution("Schedulon");
                _llmnr.Start(IPAddress.Parse("10.0.0.110"));
            }

            var webServer = new WebServer(schedulingCore, knobSet, audioCore, fileCore);

            var webserverThread = new Thread(webServer.Run);
            webserverThread.Start();
        }