Exemplo n.º 1
0
 void Start()
 {
     mqttManager            = GameObject.Find("UI Root (3D)").GetComponent <MqttManager>();
     autoControlTempManager = GameObject.Find("UI Root (3D)").GetComponent <AutoControlTempManager>();
     pingPong = false;
     //SendAllButtonSetting();
 }
Exemplo n.º 2
0
    /// <summary>
    /// 버튼 클릭시 서버로 1&0 값을 보낸다.
    /// </summary>
    public void SendSwitchData()
    {
        MqttManager mqttManager = GameObject.Find("UI Root (3D)").GetComponent <MqttManager>();

        if (transform.name == "Button_Power")
        {
            mqttManager.SendPublishButtonData("buttonPower", (mqttManager.PowerButtonState == "1") ? "0" : "1");
        }
        if (transform.name == "Button_Moter_1")
        {
            mqttManager.SendPublishButtonData("button1", (mqttManager.Button_1_State == "1") ? "0" : "1");
        }
        if (transform.name == "Button_Moter_2")
        {
            mqttManager.SendPublishButtonData("button2", (mqttManager.Button_2_State == "1") ? "0" : "1");
        }
        if (transform.name == "Button_Moter_3")
        {
            mqttManager.SendPublishButtonData("button3", (mqttManager.Button_3_State == "1") ? "0" : "1");
        }
        if (transform.name == "Button_Moter_4")
        {
            mqttManager.SendPublishButtonData("button4", (mqttManager.Button_4_State == "1") ? "0" : "1");
        }
    }
 public DaemonService(ILogger <DaemonService> logger,
                      RabbitManager rabbitManager,
                      MqttManager mqttManager,
                      ProgramStartedInformation programStartedInformation)
 {
     _logger                    = logger;
     _rabbitManager             = rabbitManager;
     _mqttManager               = mqttManager;
     _programStartedInformation = programStartedInformation;
 }
 public WindowCoverHandler(ILogger <WindowCoverHandler> logger,
                           IRestClient restClient,
                           WindowCoverConfiguration windowCoverConfiguration,
                           ProgramStartedInformation programStartedInformation,
                           MqttManager mqttManager)
 {
     this.logger     = logger;
     this.restClient = restClient;
     this.windowCoverConfiguration  = windowCoverConfiguration;
     this.programStartedInformation = programStartedInformation;
     this.mqttManager = mqttManager;
 }
Exemplo n.º 5
0
    // Start is called before the first frame update
    void Start()
    {
        //Calculations needed to calibrate the latitude and longitude to the board
        latitudeCentre  = (UpperLatitudeBound + LowerLatitudeBound) / 2;
        longitudeCentre = (RightLongitudeBound + LeftLongitudeBound) / 2;
        latitudeRange   = UpperLatitudeBound - LowerLatitudeBound;
        longitudeRange  = RightLongitudeBound - LeftLongitudeBound;

#if !UNITY_EDITOR
        if (MqttConnection != null && ConnectionId != null)
        {
            MqttManager.ConnectMqttBroker(this, ConnectionId, MqttConnection);
        }
#endif
    }
        public HttpResponseMessage StopDeviceDataRecord(string CompanyCode, string DeviceCode)
        {
            ResultMsg resultMsg = null;

            LoggerManager.Log.Info($"Company<{CompanyCode}>-Device<{DeviceCode}> stop data record.......!\n");

            string mqttTopic = CompanyCode + "/" + DeviceCode + "/StopDataRecord";

            MqttManager.client_MqttMsgPublist(mqttTopic, "");


            resultMsg            = new ResultMsg();
            resultMsg.StatusCode = (int)StatusCodeEnum.Success;
            resultMsg.Info       = "";
            resultMsg.Data       = "";
            return(HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)));
        }
        public bool WriteTagValue(string CompanyCode, string DeviceCode, string TagName, string TagValue)
        {
            bool bSucceed = false;

            LoggerManager.Log.Info("Write tag value!\n");

            string mqttTopic = CompanyCode + "/" + DeviceCode + "/00";

            TagItem[] tagDatas = new TagItem[1];
            tagDatas[0]          = new TagItem();
            tagDatas[0].TagName  = TagName;
            tagDatas[0].TagValue = TagValue;

            string mqttMessage = JsonConvert.SerializeObject(tagDatas);

            MqttManager.client_MqttMsgPublist(mqttTopic, mqttMessage);//"Company1/Device001/00"

            return(bSucceed);
        }
Exemplo n.º 8
0
        public async void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            string mqttServer = _configuration.GetValue <string>(MQTT_SERVER_KEY_NAME, String.Empty);

            if (String.IsNullOrEmpty(mqttServer))
            {
                _logger.LogCritical(JsonConvert.SerializeObject(
                                        new
                {
                    error = "MQTT Server is not set!"
                }
                                        ));
            }

            var options = new ManagedMqttClientOptionsBuilder()
                          .WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
                          .WithClientOptions(new MqttClientOptionsBuilder()
                                             .WithWebSocketServer(mqttServer)
                                             .WithTls().Build())
                          .Build();

            IManagedMqttClient mqttClient = new MqttFactory().CreateManagedMqttClient();

            List <Message> logMessages = new List <Message>();
            MqttManager    mqttManager = new MqttManager(_logger, logMessages);

            mqttClient.UseApplicationMessageReceivedHandler((e) => {
                mqttManager.MessageReceived(e);
            });

            await mqttClient.StartAsync(options);

            services.AddSingleton(mqttClient);
            services.AddSingleton(logMessages);
        }
        public HttpResponseMessage WriteTagValue(string CompanyCode, string DeviceCode, string TagName, string TagValue)
        {
            ResultMsg resultMsg = null;

            LoggerManager.Log.Info("Write tag value!\n");

            string mqttTopic = CompanyCode + "/" + DeviceCode + "/00";

            TagItem[] tagDatas = new TagItem[1];
            tagDatas[0]          = new TagItem();
            tagDatas[0].TagName  = TagName;
            tagDatas[0].TagValue = TagValue;

            string mqttMessage = JsonConvert.SerializeObject(tagDatas);

            MqttManager.client_MqttMsgPublist(mqttTopic, mqttMessage);//"Company1/Device001/00"


            resultMsg            = new ResultMsg();
            resultMsg.StatusCode = (int)StatusCodeEnum.Success;
            resultMsg.Info       = "";
            resultMsg.Data       = "";
            return(HttpResponseExtension.toJson(JsonConvert.SerializeObject(resultMsg)));
        }
Exemplo n.º 10
0
 // Start is called before the first frame update
 private void Start()
 {
     this.TrafficSpawnManager = TrafficSpawnManager.Instance;
     this.MqttManager         = MqttManager.Instance;
 }
Exemplo n.º 11
0
 void Start()
 {
     mqttManager = GameObject.Find("UI Root (3D)").GetComponent <MqttManager>();
 }
 public CoverLevelChangedHandler(ILogger <CoverLevelChangedHandler> logger,
                                 MqttManager mqttManager)
 {
     this.logger      = logger;
     this.mqttManager = mqttManager;
 }
Exemplo n.º 13
0
 public MqttJob() : base(new LogMqttModel())
 {
     mqttManager = MqttManager.Instance;
 }
Exemplo n.º 14
0
 // Start is called before the first frame update
 private void Start()
 {
     this.MqttManager = MqttManager.Instance;
 }
Exemplo n.º 15
0
 public TriggeredSensorHandler(MqttManager mqttManager,
                               ILogger <TriggeredSensorHandler> logger)
 {
     _mqttManager = mqttManager;
     _logger      = logger;
 }
Exemplo n.º 16
0
 public HostedService(SchedulerCenter schedulerCenter)
 {
     this.schedulerCenter = schedulerCenter;
     mqttManager          = MqttManager.Instance;
 }