Ejemplo n.º 1
0
 public void Disconnect()
 {
     if (!m_connected)
     {
         return;
     }
     m_connected = false;
     OnEndFrame();
     OnBusDisconnect();
     m_soundFrame = null;
     if (LoadManager != null)
     {
         LoadManager.Clear();
     }
     m_iconDescList = new IconDescriptor[0];
     if (CommandManager != null)
     {
         CommandManager.Clear();
     }
     if (m_debuggable != null)
     {
         var jtag = FindDevice <IJtagDevice>();
         if (jtag != null)
         {
             jtag.Detach();
         }
     }
     foreach (var device in m_deviceList)
     {
         device.ConfigChanged -= Device_OnConfigChanged;
         try
         {
             device.BusDisconnect();
         }
         catch (Exception ex)
         {
             Logger.Error(ex);
         }
     }
     m_eventManager.Clear();
 }
Ejemplo n.º 2
0
        public bool Connect()
        {
            bool success = true;

            if (m_connected)
            {
                throw new InvalidOperationException("Cannot connect the bus which is already connected!");
            }
            if (m_ula == null)
            {
                throw new InvalidOperationException("ULA device is missing!");
            }
            m_connected = true;
            m_eventManager.Clear();

            m_deviceList.Sort(DevicePriorityComparison);
            for (int i = 0; i < m_deviceList.Count; i++)
            {
                m_deviceList[i].BusOrder = i;
            }
            var soundRenderers = m_deviceList.OfType <ISoundRenderer>();

            foreach (var soundRenderer in soundRenderers)
            {
                soundRenderer.SampleRate = SampleRate;
            }
            if (LoadManager != null)
            {
                LoadManager.Clear();
            }
            m_iconDescList = new IconDescriptor[] { m_iconPause };
            if (CommandManager != null)
            {
                CommandManager.Clear();
            }
            foreach (var device in m_deviceList)
            {
                try
                {
                    device.BusInit(this);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    success = false;
                }
            }
            m_frameTactCount = m_ula.FrameTactCount;
            foreach (var device in m_deviceList)
            {
                device.ConfigChanged += Device_OnConfigChanged;
                try
                {
                    device.BusConnect();
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    success = false;
                }
            }
            OnBeginFrame();
            if (m_debuggable != null)
            {
                var jtag = FindDevice <IJtagDevice>();
                if (jtag != null)
                {
                    jtag.Attach(m_debuggable);
                }
            }
            m_soundFrame = new FrameSound(
                SampleRate,
                soundRenderers.Select(sr => sr.AudioBuffer));
            OnBusConnected();
            return(success);
        }