public SwampController(ControlSystem cs)
        {
            mySwamp = new Swamp24x8(C_SWAMP_IPID, cs);

            mySwamp.SourcesChangeEvent += new SourceEventHandler(mySwamp_SourcesChangeEvent);
            mySwamp.ZoneChangeEvent    += new ZoneEventHandler(mySwamp_ZoneChangeEvent);

            // Register and if fails, get rid of event handler
            if (mySwamp.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
            {
                ErrorLog.Error("mySwamp failed registration. Cause: {0}", mySwamp.RegistrationFailureReason);
            }
            else
            {
                mySwamp.SourcesChangeEvent -= new SourceEventHandler(mySwamp_SourcesChangeEvent);
                mySwamp.ZoneChangeEvent    -= new ZoneEventHandler(mySwamp_ZoneChangeEvent);
                Initialize();
            }
        }
Exemplo n.º 2
0
        public ControlSystem()
            : base()
        {
            for (int i = 0; i < 20; i++)
            {
                currentZone[i] = new UItoZone();
            }
            //currentZone[0].volumeRoutingEvent += new UItoZone.volumeRoutingHandler(UItoZone.routeVolumeToUI);

            readConfig(@"\NVRAM\AVCONFIG.xml");

            if (this.SupportsEthernet)
            {
                myEISC = new ThreeSeriesTcpIpEthernetIntersystemCommunications(0x90, "127.0.0.2", this);
                myEISC.SigChange += new SigEventHandler(MySigChangeHandler);
                swampA = new Swamp24x8(0x30, this);
                //swampA.SourcesChangeEvent += new SourceEventHandler(swampSpdifEvent);
                swampA.BaseEvent += new BaseEventHandler(swampBaseEvent);
                swampA.ZoneChangeEvent += new ZoneEventHandler(SwampZoneEvent);
                swampA.OnlineStatusChange += new OnlineStatusChangeEventHandler(swampA_OnlineStatusChange);
                if (myEISC.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Error("myEISC failed registration. Cause: {0}", myEISC.RegistrationFailureReason);
                if (swampA.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Error("SWAMP failed registration {0}", swampA.RegistrationFailureReason);
            }
            for (ushort i = 0; i < 5; i++)
            {
                myEISC.StringInput[(ushort)(801 + i)].StringValue = groupNames[i];
            }
            for (ushort i = 1; i <= 24; i++)
            {
                myEISC.StringInput[(ushort)(810 + i)].StringValue = sourceNameArray[i];
            }

            myEISC.UShortInput[151].UShortValue = (ushort)UItoZone.numberOfGroups;
            /*expand.Add(expanderE8[0], 0);
            expand.Add(expanderE8[1], 1);
            expand.Add(expanderE8[2], 2);
            foreach (var expander in expand)
            {
             * expanderE8[i].ZoneChangeEvent += new ZoneEventHandler(zoneEvent);
                if (expander.Key == device)
                {
                    ErrorLog.Notice("expander.Key, args.z.n {0} {1}", expander.Key, args.Zone.Number);
                    
                }
            }*/

            if (numberOfExpanders > 0)
            {
                int numberOfSwampE8 = 0;
                int numberOfSwampE4 = 0;
                int numberOfSwe8 = 0;
                for (int i = 0; i < numberOfExpanders; i++)
                {

                    switch (swampExpanderTypes[i])
                    {
                        case "swampE8":
                            numberOfSwampE8++;
                            maxNumberOfZones += 8;
                            expanderE8[i] = new SwampE8(expanderIDs[i], swampA);
                            expanderE8[i].ZoneChangeEvent += new ZoneEventHandler(E8ZoneEvent);
                            //expand.Add(expanderE8[i], i);
                            //expanderE8[i].ZoneChangeEvent += new zoneEventHandlerz[i](zoneEvent);
                            break;
                        case "swampE4":
                            numberOfSwampE4++;
                            maxNumberOfZones += 4;
                            expanderE4[i] = new SwampE4(expanderIDs[i], swampA);
                            expanderE4[i].ZoneChangeEvent += new ZoneEventHandler(E4ZoneEvent);
                            break;
                        case "SWE8":
                            numberOfSwe8++;
                            maxNumberOfZones += 8;
                            expanderSWE8[i] = new Swe8(expanderIDs[i], swampA);
                            //expanderSWE8[i].ZoneChangeEvent += new ZoneEventHandler(SWE8ZoneEvent);
                            break;
                        default:
                            break;
                    }
                }
                //ErrorLog.Notice("E8, E4, SWE8 {0},{1},{2}", numberOfSwampE8, numberOfSwampE4, numberOfSwe8);
                //ErrorLog.Notice("max#zones {0}", maxNumberOfZones);
                //ErrorLog.Notice("expanders.count {0}", swampA.Expanders.Count);
                //ErrorLog.Notice("expanderNumber type {0} {1}", swampA.Expanders[1].Number, swampA.Expanders[1].ExpanderType);
            }
            // Set the number of threads which you want to use in your program - At this point the threads cannot be created but we should
            // define the max number of threads which we will use in the system.
            // the right number depends on your project; do not make this number unnecessarily large
            Thread.MaxNumberOfUserThreads = 20;


        }