欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

分支数据监测终端(操作07 添加传感器档案单元)

程序员文章站 2022-07-14 20:54:03
...

698 OOP协议:

1、读取请求05:

读取一个对象属性GetRequestNormal
分支数据监测终端(操作07 添加传感器档案单元)

读取多个对象属性 GetRequestNormalList
分支数据监测终端(操作07 添加传感器档案单元)

2、设置请求06:

分支数据监测终端(操作07 添加传感器档案单元)

对象属性描述符OAD(Object Attribute Descriptor)

分支数据监测终端(操作07 添加传感器档案单元)
上图中对象标识 OI 后面接的是 属性标识、特征以及属性内元素索引。
例:
分支数据监测终端(操作07 添加传感器档案单元)

3、操作请求 07:

分支数据监测终端(操作07 添加传感器档案单元)

分支数据监测终端(操作07 添加传感器档案单元)
对于下图 属性2(读取多回路 温度)应该是05 01请求读取属性 2E10 0200

        case 0x2E100200:      // 读取05 01多回路温度属性2
				mem_cpy(resp + pos, oad->value, 4);     
                pos += 4;
                if((temp_smoke_dev_count == 0) && (first_read_AM2320_flag1 == 0))
                {
                    resp[pos++] = DT_NULL;
                    resp[pos++] = DAR_OBJECT_UNAVAILABLE;
                    break;
                }
                resp[pos++] = 1;// 结果类型是数据 data
                resp[pos++] = DT_ARRAY;   // 数据类型
                resp[pos++] = temp_smoke_dev_count+first_read_AM2320_flag1;  // len长度  
                
                for(idx=0; idx<temp_smoke_dev_count; idx++)
                {
                    resp[pos++] = DT_STRUCTURE;
                    resp[pos++] = 2;//structure数量
                    resp[pos++] = DT_OCTETSTRING;
                    resp[pos++] = 6;
                    mem_cpy_reverse(resp+pos,MeterList[MAX_METER_COUNT].elmt.meter_no,6);
                    pos+=6;
                    resp[pos++] = DT_LONG;
                    resp[pos++] = temp_of_temp_smoke_dev>>8;  // temp_of_temp_smoke_dev表示实时的温度INT16S
                    resp[pos++] = temp_of_temp_smoke_dev;    // 高字节在前,和645不一样
                }
                if(first_read_AM2320_flag1==1)
                {
                    resp[pos++] = DT_STRUCTURE;
                    resp[pos++] = 2;//structure数量
                    resp[pos++] = DT_OCTETSTRING;
                    resp[pos++] = 6;
                    mem_cpy_reverse(resp+pos,MeterList[MAX_METER_COUNT].elmt.meter_no,6);
                    pos+=6;
                    resp[pos++] = DT_LONG;
                    bcd_2_int16s(&temp_of_am2301, temphumi1.Temp_BCD);//温湿度传感器AM2301A的温度
                    resp[pos++] = temp_of_am2301>>8;
                    resp[pos++] = temp_of_am2301;//高字节在前,和645不一样                        
                }           
            }         
            break;   

方法127 应该是 操作请求 07 请求操作一个对象方法 2E10 7F00
分支数据监测终端(操作07 添加传感器档案单元)

        case 0x2E100400:      // 读取05 01多回路温度属性4
				mem_cpy(resp + pos, oad->value, 4);     
                pos += 4;
                if((temp_smoke_dev_count == 0) && (first_read_AM2320_flag1 == 0))
                {
                    resp[pos++] = DT_NULL;
                    resp[pos++] = DAR_OBJECT_UNAVAILABLE;
                    break;
                }
                resp[pos++] = 1;// 结果类型是数据 data
                resp[pos++] = DT_ARRAY;   // 数据类型
                resp[pos++] = temp_smoke_dev_count+first_read_AM2320_flag1;  // len长度  
                
                for(idx=0; idx<temp_smoke_dev_count; idx++)
                {
                    resp[pos++] = DT_STRUCTURE;
                    resp[pos++] = 3;//structure数量
                    resp[pos++] = DT_LONGUNSIGNED;
                    resp[pos++] = 


					resp[pos++] = DT_OCTETSTRING;
                    resp[pos++] = 6;
                    mem_cpy_reverse(resp+pos,MeterList[MAX_METER_COUNT].elmt.meter_no,6);
                    pos+=6;
                    
                    resp[pos++] = DT_VISIBLESTRING;
                    resp[pos++] = temp_of_temp_smoke_dev>>8;  // temp_of_temp_smoke_dev表示实时的温度INT16S
                    resp[pos++] = temp_of_temp_smoke_dev;    // 高字节在前,和645不一样
                }
                if(first_read_AM2320_flag1==1)
                {
                    resp[pos++] = DT_STRUCTURE;
                    resp[pos++] = 2;//structure数量
                    resp[pos++] = DT_OCTETSTRING;
                    resp[pos++] = 6;
                    mem_cpy_reverse(resp+pos,MeterList[MAX_METER_COUNT].elmt.meter_no,6);
                    pos+=6;
                    resp[pos++] = DT_LONG;
                    bcd_2_int16s(&temp_of_am2301, temphumi1.Temp_BCD);//温湿度传感器AM2301A的温度
                    resp[pos++] = temp_of_am2301>>8;
                    resp[pos++] = temp_of_am2301;//高字节在前,和645不一样                        
                }           
            }         
            break;   

搜索传感器 0x26008000:
组报文:

 case 0x26008000: //  操作搜索传感器,并更新传感器档案单元  方法128  
            {
                if((temp_smoke_dev_count == 0) && (first_read_AM2320_flag1 == 0)&& (smoke_dev_count == 0)&& (if_ds18b20_count_read() == 0)&& (switch_dev_count == 0))
                {
                    resp[pos++] = DT_NULL;
                    resp[pos++] = DAR_OBJECT_UNAVAILABLE;
                    break;
                }            
                sensor_file[0].sensor_num = temp_smoke_dev_count+first_read_AM2320_flag1+switch_dev_count+if_ds18b20_count_read()+smoke_dev_count; ;   //需要配置到档案的传感器总数
//                rs485_send_frame(PORT_IDX_RS485_1,&sensor_file[0].sensor_num,1,CJQ_G_Var.baudrate);
//                pos+=4;  //数据类型 DT_STRUCTURE 02  长度 03 定值
                if  (sensor_file[0].sensor_num <= MaxSensorNum)
                    {
                    for(i=0; i<temp_smoke_dev_count; i++)                                  
                        {
                            sensor_file[i].sequence = i;
                            sensor_file[i].add_len =6;
                            mem_cpy_reverse(sensor_file[i].add,MeterList[MAX_METER_COUNT].elmt.meter_no,6);
                        }
                    for(idx1=0; idx1 < first_read_AM2320_flag1; idx1++)
                        {
                            sensor_file[idx1].sequence = temp_smoke_dev_count+idx1;
                            sensor_file[idx1].add_len =6;
                            mem_cpy_reverse(sensor_file[idx1].add,MeterList[MAX_METER_COUNT].elmt.meter_no,6);
                        }    
                    for(idx2=0; idx2 < switch_dev_count; idx2++)
                        {
                            sensor_file[idx2].sequence = temp_smoke_dev_count+first_read_AM2320_flag1+idx2;
                            sensor_file[idx2].add_len =6;
                            mem_cpy_reverse(sensor_file[idx2].add,MeterList[MAX_METER_COUNT].elmt.meter_no,6);
                        }  
                    for(idx3=0; idx3 < smoke_dev_count; idx3++)
                        {
                            sensor_file[idx3].sequence = temp_smoke_dev_count+first_read_AM2320_flag1+switch_dev_count+idx3;
                            sensor_file[idx3].add_len =6;
                            mem_cpy_reverse(sensor_file[idx3].add,MeterList[MAX_METER_COUNT].elmt.meter_no,6);
                        }  
                    for(idx4=0; idx4 < if_ds18b20_count_read(); idx4++)
                        {
                            sensor_file[idx4].sequence = temp_smoke_dev_count+first_read_AM2320_flag1+switch_dev_count+smoke_dev_count+idx4;
                            sensor_file[idx4].add_len =6;
                            mem_cpy_reverse(sensor_file[idx4].add,DS18B20_ID[idx4]+1,6);
                        } 
                        resp[pos_resp++] = DAR_SECCESS; //DAR   成功
                        resp[pos_resp++] = DT_NULL; //操作返回数据          Data  OPTIONAL                        
                        
                        tpos_enterCriticalSection();
                        app_if_nor_flash_se(PAGE_ID_LORA_DEV_INFO * MAX_PAGE_SIZE);
                        app_if_nor_flash_write(PAGE_ID_LORA_DEV_INFO * MAX_PAGE_SIZE, &sensor_file, sizeof(sensor_file)); //存储 传感器的档案   
                        tpos_leaveCriticalSection();
                    }
                    else
                    {
                        resp[pos_resp++] = DAR_TYPE_UNMATCHED;  //DAR           类型不匹配
                        resp[pos_resp++] = DT_NULL;             //操作返回数据          Data  OPTIONAL
                    }
            }
             break; 

[16:50:15.950]发→◇68 18 00 43 05 01 00 00 00 00 00 02 F9 D9 07 01 02 26 00 80 00 00 00 C6 E0 16 □
[16:50:16.091]收←◆FE FE FE FE 68 1A 00 C3 05 01 00 00 00 00 00 02 0C B6 87 01 02 26 00 80 00 00 00 00 00 28 E4 16
查询传感器
[16:51:56.876]发→◇68 17 00 43 05 01 00 00 00 00 00 02 B5 C5 05 01 02 26 00 04 00 00 F2 5B 16 □
[16:51:56.964]收←◆FE FE FE FE 68 2A 00 C3 05 01 00 00 00 00 00 02 C3 25 85 01 02 26 00 04 00 01 01 01 02 03 12 00 00 09 06 4C 27 C1 04 00 00 0A 00 00 00 63 33 16
复位在上电
[16:58:11.989]发→◇68 17 00 43 05 01 00 00 00 00 00 02 B5 C5 05 01 02 26 00 04 00 00 F2 5B 16 □
[16:58:12.059]收←◆FE FE FE FE 68 2A 00 C3 05 01 00 00 00 00 00 02 C3 25 85 01 02 26 00 04 00 01 01 01 02 03 12 00 00 09 06 4C 27 C1 04 00 00 0A 00 00 00 63 33 16