Exemple #1
0
        private void Report(DataSet ds)
        {
            for (int row = 0; row < ds.Tables[0].Rows.Count; row++)
            {
                Message msg = new Message();
                msg.common.project_id = projectId;
                msg.common.gateway_id = gatewayId;
                msg.common.type = MessageType.MESSAGE_TYPE_REPORT;

                if (msg.data == null)
                    msg.data = new DataSection();
                msg.data.operation = MessageType.MESSAGE_TYPE_REPORT;
                msg.data.sequence = ds.Tables[0].Rows[row]["seq"].ToString();
                msg.data.time = ds.Tables[0].Rows[row]["time"].ToString();

                List<Meter> meters = new List<Meter>();

                Meter m = new Meter();
                m.id = ds.Tables[0].Rows[row]["meter"].ToString();

                List<Function> functions = new List<Function>();

                Function f1 = new Function();
                f1.id = ds.Tables[0].Rows[row]["function_Battery_tem"].ToString();
                f1.coding = "192";
                f1.sample_time = ds.Tables[0].Rows[row]["sample_time"].ToString();
                f1.value = ds.Tables[0].Rows[row]["Battery_tem"].ToString();
                functions.Add(f1);

                Function f2 = new Function();
                f2.id = ds.Tables[0].Rows[row]["function_Irr"].ToString();
                f2.coding = "192";
                f2.sample_time = ds.Tables[0].Rows[row]["sample_time"].ToString();
                f2.value = ds.Tables[0].Rows[row]["Irr"].ToString();
                functions.Add(f2);

                Function f3 = new Function();
                f3.id = ds.Tables[0].Rows[row]["function_Sur_tem"].ToString();
                f3.coding = "192";
                f3.sample_time = ds.Tables[0].Rows[row]["sample_time"].ToString();
                f3.value = ds.Tables[0].Rows[row]["Sur_tem"].ToString();
                functions.Add(f3);

                Function f4 = new Function();
                f4.id = ds.Tables[0].Rows[row]["function_Totalampac"].ToString();
                f4.coding = "192";
                f4.sample_time = ds.Tables[0].Rows[row]["sample_time"].ToString();
                f4.value = ds.Tables[0].Rows[row]["Totalampac"].ToString();
                functions.Add(f4);

                m.function = functions.ToArray<Function>();

                meters.Add(m);

                msg.data.meter = meters.ToArray<Meter>();

                string xml = MessageParser.Serialize(msg);
                logger.Debug(xml);

                MessageQueueManager.GetSendQueue(projectId).Enqueue(msg);

            }
        }
Exemple #2
0
        public static Message CreateReportMessage(string projectId, string gatewayId)
        {
            Message msg = new Message();
            msg.common.project_id = projectId;
            msg.common.gateway_id = gatewayId;
            msg.common.type = MessageType.MESSAGE_TYPE_REPORT;

            if (msg.data == null)
                msg.data = new DataSection();
            msg.data.operation = MessageType.MESSAGE_TYPE_REPORT;
            msg.data.sequence = "Z1";
            msg.data.time = String.Format("{0:yyyyMMddHHmmss}", DateTime.Now);

            List<Meter> meters = new List<Meter>();
            for (int i = 1; i < 4; i++)
            {
                Meter m = new Meter();
                m.id = "X1";

                List<Function> functions = new List<Function>();
                for (int j = 0; j < 6; j++)
                {
                    Function f = new Function();
                    f.id = "Y1";
                    f.coding = "Indication" + j.ToString();
                    f.sample_time = String.Format("{0:yyyyMMddHHmmss}", DateTime.Now);
                    f.value = "s";
                    functions.Add(f);
                }
                m.function = functions.ToArray<Function>();

                meters.Add(m);
            }

            msg.data.meter = meters.ToArray<Meter>();

            return msg;
        }