C语言Modbus通讯协议开发源码解读

版权申诉
0 下载量 86 浏览量 更新于2024-11-24 收藏 54KB RAR 举报
资源摘要信息: "C_code_for_modbus.rar_通讯编程文档_Visual_C++" 本资源包含了在Visual C++环境下进行C语言编写的Modbus通讯协议开发的源代码及相关文档。Modbus协议广泛应用于工业自动化领域,是一种基于主从架构的通讯协议,它允许设备之间通过串行通信或以太网进行数据交换。本资源详细介绍了如何使用C语言结合Visual C++开发环境实现Modbus通讯协议,适合于需要进行工业设备通讯、数据采集等应用的开发者。 知识点概述: 1. Modbus协议基础 - Modbus协议的起源和发展历史。 - Modbus协议的主要特点和优势。 - Modbus协议的主要功能码和应用场景。 - Modbus协议的数据帧格式和通讯机制。 2. Modbus协议的两种模式 - RTU模式(Remote Terminal Unit): 采用二进制进行数据传输,适用于串行通讯,效率高。 - ASCII模式: 采用ASCII码进行数据传输,适用于调试,但在传输效率上低于RTU模式。 3. Modbus协议的功能码解析 - 用于读写设备寄存器的功能码(如03, 06, 16等)。 - 异常响应和错误码的处理。 - 特殊功能码的应用,例如管理从站设备。 4. Visual C++开发环境基础 - Visual C++的特点和在C++开发中的地位。 - Visual C++开发环境的基本配置和使用。 - Visual C++的调试和性能分析工具。 5. C语言在Visual C++中的应用 - C与C++的联系和区别。 - 在Visual C++中如何有效地使用C语言进行编程。 - C++对C语言特性的扩展和兼容性问题。 6. Modbus协议的C语言实现 - C语言编写Modbus协议栈的方法和技巧。 - 实现Modbus主站和从站的逻辑和代码结构。 - Modbus协议的安全性考虑和实现。 7. 工业通讯编程实践 - 工业通讯的常见需求和挑战。 - 读写PLC、变频器、传感器等工业设备的案例分析。 - 故障诊断和系统维护的方法。 8. 文档内容结构 - C code for modbus.mht文件中所包含的文档结构。 - 代码注释的规范和重要性。 - 如何通过文档学习和理解Modbus通讯编程的实现细节。 本资源的下载和使用将有助于开发者在Visual C++环境中构建稳定可靠的Modbus通讯应用,对于深入学习和研究工业通讯协议、通讯编程以及C语言在现代软件开发中的应用具有重要价值。通过本资源的实践应用,开发者可以为工业自动化系统集成、远程监控、数据采集等项目提供技术支持。

优化这个sql SELECT count( 1 ) FROM ( SELECT B.ID, B.PURCHASE_REQUEST_ID, B.MATERIAL_ID, B.MATERIAL_CODE, B.MATERIAL_NAME, B.STANDARD, B.MODEL_ID, B.BILL_ROW_ID, B.BILL_NO, BILL_NAME, B.MODEL_CODE, B.MODEL_NAME, B.PARENT_MODEL_ID, B.PARENT_MODEL_CODE, B.PARENT_MODEL_NAME, B.UNIT_CODE, B.UNIT_NAME, B.PURCHASE_TYPE_CODE, CAST( NVL( B.APPLY_NUM, 0 ) AS NUMBER ( 24, 10 ) ) AS APPLY_NUM, CAST( NVL( B.DEAL_NUM, 0 ) AS NUMBER ( 24, 10 ) ) AS DEAL_NUM, CAST( NVL( B.RETURN_NUM, 0 ) AS NUMBER ( 24, 10 ) ) AS RETURN_NUM, B.DEAL_USER_ID, B.DEAL_USER_NAME, CAST( NVL( B.PRICE, 0 ) AS NUMBER ( 24, 10 ) ) AS PRICE, CAST( NVL( B.AMOUNT, 0 ) AS NUMBER ( 24, 10 ) ) AMOUNT, B.IMPLEMENT_CODE, B.IMPLEMENT_NAME, B.IMPLEMENT_INVEST_AMOUNT, B.PURCHASE_MANAGER_ID, B.PURCHASE_MANAGER_NAME, B.PROVIDER_ID, B.PROVIDER_NAME, B.REMARK, B.DELIVER_AREA, B.DELIVER_ADDRESS, B.RECEIVE_PEOPLE, B.RECEIVE_PEOPLE_PHONE, B.ITEM_STATUS, B.COST_CENTER, B.COST_BUDGET_CODE, B.COST_IMPLEMENT_NAME, B.FRAME_CONT_ID, B.FRAME_CONT_CODE, B.FRAME_CONT_NAME, B.DETAIL_CONFIG, B.PURCHASE_CATEGORY_CODE, B.INVOICE_TITLE_CODE, B.INVOICE_SEND_ADDRRSS, B.MATERIAL_REQUEST_ITEM_ID, B.YEAR, B.DELETE_FLAG, B.PROVINCE_CODE, B.REASON, B.PARENT_ITEM_ID, B.FRAME_CONT_ITEM_ID, B.SUB_MATERIAL_REQUEST_ID, B.SUB_MATERIAL_REQUEST_CODE, B.MATERIAL_URL, B.RECOMMEND_PROVIDER_NAMES, C.PURCHASE_REQUEST_CODE, C.PURCHASE_REQUEST_NAME, C.APPLY_TYPE_CODE, C.CREATOR_NAME, C.APPLY_TELEPHONE, C.COMPANY_NAME, C.DEPT_NAME, B.CREATE_TIME, TO_CHAR( B.CREATE_TIME, 'YYYY-MM-DD' ) CREATE_TIME_STR, C.ARRIVE_TIME, C.IS_TO_END, C.MONEY_WAY_CODE, C.OWN, C.APPLY_CATEGORY_CODE, C.manu_Type, C.BILL_ID, MMD.MATERIAL_TYPE_CODE, B.BRANCH_COMPANY_DEAL_USER_ID, B.BRANCH_COMPANY_DEAL_USER_NAME, ( SELECT ORG_NAME FROM ORGANIZATIONS WHERE DELETE_FLAG = '0' AND ORG_CODE = ( SELECT PARENT_COMPANY_NO FROM ORGANIZATIONS WHERE ID = B.MATERIAL_DEPT_ID )) AS MATERIAL_COMPANY_NAME, B.ORIGINAL, B.PROVIDER_PRODUCT_MODEL, B.PROVIDER_PRODUCT_NAME, B.PRODUCT_DESC, B.Back_Flag, CASE WHEN MMD.material_type_code = 'WZ' THEN '1' WHEN MMD.material_type_code = 'FW' THEN '2' ELSE '3' END apply_category_code_item, NVL( C.IS_CARDSYSTEM_REQUEST, '0' ) IS_CARDSYSTEM_REQUEST, B.APPLY_GROUP_AUTHORITES, B.SCIENTIFIC_RESEARCH_ID, B.SCIENTIFIC_RESEARCH_CODE, B.SCIENTIFIC_RESEARCH_NAME, B.PREQUALFY_CODE, nvl( C.IS_QUICK, '0' ) AS IS_QUICK, C.PURCHASE_WAY_CODE, C.PURCHASE_TYPE_CODE PURCHASE_TYPE_CODE_P, C.ORIGINAL_TYPE, C.PURCHASE_REQUEST_BILLS_TYPE, B.IS_FRAME_CONT_MONAD FROM PURCHASE_REQUEST_ITEM B LEFT JOIN PURCHASE_REQUEST C ON B.PURCHASE_REQUEST_ID = C.ID LEFT JOIN MATERIAL_DATA MMD ON MMD.ID = B.MATERIAL_ID AND MMD.DELETE_FLAG = '0' WHERE B.delete_flag = '0' AND B.Item_Status IN ( 1 ) AND NOT EXISTS ( SELECT * FROM purchase_request_item_log pril WHERE B.id = pril.purchase_request_item_id AND pril.lock_status = '1' AND pril.delete_flag = '0' ) AND ( ( c.apply_type_code NOT IN ( '20', '41', '3' ) AND nvl( B.Apply_Num, 0 ) > nvl( B.Deal_Num, 0 )) OR c.apply_type_code IN ( '20', '41', '3' ) ) AND B.Deal_User_Id =: 1 AND C.MONEY_WAY_CODE =: 2 AND C.APPLY_TYPE_CODE =: 3 AND C.PAY_OUT_TYPE_CODE =: 4 AND C.APPLY_CATEGORY_CODE =: 5 AND NVL( C.IS_CARDSYSTEM_REQUEST, '0' ) = : 6 AND NOT EXISTS ( SELECT * FROM purchase_request_item p left join material_province mp ON p.material_id = mp.material_id WHERE p.delete_flag = 0 AND mp.delete_flag = 0 AND mp.material_status = 03 AND mp.org_code = p.province_code AND p.id = B.id ) ORDER BY C.ID, B.ID ASC)

2023-06-08 上传

优化这条sql 解决bug select a.*,rownum num from ( SELECT t.PROJ_ID,t.PROJ_CODE,t.PROJ_NAME,t.CLIENT_CODE,t.CLIENT_NAME,t.SPEC_CODE,t.SPEC_NAME,t.BUS_UNIT_CODE,t.BUS_UNIT,t.PROJ_DEP_CODE,t.PROJ_DEP,t.PROJECT_MANAGER_CODE,t.PROJECT_MANAGER,t.PROJECT_DEP_MANAGER_CODE,t.PROJECT_DEP_MANAGER,t.IS_SUB_PROJ,t.SUB_PROJ_TYPE_CODE,t.SUB_PROJ_TYPE,t.PARENT_CODE,t.PROJ_GROSS,t.CLIENT_AREA_CODE,t.CLIENT_AREA,t.CLIENT_TYPE_FULL_PATH_CODE,t.CLIENT_TYPE_PULL_PATH,t.BUSINESS_TYPE_CODE,t.BUSINESS_TYPE,t.BUSINESS_LEVEL_CODE,t.BUSINESS_LEVEL,t.BUSINESS_AREA_CODE,t.BUSINESS_AREA_NAME,t.IS_CLOSE,t.IS_IN_COO,t.TAX_RATE,t.IS_AUTHORIZED,t.AUTHORIZED_AMOUNT,t.IS_VIRTUAL,t.INCOME_BUDGET,t.EXPENDITURE_BUDGET,t.P_VALUE,t.CREATE_TIME,t.P_BUD_VALUE,t.P1_BUD_VALUE,t.P2_BUD_VALUE,t.ORG_CODE,t.ORG_NAME,t.PROD_RES_TYPE,t.IS_TECH_COO,t.COO_UNIT_RATIO,t.PROJ_ACHIEVEMENTS_BUD,t.REIMBURSEMENT_COST_BUD,t.COO_COST_BUD,t.MATERIAL_COST_BUD,t.PERFORMANCE_PERCENT,t.SCHE_START_TIME,t.SCHE_END_TIME,t.PROJECT_ACCOUNT_CODE,t.CUSTOMER_TYPE_CODE,t.CUSTOMER_TYPE,t.IS_PURE_OUT_PROJ,t.PROJECT_CREATE_TIME,t.IS_RELATE,t.IS_QUOTA,t.MAIN_PROJECT_CODE,t.PROJ_STATUS,t.IS_LARGE_PROJECT,t.MARKET_DIS_COUNT_RATE,t.PROJECT_CAT,t.MGR_PER_FORMANCE_RATIO,t.P1_VALUE,t.S_VALUE,t.COOP_VALUE,t.H_VALUE,t.DEVICE_BUDGET_COST,t.SUR_FEE_DIS_COUNT_RATE,t.DES_FEE_DIS_COUNT_RATE, (select listagg(p.coo_unit_code, ',') within group(order by p.coo_unit_code) from ( select distinct coo_unit_code from t_spdi_proj where is_sub_proj = 'Y' and sub_proj_type_code = 'wbhz' and PROJ_STATUS != 'P_5' AND PROJ_STATUS != 'P_4' and parent_code = t.proj_code )p ) coo_unit_code, (select listagg(to_char(p.coo_unit), ',') within group(order by p.coo_unit) from ( select distinct coo_unit from t_spdi_proj where is_sub_proj = 'Y' and sub_proj_type_code = 'wbhz' and PROJ_STATUS != 'P_5' AND PROJ_STATUS != 'P_4' and parent_code = t.proj_code )p ) coo_unit from T_SPDI_PROJ t where t.PROJ_STATUS NOT IN ('E','H','W') order by t.proj_id )a

2023-06-01 上传