Ejemplo n.º 1
0
        protected override void OnStart(string[] args)
        {
            t = new Timer(10000); // Timer de 10 secondes.
            t.Elapsed += new ElapsedEventHandler(t_Elapsed);
            t.Start();
            // create client instance
            MqttClient client = new MqttClient("test.mosquitto.org");

            client.Connect("SMO_IoT_WindowsService", null, null);
            // publish a message on "/home/temperature" topic with QoS 2
            IoT_Topics iot = new IoT_Topics();
            Iot_Constants IOTCONST = new Iot_Constants();
            string sTopic = iot.Get_Topics("", "");
            client.Publish("ou", Encoding.UTF8.GetBytes(sTopic));
        }
Ejemplo n.º 2
0
        public string Get_Topics(string MachineOrObjet, string Unit, string Localisation)
        {
            sTopics = "";
            Iot_Constants IOTCONST = new Iot_Constants();

            try
            {
                sMachineOrObjet = MachineOrObjet;
                sUnit = Unit;
                sLocalisation = Localisation;
                CreationDate = DateTime.UtcNow;
                sTopics = IOTCONST.sFirstTopicArgument + sMachineOrObjet + "/" + CreationDate + "/" + sUnit + "/" + Localisation;
                return sTopics;
            }
            catch (Exception e)
            {
                sTopics = "/SMOIOT/Error/Exception" + e.Message;
                return sTopics;
            }
        }
Ejemplo n.º 3
0
        public string Get_Topics(string Unit, string Localisation)
        {
            sTopics = "";
            Iot_Constants IOTCONST = new Iot_Constants();
            try
            {
                Iot_Machine mach = new Iot_Machine();
                sMachineOrObjet = mach.GetMachineName();
                sUnit = Unit;
                sLocalisation = Localisation;
                CreationDate = DateTime.UtcNow;
                Iot_Machine iotmachine = new Iot_Machine();

                sTopics = IOTCONST.sFirstTopicArgument + iotmachine.GetMachineName() + "/" + CreationDate + "/" + sUnit + "/" + Localisation;
                return sTopics;
            }
            catch (Exception e)
            {
                sTopics = "/SMO_IoT/Error/Exception" + e.Message;
                return sTopics;
            }
        }