Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ser"></param>
        /// <param name="type"></param>
        /// <param name="XX">日</param>
        /// <param name="YY">时</param>
        /// <param name="ZZ">分钟</param>

        public DataItem_C105(byte ser, ReportCycleType type, int XX, int YY, int ZZ)
        {
            this.dataUnits    = new byte[7];
            this.dataUnits[0] = 0xC1;
            this.dataUnits[1] = 0x05;
            this.dataUnits[2] = ser;
            this.type         = type;
            this.XX           = XX;
            this.YY           = YY;
            this.ZZ           = ZZ;
        }
Exemplo n.º 2
0
        private void btn_c105_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txt_xx.Text) || string.IsNullOrEmpty(this.txt_yy.Text) || string.IsNullOrEmpty(this.txt_zz.Text))
            {
                MessageBox.Show("上传周期不能为空"); return;
            }

            ReportCycleType type = (ReportCycleType)(Convert.ToInt32(this.combox_SBtype.SelectedValue));

            int xx = int.Parse(this.txt_xx.Text.Trim());
            int yy = int.Parse(this.txt_yy.Text.Trim());
            int zz = int.Parse(this.txt_zz.Text.Trim());


            DataItem item = new DataItem_C105(00, type, xx, yy, zz);

            CYWriteDataCmdSend(item);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 设置上传周期
        /// </summary>
        /// <param name="info"></param>
        /// <param name="meter"></param>
        /// <returns></returns>
        public string SetUploadCycle(IoT_SetUploadCycle info, IoT_UploadCycleMeter meter)
        {
            string result = "";

            try
            {
                MongoDBHelper <Task> mongo_task = new MongoDBHelper <Task>();
                Task task = new Task();
                task.MeterMac  = meter.MeterNo.Trim();
                task.TaskDate  = QuShi.getDate();
                task.TaskID    = Guid.NewGuid().ToString(); //用于和指令进行进行关联
                task.TaskState = TaskState.Waitting;
                task.TaskType  = TaskType.TaskType_设置上传周期;  //
                //写任务
                mongo_task.Insert(CollectionNameDefine.TaskCollectionName, task);
                meter.TaskID = task.TaskID;

                /*上传周期模式:
                 * 00:以月为周期,在每个月的XX日YY时ZZ分上传数据;
                 * 01:以XX天为周期,在每XX天的YY时ZZ分上传数据,起点为每月的01日00时00分;
                 * 02:以YY时为周期,在每YY小时的ZZ分上传数据,起点为每天的00时00分;
                 * 03:以燃气表启动开始计时,以XX日YY时ZZ分上传数据
                 */
                ReportCycleType cycleType = ReportCycleType.时周期;

                if (info.ReportType == "00")
                {
                    cycleType = ReportCycleType.月周期;
                }
                else if (info.ReportType == "01")
                {
                    cycleType = ReportCycleType.天周期;
                }
                else if (info.ReportType == "02")
                {
                    cycleType = ReportCycleType.时周期;
                }
                else if (info.ReportType == "03")
                {
                    cycleType = ReportCycleType.周期采集;
                }

                /*周期参数,
                 * DD 天    范围:00-31
                 * HH 小时  范围:00-23
                 * MM 分钟  范围:00-59*/
                int DD = 1;
                int HH = 23;
                int MM = 59;
                try
                {
                    DD = Convert.ToInt32(info.Par.Substring(0, 2));
                    HH = Convert.ToInt32(info.Par.Substring(2, 2));
                    MM = Convert.ToInt32(info.Par.Substring(4, 2));
                }
                catch
                { }

                //2.设置上传周期
                DataItem_C105 item_C105 = new DataItem_C105(Convert.ToByte(new Random().Next(0, 255)), cycleType, DD, HH, MM);
                item_C105.type = (ReportCycleType)Convert.ToByte(info.ReportType);
                item_C105.XX   = Convert.ToUInt16(info.Par.Substring(0, 2));
                item_C105.YY   = Convert.ToUInt16(info.Par.Substring(2, 2));
                item_C105.ZZ   = Convert.ToUInt16(info.Par.Substring(4, 2));

                Command cmd = new Command();
                cmd.TaskID         = task.TaskID;
                cmd.Identification = ((UInt16)item_C105.IdentityCode).ToString("X2");
                cmd.ControlCode    = (byte)ControlCode.CYWriteData;//设置参数
                cmd.DataLength     = Convert.ToByte(item_C105.Length);
                cmd.DataCommand    = MyDataConvert.BytesToHexStr(item_C105.GetBytes());
                cmd.Order          = 2;
                CommandDA.Insert(cmd);
            }
            catch (Exception e)
            {
                result = e.Message;
            }
            return(result);
        }
Exemplo n.º 4
0
 private void JieXiUploadCycle(string par, ref ReportCycleType cycleType, ref int day, ref int hour, ref int minute)
 {
 }