internal Channel(string name, EventScheduler context, XSID xsid)
 {
     m_id        = id++;
     m_name      = name;
     m_context   = context;
     m_phase     = event_phase_t.EVENT_CLOCK_PHI1;
     m_xsid      = xsid;
     sampleEvent = new SampleEvent(this);
     galwayEvent = new GalwayEvent(this);
     for (int i = 0; i < reg.Length; i++)
     {
         reg[i] = 0;
     }
     active = true;
     reset();
 }
        // only used for deserializing
        internal Channel(EventScheduler context, XSID xsid, BinaryReader reader, EventList events)
        {
            m_context = context;
            m_xsid    = xsid;
            LoadFromReader(reader);

            sampleEvent = events.GetEventById(sampleEvent_id) as SampleEvent;
            galwayEvent = events.GetEventById(galwayEvent_id) as GalwayEvent;

#if DEBUG
            if (sampleEvent_id > -1 && sampleEvent == null)
            {
                throw new Exception("Channel: sampleEvent not found: " + sampleEvent_id.ToString());
            }
            if (galwayEvent_id > -1 && galwayEvent == null)
            {
                throw new Exception("Channel: galwayEvent not found: " + galwayEvent_id.ToString());
            }
#endif

            sampleEvent.m_ch = this;
            galwayEvent.m_ch = this;
        }