Exemplo n.º 1
0
        protected override void OnSetupMessageQueue()
        {
            ServiceMQ serviceMQ = (ServiceMQ)getServiceByName(CoreDaemonService.SERVICE_ID_MQ);

            if (serviceMQ != null)
            {
                serviceMQ.CreateServerControlQueue(callbackControlMessageHandler);
                serviceMQ.CreateStateQueue(callbackStateMessageHandler);
            }
        }
Exemplo n.º 2
0
        private async Task _InitializeServices()
        {
            ZoneGuardConfigContextFactory factory = new ZoneGuardConfigContextFactory();

            using (ZoneGuardConfigContext context = factory.CreateDbContext())
            {
                /***************************************************************
                *
                *  Load Services
                *
                ***************************************************************/
                List <ThingDAL> services = await context.Thing
                                           .Where <ThingDAL>(t => t.ThingType == ThingType.Service)
                                           .Include(p => p.Parameters)
                                           .ToListAsync <ThingDAL>();

                foreach (ThingDAL serviceDAL in services)
                {
                    Console.WriteLine(serviceDAL.Name);
                    ConfigService configService = ZoneGuardConfigContextFactory.CreateThingFromDAL <ConfigService>(serviceDAL);

                    Console.WriteLine(configService.toJSON());

#if warning
#endif
                    //TODO:: MUST
                    //TODOO:: MIGRATE                    addSensor(new SensorProxy(configSensor, this), false);
                    ServiceCore service = null;
                    String      s       = configService.ConfigClass;
                    if (configService.ConfigClass == "ConfigServiceMQTT")
                    {
                        service = new ServiceMQTT((ConfigServiceMQTT)configService, this);
                    }
                    else if (configService.ConfigClass == "ConfigServiceMQ")
                    {
                        service = new ServiceMQ((ConfigServiceMQ)configService, this);
                    }
                    if (service != null)
                    {
                        addService(service);
                    }
                    else
                    {
                        Logger.LogWarning("Service '{0}' not created.", configService.Id);
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void PublishSensorState(SensorStateMessage ssm)
 {
     ServiceMQ.Publish(ServiceMQ.EXCHANGE_STATE, "", ssm.toJSON());
 }