コード例 #1
0
ファイル: DownParser.cs プロジェクト: wwkkww1983/hydroSW
        //  批量数据Flash下行
        public String BuildQuery_Flash(string sid, EStationType stationType, ETrans trans, DateTime beginTime, DateTime endTime, EChannelType ctype)
        {
            //  构建发送指令的字符串
            StringBuilder sb = new StringBuilder();

            sb.Append(ProtocolMaps.ChannelProtocolStartCharMap.FindValue(ctype));
            sb.Append(String.Format("{0:D4}", Int32.Parse(sid.Trim())));
            sb.Append("0K");

            //   stationtype :  01为水位 02为雨量
            sb.Append(ProtocolHelpers.StationType2ProtoStr_1(stationType));

            //  dayOrHour : 03为按小时传 02为按天传
            //              按小时传  时间格式:   yyMMddHH
            //              按天传   时间格式:   yyMMdd
            sb.Append(ProtocolMaps.TransMap.FindValue(trans));
            switch (trans)
            {
            case ETrans.ByHour:
                sb.Append(beginTime.ToString("yyMMddHH"));
                sb.Append(endTime.ToString("yyMMddHH"));
                break;

            case ETrans.ByDay:
                sb.Append(beginTime.ToString("yyMMdd"));
                sb.Append(endTime.ToString("yyMMdd"));
                break;

            default:
                throw new Exception("传输格式错误");
            }

            sb.Append('\r');
            return(sb.ToString());
        }
コード例 #2
0
        //  批量数据UBatch下行
        public String BuildQuery_UBatch(string sid, EStationType stationType, ETrans trans, DateTime beginTime, EChannelType ctype)
        {
            //  构建发送指令的字符串
            StringBuilder sb = new StringBuilder();

            sb.Append(ProtocolMaps.ChannelProtocolStartCharMap.FindValue(ctype));
            sb.Append(String.Format("{0:D4}", Int32.Parse(sid.Trim())));
            sb.Append("0K");

            //   stationtype :  01为水位 02为雨量
            sb.Append(ProtocolHelpers.StationType2ProtoStr_1(stationType));

            //  时间
            sb.Append(beginTime.ToString("yyMMddHH"));

            sb.Append('\r');
            return(sb.ToString());
        }