活动介绍

#if defined(CONDITION_A) && defined(CONDITION_B)

时间: 2024-03-21 13:43:34 浏览: 136
#if defined(CONDITION_A) && defined(CONDITION_B)是一个C语言预处理器指令,可以用来检查CONDITION_A和CONDITION_B是否都被定义。如果这两个条件都被定义,则执行#if和#elif之间的代码,否则执行#else和#endif之间的代码。 下面是一个示例: ``` #if defined(CONDITION_A) && defined(CONDITION_B) // 如果CONDITION_A和CONDITION_B都被定义,则执行此处的代码 #else // 如果CONDITION_A和CONDITION_B中至少一个未被定义,则执行此处的代码 #endif ``` 请注意,#if和#elif之后的条件表达式必须在编译时求值,因此必须是常量表达式。因此,CONDITION_A和CONDITION_B必须是预定义的宏。
相关问题

tFblResult ApplFblBmIsValidBlock(tFblBmHdrTargetHandle targetHandle, const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * pLogicalBlock) { tFblResult result; # if defined( FBL_ENABLE_PRESENCE_PATTERN ) || defined( FBLBM_ENABLE_STANDALONE_MODE ) vuint8 device; # endif /* FBL_ENABLE_PRESENCE_PATTERN || FBLBM_ENABLE_STANDALONE_MODE */ # if !defined( FBL_ENABLE_PRESENCE_PATTERN ) vuint8 validityFlags[kEepSizeValidityFlags]; vuint8 validityMask; vuint8 byteIdx; # endif /* !FBL_ENABLE_PRESENCE_PATTERN */ # if (!defined( FBLBM_ENABLE_STANDALONE_MODE ) || defined( FBL_ENABLE_PRESENCE_PATTERN )) # if defined( V_ENABLE_USE_DUMMY_STATEMENT ) (void)targetHandle; # endif /* V_ENABLE_USE_DUMMY_STATEMENT */ # endif /* ( !FBLBM_ENABLE_STANDALONE_MODE || FBL_ENABLE_PRESENCE_PATTERN ) */ result = kFblFailed; # if defined( FBLBM_ENABLE_STANDALONE_MODE ) && !defined( FBL_ENABLE_PRESENCE_PATTERN) # error "If presence pattern is disabled special handling must be configured for the FBL because \ validity flags are not available for the FBL." /* Perform presence pattern check only for FBL, use NV validity flags for other blocks */ if (targetHandle == FBLBMHDR_TARGET_FBL) # endif /* FBLBM_ENABLE_STANDALONE_MODE && !FBL_ENABLE_PRESENCE_PATTERN */ # if defined( FBL_ENABLE_PRESENCE_PATTERN ) || defined( FBLBM_ENABLE_STANDALONE_MODE ) { /* Check the presence pattern value */ if (kFblOk == FblMemGetDeviceByRange(pLogicalBlock->blockStartAddress, pLogicalBlock->blockLength, &device)) { # if defined( kMioDeviceProtected ) /* Do not check the presence pattern for RAM */ if (device != kMioDeviceProtected) # endif /* kMioDeviceProtected */ { result = FblNvPatternGetByBlockDescriptor(pLogicalBlock, kFblNvPatternId_BlockValidity ); } } } # endif /* FBL_ENABLE_PRESENCE_PATTERN || FBLBM_ENABLE_STANDALONE_MODE */ # if !defined( FBL_ENABLE_PRESENCE_PATTERN ) # if defined( FBLBM_ENABLE_STANDALONE_MODE ) /* Check NV validity flags if block other than FBL is checked */ else # endif /* FBLBM_ENABLE_STANDALONE_MODE */ { /* Calculate index and mask for validity bit of logical block */ byteIdx = (pLogicalBlock->blockNr >> 0x03u); validityMask = (vuint8)(0x01u << (pLogicalBlock->blockNr & 0x07u)); /* Read validity information from non-volatile memory */ if (ApplFblNvReadValidityFlags(validityFlags) == kFblOk) { if ((validityFlags[byteIdx] & validityMask) == 0u) { /* Block is valid */ result = kFblOk; } } } # endif /* !FBL_ENABLE_PRESENCE_PATTERN */ return result; } #endif /* FBLBM_AP_CALLOUT_IS_VALIDBLOCK */代码解释

<think>好的,我现在要尝试理解这段C语言代码。首先,函数名是ApplFblBmIsValidBlock,返回类型是tFblResult。参数有两个:targetHandle和pLogicalBlock。看起来这个函数的作用是检查某个逻辑块是否有效。 接下来,函数内部有一些条件编译的预处理指令,比如#if defined(FBL_ENABLE_PRESENCE_PATTERN)等等。这说明代码会根据不同的宏定义来编译不同的部分。首先,我需要理清这些宏定义之间的关系。 然后,声明了一些变量,比如result初始化为kFblFailed,说明默认情况下返回失败。接下来,在条件编译的部分,比如当FBLBM_ENABLE_STANDALONE_MODE被定义,而FBL_ENABLE_PRESENCE_PATTERN未定义时,会抛出一个错误。这可能意味着这两个宏的某些组合是不允许的,或者需要特殊处理。 在代码的主体部分,首先检查是否满足某些宏定义的条件,比如FBL_ENABLE_PRESENCE_PATTERN或者FBLBM_ENABLE_STANDALONE_MODE,然后根据不同的条件执行不同的逻辑。例如,在存在FBL_ENABLE_PRESENCE_PATTERN的情况下,会调用FblMemGetDeviceByRange获取设备信息,然后检查设备类型是否为受保护的,如果不是的话,再调用FblNvPatternGetByBlockDescriptor来检查块的有效性。 而如果未定义FBL_ENABLE_PRESENCE_PATTERN,则使用另一种方式,通过读取NV有效性标志来判断块是否有效。这里涉及到位操作,比如计算byteIdx和validityMask,然后读取validityFlags数组中的相应位来判断有效性。 可能的疑问点:条件编译的各个部分如何组合,宏定义之间的依赖关系,以及不同情况下的处理逻辑。例如,当同时启用FBLBM_ENABLE_STANDALONE_MODE和未启用FBL_ENABLE_PRESENCE_PATTERN时,如何处理有效性检查? 另外,函数的返回值result初始化为失败,只有在某些条件满足时才设置为kFblOk。需要仔细查看每个条件分支中的result赋值情况,确保逻辑正确。 还需要理解结构体指针pLogicalBlock的成员,比如blockStartAddress、blockLength和blockNr,这些可能在计算设备范围或有效性标志时使用到。 总结来说,这个函数根据不同的编译配置选择不同的方法来验证逻辑块的有效性,可能使用存在模式检查或者NV标志位检查,具体取决于宏定义的配置情况。</think>以下是对代码的逐步解析: $$tFblResult\ ApplFblBmIsValidBlock(...)$$ 函数用于验证指定逻辑块的有效性,返回kFblOk表示有效,kFblFailed表示无效。 ### 一、参数说明 1. `targetHandle`:目标处理器句柄 2. `pLogicalBlock`:逻辑块描述符指针(含blockStartAddress/blockLength/blockNr等字段) ### 二、条件编译逻辑 #### 1. 存在性模式检查(FBL_ENABLE_PRESENCE_PATTERN) ```c # if defined(FBL_ENABLE_PRESENCE_PATTERN) /* 通过特殊数据模式验证 */ result = FblNvPatternGetByBlockDescriptor(...) ``` - 适用于EEPROM/Flash等非易失存储器 - 在块起始位置写入特定数据模式(如$0x5A5A$) - 通过校验该模式判断块有效性 #### 2. 独立模式检查(FBLBM_ENABLE_STANDALONE_MODE) ```c # if defined(FBLBM_ENABLE_STANDALONE_MODE) /* FBL专用有效性检查 */ if(targetHandle == FBLBMHDR_TARGET_FBL) ``` - 专用于Bootloader自身有效性验证 - 需配合存在性模式使用(第5行`#error`提示) #### 3. NV标志位检查(默认路径) ```c # if !defined(FBL_ENABLE_PRESENCE_PATTERN) /* 有效性标志位验证 */ byteIdx = blockNr >> 3; // 等价于 blockNr / 8 validityMask = 1 << (blockNr & 0x07); // 等价于 blockNr % 8 ``` - 使用非易失存储器的有效性标志位图 - 每个block对应1个bit位(0有效,1无效) - 通过`ApplFblNvReadValidityFlags()`读取标志位 ### 三、执行流程 $$flowchart st=>start: 开始 cond1=>condition: 启用存在性模式\n或独立模式? op1=>operation: 存在性模式检查 cond2=>condition: 是FBL块? op2=>operation: 独立模式校验 op3=>operation: NV标志位检查 e=>end: 返回结果 st->cond1 cond1(yes)->op1->e cond1(no)->cond2 cond2(yes)->op2->e cond2(no)->op3->e $$ ### 四、关键数据结构 ```c typedef struct { vuint32 blockStartAddress; // 块起始地址($0x80000000$) vuint32 blockLength; // 块长度($0x2000$) vuint8 blockNr; // 块编号($0x01$~$0xFF$) } tBlockDescriptor; ``` ### 五、设计特点 1. 双模式兼容:支持存在性模式(硬件级验证)和标志位模式(软件级验证) 2. 内存优化:标志位存储方式(每个块1bit)显著减少存储空间占用 3. 安全隔离:对受保护设备(kMioDeviceProtected)跳过存在性检查 4. 错误防御:通过#error强制约束不安全的宏组合 该函数常用于汽车电子刷写流程中,用于验证待编程数据块的完整性和有效性。实际应用中需根据存储介质特性选择验证模式,例如Flash存储器推荐使用存在性模式,EEPROM可使用标志位模式。

#ifndef _RX_FOC_STATEMACHINE_H_ #define _RX_FOC_STATEMACHINE_H_ #include "RX_Motor_Parameters.h" typedef struct RX_FOC_STATEMACHINE_STATE { void (*entry)(void); void (*idle)(void); void (*stop)(void); void (*zero_current_calibrate)(void); void (*check_bemf)(void); void (*alignment)(void); #if defined ENABLE_ROTOR_IPD2_FUNCTION void (*inductance_sat_pos_dect)(void); #endif void (*hfi)(void); void (*closeloop_startup)(void); void (*open_loop)(void); void (*close_loop)(void); } RX_FOC_STATEMACHINE_STATE_T; extern void (*RX_FOC_State_Machine_Run)(void); extern const RX_FOC_STATEMACHINE_STATE_T rx_foc_run_states; #endif

<think>好的,用户想了解FOC状态机的定义以及在嵌入式C编程中函数指针的作用。首先,我需要回忆一下FOC(电机磁场定向控制)的基本概念,以及状态机在其中的应用。 FOC状态机通常用于管理电机的不同运行状态,比如初始化、校准、运行和停止等。状态机的定义一般包括状态枚举、转换条件和对应的处理函数。在嵌入式系统中,状态机的高效管理对于实时性要求高的应用非常重要。 接下来,函数指针在状态机中的作用。函数指针允许动态调用不同的处理函数,根据当前状态执行相应的操作。这样可以避免使用大量的条件判断语句,提高代码的可维护性和扩展性。例如,每个状态可能对应一个函数,状态机通过函数指针数组来索引这些函数,从而在状态切换时调用正确的处理逻辑。 用户提供的参考引用中提到了ArduinoFOC库中的StateMachine类,初始化状态为INIT,并在loop中更新状态机。这说明状态机的实现可能涉及状态转换关系的配置,以及各状态函数的逻辑编写。需要解释这些部分如何通过函数指针来实现。 可能还需要解释状态机的工作流程,比如如何从初始化状态转换到校准状态,再转换到运行状态,每个转换的条件是什么。函数指针在这里如何被赋值和调用,以及如何通过状态机对象管理当前状态和转换。 另外,用户的问题涉及嵌入式C编程,需要强调资源受限环境下函数指针的效率考量,比如内存占用和执行速度。可能还要提到使用函数指针数组来优化状态查找,减少分支预测错误,提升性能。 最后,生成相关问题时要围绕状态机的设计、函数指针的应用、状态转换机制以及嵌入式系统中的优化策略等方面展开,确保问题能够帮助用户深入理解相关概念。</think>### FOC状态机定义与函数指针作用解析 #### 一、FOC状态机定义 FOC(Field-Oriented Control,磁场定向控制)状态机是一种用于管理电机控制流程的有限状态机(FSM),通常包含以下核心组件: 1. **状态枚举**:定义电机控制的生命周期阶段,例如: ```c typedef enum { STATE_INIT, // 初始化 STATE_CALIB, // 校准 STATE_RUN, // 运行 STATE_STOP // 停止 } FOC_State_t; ``` 2. **状态转换规则**:通过事件或条件触发状态迁移,例如校准完成后自动进入运行状态。 3. **上下文数据**:保存电机参数(如电流、角度)和控制标志。 #### 二、函数指针的核心作用 在嵌入式C中,函数指针用于实现**动态行为绑定**,典型应用包括: 1. **状态处理函数表**: ```c typedef void (*StateHandler)(void* context); StateHandler state_handlers[] = { handle_init, // STATE_INIT handle_calib, // STATE_CALIB handle_run, // STATE_RUN handle_stop // STATE_STOP }; ``` 通过索引直接调用对应状态的处理函数,避免`switch-case`的冗余[^1]。 2. **条件检查函数**: ```c typedef bool (*TransitionCondition)(void* context); struct Transition { FOC_State_t from; FOC_State_t to; TransitionCondition condition; }; ``` 定义状态转换的触发条件(如`check_calib_complete()`)。 3. **回调机制**: ```c void state_machine_run(FOC_SM* sm) { sm->current_handler(sm->context); // 动态调用当前状态处理函数 } ``` #### 三、典型实现流程 ```c // 状态机结构体 typedef struct { FOC_State_t current_state; StateHandler* handlers; Transition* transitions; void* context; // 电机控制参数 } FOC_SM; // 状态处理函数示例 void handle_calib(void* ctx) { MotorContext* mc = (MotorContext*)ctx; if (encoder_calibrated(mc)) { mc->sm->current_state = STATE_RUN; // 状态迁移 } } ``` #### 四、设计优势 1. **可扩展性**:新增状态仅需扩展枚举和函数表 2. **解耦合**:状态逻辑与控制流程分离 3. **实时性**:函数指针跳转比条件判断更快(ARM Cortex-M中约节省3-5个时钟周期)
阅读全文

相关推荐

from jqdata import * def initialize(context): # 策略初始化设置 set_params(context) # 设置参数 set_backtest() # 设置回测条件 def set_params(context): # 配置策略参数 context.stock_pool = [ {'code': '399673.XSHE', 'name': '创业板50'}, {'code': '000688.XSHG', 'name': '科创50'}, {'code': '399303.XSHE', 'name': '国证2000'} ] context.bond_code = '000012.XSHG' # 国债指数 context.cy_index = '399006.XSHE' # 创业板指 context.ma_days = 20 # 均线周期 context.rank_days = 20 # 排名计算周期 context.sell_ma = 10 # 卖出均线周期 def set_backtest(): # 回测设置 set_benchmark('399673.XSHE') set_option('use_real_price', True) set_order_cost(OrderCost( open_tax=0, close_tax=0.001, open_commission=0.0003, close_commission=0.0003, min_commission=5 ), type='stock') def handle_data(context, data): # 每日交易逻辑 if not is_trading_day(context): return check_sell_condition(context, data) # 持仓时判断平仓 check_buy_condition(context, data) # 空仓时判断开仓 def is_trading_day(context): # 判断是否为交易日 return not (context.current_dt.hour == 15 and context.current_dt.minute == 0) def check_sell_condition(context, data): # 平仓条件判断 for stock in context.portfolio.positions: if stock.code == context.bond_code: continue current_price = data[stock.code].close ma10 = get_ma(stock.code, context.sell_ma, data) if current_price < ma10: clear_position(context, stock.code) log.info(f"触发平仓条件:{stock.code} 价格跌破10日均线") def check_buy_condition(context, data): # 开仓条件判断 if len(context.portfolio.positions) > 0: return # 大盘择时判断 cy_price = data[context.cy_index].close cy_ma20 = get_ma(context.cy_index, context.ma_days, data) if cy_price <= cy_ma20: return # 计算标的排名 ranked_stocks = [] for stock in context.stock_pool: current_price = data[stock['code']].close ma20 = get_ma(stock['code'], context.rank_days, data) ratio = (current_price - ma20) / ma20 ranked_stocks.append((stock, ratio)) # 按涨幅排序 ranked_stocks.sort(key=lambda x: x[1], reverse=True) target_stock = ranked_stocks[0][0] # 开仓条件验证 current_price = data[target_stock['code']] cy_ma20 = get_ma(context.cy_index, context.ma_days, data) NameError: name 'get_ma' is not defined

OF/********************************************************************************************************************* Copyright (c) 2020 RoboSense All rights reserved By downloading, copying, installing or using the software you agree to this license. If you do not agree to this license, do not download, install, copy or use the software. License Agreement For RoboSense LiDAR SDK Library (3-clause BSD License) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the names of the RoboSense, nor Suteng Innovation Technology, nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *********************************************************************************************************************/ #include "manager/node_manager.hpp" #include <rs_driver/macro/version.hpp> #include <signal.h> #ifdef ROS_FOUND #include <ros/ros.h> #include <ros/package.h> #elif ROS2_FOUND #include <rclcpp/rclcpp.hpp> #endif using namespace robosense::lidar; #ifdef ROS2_FOUND std::mutex g_mtx; std::condition_variable g_cv; #endif static void sigHandler(int sig) { RS_MSG << "RoboSense-LiDAR-Driver is stopping....." << RS_REND; #ifdef ROS_FOUND ros::shutdown(); #elif ROS2_FOUND g_cv.notify_all(); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// static std::string pcd_name_prefix = ""; void SetPCDNamePrefix(const std::string& prefix) { RS_INFO << "------------------------------------------------------" << RS_REND; RS_INFO << "Set PCD Name Prefix: " << prefix << RS_REND; pcd_name_prefix = prefix; RS_INFO << "------------------------------------------------------" << RS_REND; } const std::string& GetPCDNamePrefix() { // RS_INFO << "Use PCD Name Prefix: " << pcd_name_prefix << RS_REND; return pcd_name_prefix; } /////////////////////////////////////////////////////////////////////////////////////////////// static std::string pcd_file_path = ""; void SetPCDFilePath(const std::string& path) { RS_INFO << "------------------------------------------------------" << RS_REND; RS_INFO << "Set PCD Dir: " << path << RS_REND; pcd_file_path = path; RS_INFO << "------------------------------------------------------" << RS_REND; } const std::string& GetPCDFilePath() { // RS_INFO << "Use PCD Dir: " << pcd_file_path << RS_REND; return pcd_file_path; } /////////////////////////////////////////////////////////////////////////////////////////////// void StringSplit(const std::string& str, const char split_char, std::vector<std::string>& res) { std::istringstream iss(str); std::string token; while(getline(iss, token, split_char)) { res.push_back(std::move(token)); } } const std::size_t LIDAR_INDEX_IN_PCAP_FILE = 4; /////////////////////////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) { signal(SIGINT, sigHandler); ///< bind ctrl+c signal with the sigHandler function RS_TITLE << "********************************************************" << RS_REND; RS_TITLE << "********** **********" << RS_REND; RS_TITLE << "********** RSLidar_SDK Version: v" << RSLIDAR_VERSION_MAJOR << "." << RSLIDAR_VERSION_MINOR << "." << RSLIDAR_VERSION_PATCH << " **********" << RS_REND; RS_TITLE << "********** **********" << RS_REND; RS_TITLE << "********************************************************" << RS_REND; #ifdef ROS_FOUND ros::init(argc, argv, "rslidar_sdk_node", ros::init_options::NoSigintHandler); #elif ROS2_FOUND rclcpp::init(argc, argv); #endif std::string config_path; #ifdef RUN_IN_ROS_WORKSPACE config_path = ros::package::getPath("rslidar_sdk"); #else config_path = (std::string)PROJECT_PATH; #endif config_path += "/config/"; #ifdef ROS_FOUND ros::NodeHandle priv_hh("~"); std::string pcap_file; std::string dest_pcd_dir; priv_hh.param("pcap_file", pcap_file, std::string("")); priv_hh.param("dest_pcd_dir", dest_pcd_dir, std::string("")); #elif ROS2_FOUND std::shared_ptr<rclcpp::Node> nd = rclcpp::Node::make_shared("param_handle"); std::string pcap_file = nd->declare_parameter<std::string>("pcap_file", ""); std::string dest_pcd_dir = nd->declare_parameter<std::string>("dest_pcd_dir", ""); #endif // #if defined(ROS_FOUND) || defined(ROS2_FOUND) // if (!path.empty()) // { // config_path = path; // } // #endif std::string lidar_name = ""; std::vector<std::string> path_nodes{}; StringSplit(pcap_file, '/', path_nodes); std::vector<std::string> filename_segs{}; std::vector<std::string> token_res{}; if (path_nodes.size() > 0) { StringSplit(path_nodes[path_nodes.size()-1], '.', filename_segs); if (filename_segs.size() > 0) { StringSplit(filename_segs[0], '_', token_res); } else { RS_ERROR << "The lidar name in pcap file is not specified: [" << pcap_file << "] is wrong. Please check." << RS_REND; return -1; } } if (token_res.size() <= LIDAR_INDEX_IN_PCAP_FILE) { RS_ERROR << "The lidar name in pcap file is not specified: [" << pcap_file << "] is wrong. Please check." << RS_REND; return -1; } else { lidar_name = token_res[LIDAR_INDEX_IN_PCAP_FILE]; std::stringstream ss; for (std::size_t i = 0; i <= LIDAR_INDEX_IN_PCAP_FILE; i++) { ss << token_res[i] << "_"; } SetPCDNamePrefix(ss.str()); } std::stringstream ss; ss << "config-" << lidar_name << ".yaml"; config_path = config_path + ss.str(); if (dest_pcd_dir.empty()) { RS_ERROR << "The destination pcd output dir is not specified: [" << dest_pcd_dir << "] is wrong. Please check." << RS_REND; return -1; } else { SetPCDFilePath(dest_pcd_dir); } SourceDriverPCAPPath::SetPCAPFilePath(pcap_file); YAML::Node config; try { config = YAML::LoadFile(config_path); RS_INFO << "--------------------------------------------------------" << RS_REND; RS_INFO << "Config loaded from PATH:" << RS_REND; RS_INFO << config_path << RS_REND; RS_INFO << "--------------------------------------------------------" << RS_REND; } catch (...) { RS_ERROR << "The format of config file " << config_path << " is wrong. Please check (e.g. indentation)." << RS_REND; return -1; } std::shared_ptr<NodeManager> demo_ptr = std::make_shared<NodeManager>(); demo_ptr->init(config); demo_ptr->start(); RS_MSG << "RoboSense-LiDAR-Driver is running....." << RS_REND; #ifdef ROS_FOUND ros::spin(); #elif ROS2_FOUND std::unique_lock<std::mutex> lck(g_mtx); g_cv.wait(lck); #endif return 0; }

#!/usr/bin/perl -w ##########################程式信息########################## #脚本名称:防焊开窗优化程式(solder_dfm.pl) #开发人员:欣强电子电脑室(唐伟) #开发时间:2017年8月1日 #版本信息:Ver_A.1.0 (A:制前规则变更,外部变更或升级;1.0:脚本基带版本号,内部变更或升级) #修改信息:当前版本(Ver_A.1.0),首次开发测试,暂无版本变更信息 ##########################程式信息########################## ##########################提示代码########################## my $panel_bp_101 = "错误代码:101,当前用户没有执行权限,请联系系统管理员!"; my $panel_bp_102 = "错误代码:102,请打开料号后再执行程式!"; my $panel_bp_103 = "错误代码:103,请在打开Step再执行程式!"; my $panel_bp_104 = "错误代码:104,参数不可有空数值!"; my $panel_bp_105 = "错误代码:105,请选择当前料号的工作层!"; my $panel_bp_106 = "错误代码:106,请选择对比料号的对比层!"; my $panel_bp_107 = "错误代码:107,对比料号Step没有创建profile,无法执行profile范围比对!"; my $panel_bp_108 = "错误代码:108,脚本注册失败,无法获取系统管理员权限!"; ##########################提示代码########################## #库及包的调取 use lib "$ENV{GENESIS_DIR}/$ENV{GENESIS_EDIR}/all/perl"; use Genesis; use Tk; use Tk::Tree; use Tk::PNG; use Tk::Bitmap; use Tk::LabFrame; use Tk::LabEntry; use strict; use Encode; use encoding 'utf-8'; use Date::Calc qw(Delta_Days); use POSIX qw(strftime); use warnings; use Time::Piece; use Date::Calc qw(Delta_Days); require 'shellwords.pl'; ##########################初始化########################## my $f = new Genesis; #new my $version = 'A.1.0(测试版)'; #定义版本号 #获取系统时间 my $date = strftime("%Y年%m月%d日",localtime()); #日期(年-月-日) my $time = strftime("%H时%M分%S秒", localtime(time)); #时间(时-分-秒) #获取当前系统,主机名,用户组,用户名 my $Sys_name = &GetUserSymtem(); #系统名 my $Hostname = $ENV{HOST}; #主机名 my $User_group = &GetUserGroup(); #用户组 my $Username = &GetUserName(); #用户名 my $User_prive = &GetUserPrive(); #用户权限 #获取当前工作软件环境(默认获取Incam环境变量) my $Soft_path = $ENV{INCAM_PRODUCT}; #获取当前工作料号及step my $JOB = $ENV{JOB}; #料号 my $STEP = $ENV{STEP}; #Step ##########################初始化########################## #tk界面 my $mw = MainWindow->new(-background => "#CDD2E4"); my ($lVer,$Font,$ImgPath); $ImgPath = "$ENV{GENESIS_DIR}/sys/scripts/solder/icon"; chomp($ImgPath); if ($Sys_name =~ /Win/) { #系统权限 $lVer = "Windows"; $Font = "楷体 10"; } elsif ($Sys_name =~ /Linux/) { #获取系统名 $lVer = cat /etc/issue | head -n 1; chomp($lVer); $Font = "Ukai 10"; } else { $lVer = "Other OS"; $Font = "SimSun 10"; } if ($User_prive <= 10) { $mw->withdraw; &MessageDialogWarn("$panel_bp_101"); exit(0); } unless ($JOB) { #料号下执行权限 $mw->withdraw; &MessageDialogWarn("$panel_bp_102"); exit(0); } unless ($STEP) { #料号Step下执行权限 $mw->withdraw; &MessageDialogWarn("$panel_bp_103"); exit(0); } ##########################权限控制######################### #######################定义全局变量######################### my $Job_Path; #获取料号路径 if (defined $Soft_path) { $Job_Path = $f->COM("get_job_path,job=$JOB"); #InCAM } else { $Job_Path = $ENV{GENESIS_DIR}/e$ENV{GENESIS_VER}/misc/dbutil path jobs $JOB;chomp $Job_Path; #Genesis2000 } my $next_code = "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAACXBIWXMAAAsSAAALEgHS3X78AAAANklEQVQokWNgGAjwn4GBwZpUDSRp+s9Aoqb/DHg0MeLQgA7g6piIsNGGFCeR5AeSQomkeMALAJpZEs3h4b2/AAAAAElFTkSuQmCC"; my $Week = localtime->week; # my $images_path = "$ImgPath/icon"; # my ($tmopt,$gxopt,$Smdopt,$lbcyjz) = (1,2,2,2); #初始参数 my ($tmopt,$gxopt,$Smdopt,$lbcyjz) = (0.2,2,2.5,2); #初始参数 my $do_type = 'type_auto1'; my $l_message = undef; my $message = ""; my $mess = ""; my $event_id = undef; my ($Smd_opt_ftsz,$Cov_opt_ftsz,$Suf_opt_ftsz,$Suf_opt_yjsz,$jdzs,$jdzsjdz); #######################定义全局变量######################### ##########################料号数据######################### $f->DO_INFO("-t MATRIX -d ROW -e $JOB/matrix"); my ($info_ref,@maska,@signa,@mask,@sign); for (my $i = 0 ; $i < @{$f->{doinfo}{gROWname}} ; $i++) { $info_ref = { name => @{$f->{doinfo}{gROWname}}[$i], layer_type => @{$f->{doinfo}{gROWlayer_type}}[$i], context => @{$f->{doinfo}{gROWcontext}}[$i], polarity => @{$f->{doinfo}{gROWpolarity}}[$i], side => @{$f->{doinfo}{gROWside}}[$i], }; if ($info_ref->{context} eq "board" && $info_ref->{layer_type} eq "solder_mask" ) { push(@maska,$info_ref->{name}); } elsif ($info_ref->{context} eq "board" && $info_ref->{layer_type} eq "signal" && ($info_ref->{side} eq "top" || $info_ref->{side} eq "bottom")) { push(@signa,$info_ref->{name}); } } ##########################料号数据######################### ##################### #主窗口设置 my $logo1 = $mw->Photo(-format => 'png',-file => "$ImgPath/twei_logo.png"); my $logo2 = $mw->Photo(-format => 'png',-file => "$ImgPath/solder_dfm.png"); my $logo3 = $mw->Photo(-format => 'png',-file => "$ImgPath/ncc.png"); my $gwidth = 635; my $gheight = 350; if ($Sys_name =~ /Linux/) { $gheight = 380; } my $px = int(($mw->screenwidth() - $gwidth) / 2); my $py = int(($mw->screenheight() - $gheight - 20) / 2); $mw->geometry("${gwidth}x${gheight}+$px+$py"); $mw->resizable(0,0); $mw->bind("Escape", sub{exit}); $mw->title("防焊墓碑优化程式(开源免费无限制)"." 版本:$version --BpSystem"); # $mw->iconbitmap("$ImgPath/ncc.ico"); if ($Sys_name =~ /Linux/) { $mw->iconimage($logo3); } else { $mw->iconbitmap("$ImgPath/ncc.ico"); } my $LabelFrame = $mw->Frame( -relief => 'ridge', -background => "#CDD2E4", ) ->pack(-fill => 'x'); my $LabelLogo1 = $LabelFrame->Label( -image => $logo1, -anchor => 'w', -bg => "#CDD2E4", )->pack(-side => "left",-expand => 1); my $LabelText2 = $LabelFrame->Label( -text => " 开源时间:2019-12-17\n开发人员:一阵寒风\n微信号码:358143105", -bg => "#CDD2E4", -font => $Font, -fg => "#2f4f4f")->pack(-side => "left",-expand => 1); my $LabelLogo3 = $LabelFrame->Label( -image => $logo2, -anchor => 'w', -bg => "#CDD2E4" )->pack(-side => "left",-expand => 1); my $msgbar = $mw->Label( -borderwidth => 2, -relief => 'ridge', -bg => "#CDD2E4" )->pack(-side => 'top', -fill => 'x'); my $messbs = " 当前主机:$Hostname 用户组:$User_group 用户名:$Username 用户权限:$User_prive "; my $event_idmse = undef; $msgbar->Label( -textvariable => \$messbs, -font=>$Font, -bg => "#CDD2E4" )->pack(-fill => 'x'); $event_idmse = $mw->repeat(300, \&scroll); my $FrameMain = $mw->LabFrame( -label=>'参数调整区:', -foreground => "red", -font => $Font, -borderwidth => 2, -relief => 'ridge', -background => "#CDD2E4", ) ->pack(-fill => 'both'); my $SubFrameMain = $FrameMain->Frame(-background => "#CDD2E4",) ->pack(-fill => 'both'); ###################################################################################### my $SubFrameL = $SubFrameMain->LabFrame( -label=>'运行级别:', -foreground => "red", -font => $Font, -borderwidth => 2, -relief => 'ridge', -background => "#CDD2E4", ) ->pack(-fill => 'both'); my $main = $SubFrameL->Frame(-bg => "#CDD2E4",)->pack(-side => "top",-fill => 'both',-expand => 1); my $optionFrame = $main->Frame(-bg => "#CDD2E4",)->pack(-fill => 'both',-expand => 1); my $sle = $optionFrame->Radiobutton( -background => "#CDD2E4", -text => "整板制作", -font => $Font, -value => 'type_auto1', -variable => \$do_type, )->pack(-side=>'left',-expand => 1); my $i = 0; while ($i < scalar(@maska)) { $f->INFO(entity_type => 'layer',entity_path => "$JOB/$STEP/$maska[$i]"); if ($f->{doinfo}{gSIDE} eq "top") { my $sle1 = $optionFrame->Radiobutton( -background => "#CDD2E4", -text => "顶层制作", -font => $Font, -value => 'type_auto2', -variable => \$do_type, )->pack(-side=>'left',-expand => 1); my $sle2 = $optionFrame->Radiobutton( -background => "#CDD2E4", -text => "顶层自选", -font => $Font, -value => 'type_auto3', -variable => \$do_type, )->pack(-side=>'left',-expand => 1); } else { my $sle1 = $optionFrame->Radiobutton( -background => "#CDD2E4", -text => "底层制作", -font => $Font, -value => 'type_auto4', -variable => \$do_type, )->pack(-side=>'left',-expand => 1); my $sle2 = $optionFrame->Radiobutton( -background => "#CDD2E4", -text => "底层自选", -font => $Font, -value => 'type_auto5', -variable => \$do_type, )->pack(-side=>'left',-expand => 1); } $i++ } my $select_frm = $SubFrameMain->LabFrame( -label =>"参数设置:单位(mil),均为单边数值,自行调整最优的参数,\"()\"内为推荐参数范围", -borderwidth => 2, -background => "#CDD2E4", -fg => "red", -relief => 'ridge', -font => $Font, )->pack(-side=>'top',-fill=>'both'); my $show_check = $select_frm->Frame( -background => "#CDD2E4", -borderwidth =>2, -height => 20, )->pack(-side=>'top',-fill=>'both'); my $thick_board = $show_check->LabEntry( -label => '铜面SMD开窗值(0/1.0):', -labelBackground => '#CDD2E4', -labelFont => $Font, -textvariable => \$tmopt, -bg => 'white', -width => 15, -relief=>'ridge', -state=>"normal", -labelPack => [qw/-side left -anchor w/], )-> grid(-row => '0', -column => '0'); my $update = $show_check->LabEntry( -label => 'SMD最小盖线值(0/2.0):', -labelBackground => '#CDD2E4', -labelFont => $Font, -textvariable => \$gxopt, -bg => 'white', -width => 15, -relief=>'ridge', -state=>"normal", -labelPack => [qw/-side left -anchor w/], )-> grid(-row => '1', -column => '0'); my $updated = $show_check->Label(-text => ' ',-bg =>'#CDD2E4')->grid(-row => '0', -column => '1'); my $updatee = $show_check->Label(-text => ' ',-bg =>'#CDD2E4')->grid(-row => '1', -column => '1'); my $updats = $show_check->LabEntry( -label => '标准SMD开窗值(2/3.0):', -labelBackground => '#CDD2E4', -labelFont => $Font, -textvariable => \$Smdopt, -bg => 'white', -width => 15, -relief=>'ridge', -state=>"normal", -labelPack => [qw/-side left -anchor w/], )-> grid(-row => '0', -column => '2'); my $updath = $show_check->LabEntry( -label => 'SMD接铜圆角值(0/2.0):', -labelBackground => '#CDD2E4', -labelFont => $Font, -textvariable => \$lbcyjz, -bg => 'white', -width => 15, -relief=>'ridge', -state=>"normal", -labelPack => [qw/-side left -anchor w/], )-> grid(-row => '1', -column => '2'); my $button_frm = $mw->Frame(-background => "#CDD2E4",-borderwidth =>10,-height => 20)->pack(-anchor=>'e',-fill=>'both'); my $create_button = $button_frm->Button( -text => '执行', -command => sub {&appy}, -width => 8, -bg=>'#A1AEE1', -font=> $Font, -height=> 1, )->pack(-side=>'left',-expand => 1,); my $exit_button = $button_frm->Button( -text => '取消', -command => sub {exit;}, -width => 8, -bg=>'#A1AEE1', -font=> $Font, -height=> 1, )->pack(-side=>'left',-expand => 1,); my $help_button = $button_frm->Button( -text => '帮助', -command => \&helps, -width => 8, -bg=>'#A1AEE1', -font=> $Font, -height=> 1, )->pack(-side=>'left',-expand => 1,); ###################################################################################### my $msgarea = $mw->Label(-borderwidth => 2, -relief => 'ridge',-bg => "#7B7E89",-font=>$Font)->pack(-side => 'bottom', -fill => 'x'); my $next = $mw->Photo(-data=>$next_code, -format=>'png'); $msgarea->Label(-image=>$next,-bg => "white")->pack(-side=>'left',-expand => 1); $msgarea->Label(-textvariable => \$mess,-font=>$Font,-bg => "#7B7E89",-fg => "white")->pack(-side =>'left',-expand => 1); $event_id = $mw->repeat(300, \&timeout); MainLoop; #主程序 sub appy { if (scalar(@maska) == 2) { if ($do_type eq 'type_auto1') { @mask = @maska; @sign = @signa; } elsif ($do_type eq 'type_auto2' or $do_type eq 'type_auto3') { @mask = ($maska[0]); @sign = ($signa[0]); } elsif ($do_type eq 'type_auto4' or $do_type eq 'type_auto5') { @mask = ($maska[1]); @sign = ($signa[1]); } } elsif (scalar(@maska) == 1) { if ($do_type eq 'type_auto1') { @mask = @maska; $f->INFO(entity_type => 'layer',entity_path => "$JOB/$STEP/$maska[0]"); my $cjx = $f->{doinfo}{gSIDE}; foreach my $a(@signa) { $f->INFO(entity_type => 'layer',entity_path => "$JOB/$STEP/$a"); if ($f->{doinfo}{gSIDE} eq $cjx) { @sign = ($a); } } } elsif ($do_type eq 'type_auto2' or $do_type eq 'type_auto3') { @mask = @maska; foreach my $b(@signa) { $f->INFO(entity_type => 'layer',entity_path => "$JOB/$STEP/$b"); if ($f->{doinfo}{gSIDE} eq "top") { @sign = ($b); } } } elsif ($do_type eq 'type_auto4' or $do_type eq 'type_auto5') { @mask = @maska; foreach my $c(@signa) { $f->INFO(entity_type => 'layer',entity_path => "$JOB/$STEP/$c"); if ($f->{doinfo}{gSIDE} eq "bottom") { @sign = ($c); } } } } if ($tmopt eq "" || $gxopt eq "" || $Smdopt eq "" || $lbcyjz eq "") { &MessageDialogWarn("$panel_bp_104"); return; } $mw->iconify; $Smd_opt_ftsz = $Smdopt*2 + 1.2; $Cov_opt_ftsz = $gxopt*2 + 0.15; $Suf_opt_ftsz = $tmopt*2 - 0.1; $Suf_opt_yjsz = $tmopt*1; $f->COM ("units,type=inch"); my $a = 0; while ($a < scalar(@mask)) { &ClearLayer(); $f->VOF; &WorkLayer("$mask[$a].bk"); $f->COM ("sel_delete"); $f->VON; &DelectLay( "$mask[$a].tmp", "$mask[$a].tmps", "$mask[$a].tmpp", "$mask[$a].tmppt", "$mask[$a].tmppd", "$mask[$a].tmpos", "$mask[$a].ds", "$mask[$a].tmppp", "$mask[$a].tmpppd", "$mask[$a].tmppp+++", "$mask[$a].smd", "$mask[$a].smds" ); &WorkLayer("$mask[$a]"); &CopyLay("$mask[$a].bk","no",0); &WorkLayer("$sign[$a]"); my $selcct_fe; if ($do_type eq 'type_auto1' or $do_type eq 'type_auto2' or $do_type eq 'type_auto4') { $selcct_fe = &SelAttCopy(".smd",0,0); } elsif ($do_type eq 'type_auto3' or $do_type eq 'type_auto5') { &do_arec; last; } if ($selcct_fe != 0){ &CopyLay("$mask[$a].tmp","no",0); &WorkLayer("$mask[$a].tmp"); &CopyLay("$mask[$a].tmpp","no",0); &CopyLay("$mask[$a].smd","no",0); } else { last; } &WorkLayer("$sign[$a]"); &CopyLay("$mask[$a].tmppp","no",0); &WorkLayer("$mask[$a].tmpp"); if ($tmopt <= 0) { $jdzs = ($tmopt + $gxopt) * 2; $jdzsjdz = abs($jdzs); } else { $jdzs = 0.1; $jdzsjdz = 0; } &CopyLay("$mask[$a].tmppp","yes",$jdzs); &WorkLayer("$mask[$a].tmppp"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); $f->COM ("sel_resize,size=$Cov_opt_ftsz,corner_ctl=no"); &WorkLayer("$mask[$a].tmpp"); &CopyLay("$mask[$a].tmppp","yes",$Suf_opt_ftsz); &WorkLayer("$mask[$a].tmppp"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); $f->COM ("sel_resize,size=-1.5,corner_ctl=no"); &CopyLay("$mask[$a].tmpppd","no",0); $f->COM ("sel_surf2outline,width=1.5"); &WorkLayer("$mask[$a].tmpppd"); &CopyLay("$mask[$a].tmppp","no",0); &WorkLayer("$mask[$a].tmpp"); $f->COM ("sel_resize,size=$Smd_opt_ftsz,corner_ctl=no"); &CopyLay("$mask[$a].tmppt","no",0); &WorkLayer("$mask[$a].tmppp"); &CopyLay("$mask[$a].tmpp","yes",0); &CopyLay("$mask[$a].tmppt","yes",10); &WorkLayer("$mask[$a].tmppt"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); &CopyLay("$mask[$a].tmpp","no",0); &WorkLayer("$mask[$a].tmpp"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); $f->COM ("sel_resize,size=-$lbcyjz,corner_ctl=no"); &CopyLay("$mask[$a].tmppd","no",0); $f->COM ("sel_surf2outline,width=$lbcyjz"); &WorkLayer("$mask[$a].tmppd"); &CopyLay("$mask[$a].tmpp","no",0); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); &WorkLayer("$mask[$a].tmpp"); $f->COM ("fill_params,type=solid,origin_type=datum,solid_type=fill,std_type=line,min_brush=2,use_arcs=yes,symbol=,dx=0.1,dy=0.1,std_angle=45,std_line_width=10,std_step_dist=50,std_indent=odd,break_partial=yes,cut_prims=no,outline_draw=no,outline_width=0,outline_invert=no"); $f->COM ("sel_fill"); $f->COM ("sel_contourize,accuracy=0.1,break_to_islands=yes,clean_hole_size=3,clean_hole_mode=x_and_y"); &WorkLayer("$mask[$a].tmp"); $f->COM ("sel_resize,size=-0.5,corner_ctl=no"); &WorkLayer("$mask[$a].tmpp"); $f->COM ("sel_ref_feat,layers=$mask[$a].tmp,use=filter,mode=disjoint,pads_as=shape,f_types=line\;pad\;surface\;arc\;text,polarity=positive\;negative,include_syms=,exclude_syms="); my $selcct_com3 = $f->{COMANS}; if ($selcct_com3 != 0){ $f->COM ("sel_delete"); } $f->COM ("sel_ref_feat,layers=$mask[$a].tmp,use=filter,mode=cover,pads_as=shape,f_types=line\;pad\;surface\;arc\;text,polarity=positive\;negative,include_syms=,exclude_syms="); my $selcct_com2 = $f->{COMANS}; if ($selcct_com2 != 0){ $f->COM ("sel_delete"); } &WorkLayer("$mask[$a].tmp"); $f->COM ("sel_resize,size=$Smd_opt_ftsz,corner_ctl=no"); &CopyLay("$mask[$a].tmpos","no",-$lbcyjz); $f->COM ("sel_resize,size=-$lbcyjz,corner_ctl=no"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); $f->COM ("sel_surf2outline,width=$lbcyjz"); &WorkLayer("$mask[$a].tmpos"); &CopyLay("$mask[$a].tmp","no",0); &WorkLayer("$mask[$a].tmp"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); &WorkLayer("$mask[$a].tmpp"); &CopyLay("$mask[$a].tmp","yes",0.5); &WorkLayer("$mask[$a].tmp"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); $f->COM ("sel_resize,size=0.4,corner_ctl=no"); &WorkLayer("$mask[$a]"); &CopyLay("$mask[$a].ds","no",0); &WorkLayer("$mask[$a].ds"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); &WorkLayer("$mask[$a].smd"); $f->COM ("sel_resize,size=$tmopt,corner_ctl=no"); $f->COM ("sel_resize,size=$Suf_opt_yjsz,corner_ctl=no"); &CopyLay("$mask[$a].smds","no",-1); $f->COM ("sel_resize,size=-1,corner_ctl=no"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); $f->COM ("sel_surf2outline,width=1"); &WorkLayer("$mask[$a].smds"); &CopyLay("$mask[$a].smd","no",0); &WorkLayer("$mask[$a].smd"); &CopyLay("$mask[$a].tmp","yes",0); &WorkLayer("$mask[$a].tmp"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); $f->COM ("cur_atr_reset"); $f->COM ("cur_atr_set,attribute=.solder_defined"); $f->COM ("sel_change_atr,mode=add"); $f->COM ("cur_atr_reset"); $f->COM ("sel_ref_feat,layers=$mask[$a].ds,use=filter,mode=disjoint,pads_as=shape,f_types=line\;pad\;surface\;arc\;text,polarity=positive\;negative,include_syms=,exclude_syms="); my $selcct_com1 = $f->{COMANS}; if ($selcct_com1 != 0){ $f->COM ("sel_delete"); } $f->COM ("sel_ref_feat,layers=$mask[$a].ds,use=filter,mode=cover,pads_as=shape,f_types=line\;pad\;surface\;arc\;text,polarity=positive\;negative,include_syms=,exclude_syms="); $f->COM ("get_select_count"); my $selcct_com = $f->{COMANS}; if ($selcct_com != 0){ $f->COM ("sel_delete"); } &CopyLay("$mask[$a]","yes",0); $f->COM ("display_layer,name=$mask[$a].bk,display=yes,number=1"); $f->COM ("display_layer,name=$mask[$a],display=yes,number=2"); $f->COM ("work_layer,name=$mask[$a]"); &DelectLay( "$mask[$a].tmp", "$mask[$a].tmps", "$mask[$a].tmpp", "$mask[$a].tmppt", "$mask[$a].tmppd", "$mask[$a].tmpos", "$mask[$a].ds", "$mask[$a].tmppp", "$mask[$a].tmpppd", "$mask[$a].tmppp+++", "$mask[$a].smd", "$mask[$a].smds" ); $a++ } $mw->withdraw; &MessageDialoginfo("脚本运行完成,请认真核对备份层!"); exit; } sub do_arec { while (1) { $f->COM ("filter_reset,filter_name=popup"); $f->COM ("sel_clear_feat"); $f->COM ("clear_highlight"); $f->COM ("filter_set,filter_name=popup,update_popup=yes,feat_types=pad"); $f->COM ("filter_atr_set,filter_name=popup,condition=yes,attribute=.smd"); $f->COM ("filter_highlight"); $f->COM ("display_layer,name=$mask[$a],display=yes,number=2"); $f->MOUSE("r Please SELECT weizhi"); my @MOUSEANS=$f->{MOUSEANS}; my ($x1,$y1,$x2,$y2)=split /\s+/,$f->{MOUSEANS}; $f->COM("filter_area_strt"); $f->COM("filter_area_xy,x=$x1,y=$y1"); $f->COM("filter_area_xy,x=$x2,y=$y2"); $f->COM("filter_area_end,layer=,filter_name=popup,operation=select,area_type=rectangle,inside_area=yes,intersect_area=no"); $f->COM ("get_select_count"); my $selcct_fea = $f->{COMANS}; if ($selcct_fea != 0) { &CopyLay("$mask[$a].tmp","no",0); &WorkLayer("$mask[$a].tmp"); &CopyLay("$mask[$a].tmpp","no",0); &CopyLay("$mask[$a].smd","no",0); } else { $f->COM ("clear_highlight"); $f->COM ("filter_reset,filter_name=popup"); last; } &WorkLayer("$sign[$a]"); $f->COM("filter_reset,filter_name=popup"); $f->COM("filter_area_strt"); $f->COM("filter_area_xy,x=$x1,y=$y1"); $f->COM("filter_area_xy,x=$x2,y=$y2"); $f->COM("filter_area_end,layer=,filter_name=popup,operation=select,area_type=rectangle,inside_area=yes,intersect_area=yes"); &CopyLay("$mask[$a].tmppp","no",0); &WorkLayer("$mask[$a].tmpp"); if ($tmopt <= 0) { $jdzs = ($tmopt + $gxopt) * 2; $jdzsjdz = abs($jdzs); } else { $jdzs = 0.1; $jdzsjdz = 0; } &CopyLay("$mask[$a].tmppp","yes",$jdzs); &WorkLayer("$mask[$a].tmppp"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); $f->COM ("sel_resize,size=$Cov_opt_ftsz,corner_ctl=no"); &WorkLayer("$mask[$a].tmpp"); &CopyLay("$mask[$a].tmppp","yes",$Suf_opt_ftsz); &WorkLayer("$mask[$a].tmppp"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); $f->COM ("sel_resize,size=-1.5,corner_ctl=no"); &CopyLay("$mask[$a].tmpppd","no",0); $f->COM ("sel_surf2outline,width=1.5"); &WorkLayer("$mask[$a].tmpppd"); &CopyLay("$mask[$a].tmppp","no",0); $f->COM ("display_layer,name=$mask[$a].tmpp,display=yes,number=1"); $f->COM ("work_layer,name=$mask[$a].tmpp"); &WorkLayer("$mask[$a].tmpp"); $f->COM ("sel_resize,size=$Smd_opt_ftsz,corner_ctl=no"); &CopyLay("$mask[$a].tmppt","no",0); &WorkLayer("$mask[$a].tmppp"); &CopyLay("$mask[$a].tmpp","yes",0); &CopyLay("$mask[$a].tmppt","yes",10); &WorkLayer("$mask[$a].tmppt"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); &CopyLay("$mask[$a].tmpp","no",0); &WorkLayer("$mask[$a].tmpp"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); $f->COM ("sel_resize,size=-$lbcyjz,corner_ctl=no"); &CopyLay("$mask[$a].tmppd","no",0); $f->COM ("sel_surf2outline,width=$lbcyjz"); &WorkLayer("$mask[$a].tmppd"); &CopyLay("$mask[$a].tmpp","no",0); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); &WorkLayer("$mask[$a].tmpp"); $f->COM ("fill_params,type=solid,origin_type=datum,solid_type=fill,std_type=line,min_brush=2,use_arcs=yes,symbol=,dx=0.1,dy=0.1,std_angle=45,std_line_width=10,std_step_dist=50,std_indent=odd,break_partial=yes,cut_prims=no,outline_draw=no,outline_width=0,outline_invert=no"); $f->COM ("sel_fill"); $f->COM ("sel_contourize,accuracy=0.1,break_to_islands=yes,clean_hole_size=3,clean_hole_mode=x_and_y"); &WorkLayer("$mask[$a].tmp"); $f->COM ("sel_resize,size=-0.5,corner_ctl=no"); &WorkLayer("$mask[$a].tmpp"); $f->COM ("sel_ref_feat,layers=$mask[$a].tmp,use=filter,mode=disjoint,pads_as=shape,f_types=line\;pad\;surface\;arc\;text,polarity=positive\;negative,include_syms=,exclude_syms="); my $selcct_com3a = $f->{COMANS}; if ($selcct_com3a != 0){ $f->COM ("sel_delete"); } $f->COM ("sel_ref_feat,layers=$mask[$a].tmp,use=filter,mode=cover,pads_as=shape,f_types=line\;pad\;surface\;arc\;text,polarity=positive\;negative,include_syms=,exclude_syms="); my $selcct_com2a = $f->{COMANS}; if ($selcct_com2a != 0){ $f->COM ("sel_delete"); } &WorkLayer("$mask[$a].tmp"); $f->COM ("sel_resize,size=$Smd_opt_ftsz,corner_ctl=no"); &CopyLay("$mask[$a].tmpos","no",-$lbcyjz); $f->COM ("sel_resize,size=-$lbcyjz,corner_ctl=no"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); $f->COM ("sel_surf2outline,width=$lbcyjz"); &WorkLayer("$mask[$a].tmpos"); &CopyLay("$mask[$a].tmp","no",0); &WorkLayer("$mask[$a].tmp"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); &WorkLayer("$mask[$a].tmpp"); &CopyLay("$mask[$a].tmp","yes",0.5); &WorkLayer("$mask[$a].tmp"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); $f->COM ("sel_resize,size=0.4,corner_ctl=no"); &WorkLayer("$mask[$a]"); &CopyLay("$mask[$a].ds","no",0); &WorkLayer("$mask[$a].ds"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); &WorkLayer("$mask[$a].smd"); $f->COM ("sel_resize,size=$tmopt,corner_ctl=no"); $f->COM ("sel_resize,size=$Suf_opt_yjsz,corner_ctl=no"); &CopyLay("$mask[$a].smds","no",-1); $f->COM ("sel_resize,size=-1,corner_ctl=no"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes"); $f->COM ("sel_surf2outline,width=1"); &WorkLayer("$mask[$a].smds"); &CopyLay("$mask[$a].smd","no",0); &WorkLayer("$mask[$a].smd"); &CopyLay("$mask[$a].tmp","yes",0); &WorkLayer("$mask[$a].tmp"); $f->COM ("sel_cont_resize,accuracy=0.1,break_to_islands=yes,island_size=0,hole_size=0,drill_filter=no,corner_ctl=yes "); $f->COM ("cur_atr_reset"); $f->COM ("cur_atr_set,attribute=.solder_defined"); $f->COM ("sel_change_atr,mode=add"); $f->COM ("cur_atr_reset"); $f->COM ("sel_ref_feat,layers=$mask[$a].ds,use=filter,mode=disjoint,pads_as=shape,f_types=line\;pad\;surface\;arc\;text,polarity=positive\;negative,include_syms=,exclude_syms="); my $selcct_com1a = $f->{COMANS}; if ($selcct_com1a != 0){ $f->COM ("sel_delete"); } $f->COM ("sel_ref_feat,layers=$mask[$a].ds,use=filter,mode=cover,pads_as=shape,f_types=line\;pad\;surface\;arc\;text,polarity=positive\;negative,include_syms=,exclude_syms="); $f->COM ("get_select_count"); my $selcct_coma = $f->{COMANS}; if ($selcct_coma != 0){ $f->COM ("sel_delete"); } $f->COM ("sel_copy_other,dest=layer_name,target_layer=$mask[$a],invert=yes,dx=0,dy=0,size=0,x_anchor=0,y_anchor=0,rotation=0,mirror=none"); &CopyLay("$mask[$a]","yes",0); $f->COM ("display_layer,name=$sign[$a],display=yes,number=1"); $f->COM ("display_layer,name=$mask[$a],display=yes,number=2"); $f->COM ("work_layer,name=$sign[$a]"); &DelectLay( "$mask[$a].tmp", "$mask[$a].tmps", "$mask[$a].tmpp", "$mask[$a].tmppt", "$mask[$a].tmppd", "$mask[$a].tmpos", "$mask[$a].ds", "$mask[$a].tmppp", "$mask[$a].tmpppd", "$mask[$a].tmppp+++", "$mask[$a].smd", "$mask[$a].smds" ); $f->COM ("clear_highlight"); $f->COM ("filter_reset,filter_name=popup"); } } ##########################函数区########################## sub SelAttCopy { #属性选择 my ($attribute,$text,$option,$tolay,$invert,$size) = @_; $f->COM("filter_reset,filter_name=popup"); $f->COM ("filter_set,filter_name=popup,update_popup=yes,feat_types=pad"); $f->COM("filter_atr_set,filter_name=popup,condition=yes,attribute=$attribute,text=$text,option=$option"); $f->COM("filter_area_strt"); $f->COM("filter_area_end,layer=,filter_name=popup,operation=select,area_type=none,inside_area=no,intersect_area=no"); $f->COM("get_select_count"); my $selShul = $f->{COMANS}; return $selShul; } sub CopyLay { #复制层 my ($target_layer,$invert,$size) = @_; $f->COM("sel_copy_other,dest=layer_name,target_layer=$target_layer,invert=$invert,dx=0,dy=0,size=$size,x_anchor=0,y_anchor=0,rotation=0,mirror=none"); } sub DelectLay { #删除层(接收多个参数) $f->VOF(); foreach(@_){ $f->COM("delete_layer,layer=$_"); } $f->VON(); } sub WorkLayer { #工作层 my $WorkLay = shift; $f->COM("affected_layer,mode=all,affected=no"); $f->COM("clear_layers"); $f->COM("filter_reset,filter_name=popup"); $f->COM("display_layer,name=$WorkLay,display=yes,number=1"); $f->COM("work_layer,name=$WorkLay"); } sub ClearLayer { #层初始化 my $WorkLay = shift; $f->COM("affected_layer,mode=all,affected=no"); $f->COM("clear_layers"); $f->COM("filter_reset,filter_name=popup"); } sub helps { my $mw = MainWindow->new( -title =>"关于脚本",-background => "#CDD2E4"); $mw->geometry("560x680+800+100"); $mw->resizable(0,0); $mw->update; # if ($Sys_name =~ /Linux/) { # $mw->iconimage($logo3); # } else { # $mw->iconbitmap("$ImgPath/ncc.ico"); # } my $helps_log = $mw->Photo('info',-file => "$ImgPath/hp.xpm"); $mw ->Label(-image => $helps_log, -border => 1, -relief => 'solid',)->pack(-side => 'top',-padx => 1,-pady => 1); $mw->Label( -text => "注意事项及免责申明\n". "1.参数设置部分需根据本厂的具体工艺要求合理设置,特殊要求可视情况定制,\n". "2.使用推荐范围内的参数,综合管控及细节处理效果更佳,\n". "3.脚本运行不干涉防焊层,直接以负片的形式做出,请在运行脚本后再做塞孔处理,\n". "4.请认真核对备份层,以免造成未知错误对您产生影响,\n". "5.脚本可以提升效率及品质但不能替代人的作用,可信赖脚本但不可依赖,\n". "6.对于使用本脚本产生任何不良影响与脚本制作者无关,\n". "7.如您继续使用此脚本表示您已接受以上所有条款!\n", -font => '宋体 10', -background => "#CDD2E4" )->pack(-side => 'top',); $mw->Label( -text => "技术在于碰撞,欢迎大家批评指教,望大家共同努力共同进步!", -fg => 'blue', -font => '宋体 10', -background => "#CDD2E4", )->pack(-side => 'top',); $mw->Button( -text => '确定',-command => sub {$mw->destroy;}, -width => 8, -font=> '宋体 10', -height=> 1, -background => "#A1AEE1" )->pack(-side => 'right', -padx => 12, -pady => 12); $mw->Label( -text => "\n\n Copyright © 2017 Twei Tang. All rights reserved ", -fg => 'red', -font => '宋体 10', -background => "#CDD2E4", )->pack(-side => 'right',); MainLoop; } sub scroll { $messbs = substr($messbs, 1) . substr($messbs, 0, 1); } sub timeout { $mess = strftime("当前时间: %Y-%m-%d %H:%M:%S 第"."$Week"."周 当前系统: $lVer",localtime()); } sub GetUserSymtem { #获取系统名 my $Sys; if ($^O =~ /linux/) { $Sys = "Linux"; } elsif ($^O =~ /MSWin32/) { $Sys = "Windows"; } else { $Sys = "其它"; } return $Sys; } sub GetUserGroup { #获取用户组 $f->COM('get_user_group'); return $f->{COMANS}; } sub GetUserName { #获取用户名 $f->COM('get_user_name'); return $f->{COMANS}; } sub GetUserPrive { #获取用户权限 $f->COM('get_user_priv'); my @priv = split(/\s+/,$f->{COMANS}); return $priv[0]; } sub MessageDialog { #提示信息窗口 my $title = shift; my $icon = shift; my $type = shift; my $message = shift; $mw->messageBox( -icon => $icon, -message => $message, -title =>$title, ($Sys_name =~ /Linux/) ? (-font => $Font, -background => '#EDECEB', -bg => '#CDD2E4', -wraplength => '7i',-type => $type) : (-type => $type) ); return $type; } sub MessageDialogError { #错误提示窗口 $mw->withdraw; &MessageDialog('错误提示','error','ok',shift); exit; } sub MessageDialogWarn { #警告信息窗口 &MessageDialog('警告信息','error','ok',shift); } sub MessageDialoginfo { #操作信息窗口 &MessageDialog('操作信息','info','ok',shift); } ##########################函数区########################## 注意:这个是使用perl语言的TK GUI写的代码,请你把他变为activeperl TKX GUI的代码,要求实现的功能一模一样,不能添加新的库文件,我懒得添加

/* * Copyright (c) 2020 - 2025 Renesas Electronics Corporation and/or its affiliates * * SPDX-License-Identifier: BSD-3-Clause */ /*******************************************************************************************************************//** * @ingroup RENESAS_TRANSFER_INTERFACES * @defgroup TRANSFER_API Transfer Interface * * @brief Interface for data transfer functions. * * @section TRANSFER_API_SUMMARY Summary * The transfer interface supports background data transfer (no CPU intervention). * * * @{ **********************************************************************************************************************/ #ifndef R_TRANSFER_API_H #define R_TRANSFER_API_H /*********************************************************************************************************************** * Includes **********************************************************************************************************************/ /* Common error codes and definitions. */ #include "bsp_api.h" /* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */ FSP_HEADER /********************************************************************************************************************** * Macro definitions **********************************************************************************************************************/ #define TRANSFER_SETTINGS_MODE_BITS (30U) #define TRANSFER_SETTINGS_SIZE_BITS (28U) #define TRANSFER_SETTINGS_SRC_ADDR_BITS (26U) #define TRANSFER_SETTINGS_CHAIN_MODE_BITS (22U) #define TRANSFER_SETTINGS_IRQ_BITS (21U) #define TRANSFER_SETTINGS_REPEAT_AREA_BITS (20U) #define TRANSFER_SETTINGS_DEST_ADDR_BITS (18U) /********************************************************************************************************************** * Typedef definitions **********************************************************************************************************************/ /** Transfer control block. Allocate an instance specific control block to pass into the transfer API calls. */ typedef void transfer_ctrl_t; #ifndef BSP_OVERRIDE_TRANSFER_MODE_T /** Transfer mode describes what will happen when a transfer request occurs. */ typedef enum e_transfer_mode { /** In normal mode, each transfer request causes a transfer of @ref transfer_size_t from the source pointer to * the destination pointer. The transfer length is decremented and the source and address pointers are * updated according to @ref transfer_addr_mode_t. After the transfer length reaches 0, transfer requests * will not cause any further transfers. */ TRANSFER_MODE_NORMAL = 0, /** Repeat mode is like normal mode, except that when the transfer length reaches 0, the pointer to the * repeat area and the transfer length will be reset to their initial values. If DMAC is used, the * transfer repeats only transfer_info_t::num_blocks times. After the transfer repeats * transfer_info_t::num_blocks times, transfer requests will not cause any further transfers. If DTC is * used, the transfer repeats continuously (no limit to the number of repeat transfers). */ TRANSFER_MODE_REPEAT = 1, /** In block mode, each transfer request causes transfer_info_t::length transfers of @ref transfer_size_t. * After each individual transfer, the source and destination pointers are updated according to * @ref transfer_addr_mode_t. After the block transfer is complete, transfer_info_t::num_blocks is * decremented. After the transfer_info_t::num_blocks reaches 0, transfer requests will not cause any * further transfers. */ TRANSFER_MODE_BLOCK = 2, /** In addition to block mode features, repeat-block mode supports a ring buffer of blocks and offsets * within a block (to split blocks into arrays of their first data, second data, etc.) */ TRANSFER_MODE_REPEAT_BLOCK = 3 } transfer_mode_t; #endif #ifndef BSP_OVERRIDE_TRANSFER_SIZE_T /** Transfer size specifies the size of each individual transfer. * Total transfer length = transfer_size_t * transfer_length_t */ typedef enum e_transfer_size { TRANSFER_SIZE_1_BYTE = 0, ///< Each transfer transfers a 8-bit value TRANSFER_SIZE_2_BYTE = 1, ///< Each transfer transfers a 16-bit value TRANSFER_SIZE_4_BYTE = 2, ///< Each transfer transfers a 32-bit value TRANSFER_SIZE_8_BYTE = 3 ///< Each transfer transfers a 64-bit value } transfer_size_t; #endif #ifndef BSP_OVERRIDE_TRANSFER_ADDR_MODE_T /** Address mode specifies whether to modify (increment or decrement) pointer after each transfer. */ typedef enum e_transfer_addr_mode { /** Address pointer remains fixed after each transfer. */ TRANSFER_ADDR_MODE_FIXED = 0, /** Offset is added to the address pointer after each transfer. */ TRANSFER_ADDR_MODE_OFFSET = 1, /** Address pointer is incremented by associated @ref transfer_size_t after each transfer. */ TRANSFER_ADDR_MODE_INCREMENTED = 2, /** Address pointer is decremented by associated @ref transfer_size_t after each transfer. */ TRANSFER_ADDR_MODE_DECREMENTED = 3 } transfer_addr_mode_t; #endif #ifndef BSP_OVERRIDE_TRANSFER_REPEAT_AREA_T /** Repeat area options (source or destination). In @ref TRANSFER_MODE_REPEAT, the selected pointer returns to its * original value after transfer_info_t::length transfers. In @ref TRANSFER_MODE_BLOCK and @ref TRANSFER_MODE_REPEAT_BLOCK, * the selected pointer returns to its original value after each transfer. */ typedef enum e_transfer_repeat_area { /** Destination area repeated in @ref TRANSFER_MODE_REPEAT or @ref TRANSFER_MODE_BLOCK or @ref TRANSFER_MODE_REPEAT_BLOCK. */ TRANSFER_REPEAT_AREA_DESTINATION = 0, /** Source area repeated in @ref TRANSFER_MODE_REPEAT or @ref TRANSFER_MODE_BLOCK or @ref TRANSFER_MODE_REPEAT_BLOCK. */ TRANSFER_REPEAT_AREA_SOURCE = 1 } transfer_repeat_area_t; #endif #ifndef BSP_OVERRIDE_TRANSFER_CHAIN_MODE_T /** Chain transfer mode options. * @note Only applies for DTC. */ typedef enum e_transfer_chain_mode { /** Chain mode not used. */ TRANSFER_CHAIN_MODE_DISABLED = 0, /** Switch to next transfer after a single transfer from this @ref transfer_info_t. */ TRANSFER_CHAIN_MODE_EACH = 2, /** Complete the entire transfer defined in this @ref transfer_info_t before chaining to next transfer. */ TRANSFER_CHAIN_MODE_END = 3 } transfer_chain_mode_t; #endif #ifndef BSP_OVERRIDE_TRANSFER_IRQ_T /** Interrupt options. */ typedef enum e_transfer_irq { /** Interrupt occurs only after last transfer. If this transfer is chained to a subsequent transfer, * the interrupt will occur only after subsequent chained transfer(s) are complete. * @warning DTC triggers the interrupt of the activation source. Choosing TRANSFER_IRQ_END with DTC will * prevent activation source interrupts until the transfer is complete. */ TRANSFER_IRQ_END = 0, /** Interrupt occurs after each transfer. * @note Not available in all HAL drivers. See HAL driver for details. */ TRANSFER_IRQ_EACH = 1 } transfer_irq_t; #endif #ifndef BSP_OVERRIDE_TRANSFER_CALLBACK_ARGS_T /** Callback function parameter data. */ typedef struct st_transfer_callback_args_t { void const * p_context; ///< Placeholder for user data. Set in @ref transfer_api_t::open function in ::transfer_cfg_t. } transfer_callback_args_t; #endif /** Driver specific information. */ typedef struct st_transfer_properties { uint32_t block_count_max; ///< Maximum number of blocks uint32_t block_count_remaining; ///< Number of blocks remaining uint32_t transfer_length_max; ///< Maximum number of transfers uint32_t transfer_length_remaining; ///< Number of transfers remaining } transfer_properties_t; #ifndef BSP_OVERRIDE_TRANSFER_INFO_T /** This structure specifies the properties of the transfer. * @warning When using DTC, this structure corresponds to the descriptor block registers required by the DTC. * The following components may be modified by the driver: p_src, p_dest, num_blocks, and length. * @warning When using DTC, do NOT reuse this structure to configure multiple transfers. Each transfer must * have a unique transfer_info_t. * @warning When using DTC, this structure must not be allocated in a temporary location. Any instance of this * structure must remain in scope until the transfer it is used for is closed. * @note When using DTC, consider placing instances of this structure in a protected section of memory. */ typedef struct st_transfer_info { union { struct { uint32_t : 16; uint32_t : 2; /** Select what happens to destination pointer after each transfer. */ transfer_addr_mode_t dest_addr_mode : 2; /** Select to repeat source or destination area, unused in @ref TRANSFER_MODE_NORMAL. */ transfer_repeat_area_t repeat_area : 1; /** Select if interrupts should occur after each individual transfer or after the completion of all planned * transfers. */ transfer_irq_t irq : 1; /** Select when the chain transfer ends. */ transfer_chain_mode_t chain_mode : 2; uint32_t : 2; /** Select what happens to source pointer after each transfer. */ transfer_addr_mode_t src_addr_mode : 2; /** Select number of bytes to transfer at once. @see transfer_info_t::length. */ transfer_size_t size : 2; /** Select mode from @ref transfer_mode_t. */ transfer_mode_t mode : 2; } transfer_settings_word_b; uint32_t transfer_settings_word; }; void const * volatile p_src; ///< Source pointer void * volatile p_dest; ///< Destination pointer /** Number of blocks to transfer when using @ref TRANSFER_MODE_BLOCK (both DTC an DMAC) or * @ref TRANSFER_MODE_REPEAT (DMAC only) or * @ref TRANSFER_MODE_REPEAT_BLOCK (DMAC only), unused in other modes. */ volatile uint16_t num_blocks; /** Length of each transfer. Range limited for @ref TRANSFER_MODE_BLOCK, @ref TRANSFER_MODE_REPEAT, * and @ref TRANSFER_MODE_REPEAT_BLOCK * see HAL driver for details. */ volatile uint16_t length; } transfer_info_t; #endif /** Driver configuration set in @ref transfer_api_t::open. All elements except p_extend are required and must be * initialized. */ typedef struct st_transfer_cfg { /** Pointer to transfer configuration options. If using chain transfer (DTC only), this can be a pointer to * an array of chained transfers that will be completed in order. */ transfer_info_t * p_info; void const * p_extend; ///< Extension parameter for hardware specific settings. } transfer_cfg_t; /** Select whether to start single or repeated transfer with software start. */ typedef enum e_transfer_start_mode { TRANSFER_START_MODE_SINGLE = 0, ///< Software start triggers single transfer. TRANSFER_START_MODE_REPEAT = 1 ///< Software start transfer continues until transfer is complete. } transfer_start_mode_t; /** Transfer functions implemented at the HAL layer will follow this API. */ typedef struct st_transfer_api { /** Initial configuration. * * @param[in,out] p_ctrl Pointer to control block. Must be declared by user. Elements set here. * @param[in] p_cfg Pointer to configuration structure. All elements of this structure * must be set by user. */ fsp_err_t (* open)(transfer_ctrl_t * const p_ctrl, transfer_cfg_t const * const p_cfg); /** Reconfigure the transfer. * Enable the transfer if p_info is valid. * * @param[in,out] p_ctrl Pointer to control block. Must be declared by user. Elements set here. * @param[in] p_info Pointer to a new transfer info structure. */ fsp_err_t (* reconfigure)(transfer_ctrl_t * const p_ctrl, transfer_info_t * p_info); /** Reset source address pointer, destination address pointer, and/or length, keeping all other settings the same. * Enable the transfer if p_src, p_dest, and length are valid. * * @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer. * @param[in] p_src Pointer to source. Set to NULL if source pointer should not change. * @param[in] p_dest Pointer to destination. Set to NULL if destination pointer should not change. * @param[in] num_transfers Transfer length in normal mode or number of blocks in block mode. In DMAC only, * resets number of repeats (initially stored in transfer_info_t::num_blocks) in * repeat mode. Not used in repeat mode for DTC. */ fsp_err_t (* reset)(transfer_ctrl_t * const p_ctrl, void const * p_src, void * p_dest, uint16_t const num_transfers); /** Enable transfer. Transfers occur after the activation source event (or when * @ref transfer_api_t::softwareStart is called if no peripheral event is chosen as activation source). * * @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer. */ fsp_err_t (* enable)(transfer_ctrl_t * const p_ctrl); /** Disable transfer. Transfers do not occur after the activation source event (or when * @ref transfer_api_t::softwareStart is called if no peripheral event is chosen as the DMAC activation source). * @note If a transfer is in progress, it will be completed. Subsequent transfer requests do not cause a * transfer. * * @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer. */ fsp_err_t (* disable)(transfer_ctrl_t * const p_ctrl); /** Start transfer in software. * @warning Only works if no peripheral event is chosen as the DMAC activation source. * @note Not supported for DTC. * * @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer. * @param[in] mode Select mode from @ref transfer_start_mode_t. */ fsp_err_t (* softwareStart)(transfer_ctrl_t * const p_ctrl, transfer_start_mode_t mode); /** Stop transfer in software. The transfer will stop after completion of the current transfer. * @note Not supported for DTC. * @note Only applies for transfers started with TRANSFER_START_MODE_REPEAT. * @warning Only works if no peripheral event is chosen as the DMAC activation source. * * @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer. */ fsp_err_t (* softwareStop)(transfer_ctrl_t * const p_ctrl); /** Provides information about this transfer. * * @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer. * @param[out] p_properties Driver specific information. */ fsp_err_t (* infoGet)(transfer_ctrl_t * const p_ctrl, transfer_properties_t * const p_properties); /** Releases hardware lock. This allows a transfer to be reconfigured using @ref transfer_api_t::open. * * @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer. */ fsp_err_t (* close)(transfer_ctrl_t * const p_ctrl); /** To update next transfer information without interruption during transfer. * Allow further transfer continuation. * * @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer. * @param[in] p_src Pointer to source. Set to NULL if source pointer should not change. * @param[in] p_dest Pointer to destination. Set to NULL if destination pointer should not change. * @param[in] num_transfers Transfer length in normal mode or block mode. */ fsp_err_t (* reload)(transfer_ctrl_t * const p_ctrl, void const * p_src, void * p_dest, uint32_t const num_transfers); /** Specify callback function and optional context pointer and working memory pointer. * * @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer. * @param[in] p_callback Callback function to register * @param[in] p_context Pointer to send to callback function * @param[in] p_callback_memory Pointer to volatile memory where callback structure can be allocated. * Callback arguments allocated here are only valid during the callback. */ fsp_err_t (* callbackSet)(transfer_ctrl_t * const p_ctrl, void (* p_callback)(transfer_callback_args_t *), void const * const p_context, transfer_callback_args_t * const p_callback_memory); } transfer_api_t; /** This structure encompasses everything that is needed to use an instance of this interface. */ typedef struct st_transfer_instance { transfer_ctrl_t * p_ctrl; ///< Pointer to the control structure for this instance transfer_cfg_t const * p_cfg; ///< Pointer to the configuration structure for this instance transfer_api_t const * p_api; ///< Pointer to the API structure for this instance } transfer_instance_t; /* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */ FSP_FOOTER #endif /*******************************************************************************************************************//** * @} (end defgroup TRANSFER_API) **********************************************************************************************************************/ 这里存在 // 标准函数原型应类似: fsp_err_t R_TRANSFER_Open( transfer_ctrl_t * const p_ctrl, transfer_cfg_t const * const p_cfg);

最新推荐

recommend-type

C# Socket通信源码:多连接支持与断线重连功能的物联网解决方案

内容概要:本文介绍了一套基于C#编写的Socket服务器与客户端通信源码,源自商业级物联网项目。这套代码实现了双Socket机制、多连接支持以及断线重连功能,适用于各类C#项目(如MVC、Winform、控制台、Webform)。它通过简单的静态类调用即可获取客户端传输的数据,并内置了接收和发送数据缓冲队列,确保数据传输的稳定性。此外,代码提供了数据读取接口,但不涉及具体的数据处理逻辑。文中详细展示了服务端和客户端的基本配置与使用方法,强调了在实际应用中需要注意的问题,如避免主线程执行耗时操作以防内存膨胀。 适合人群:具备基本C#编程能力的研发人员,尤其是对Socket通信有一定了解并希望快速集成相关功能到现有项目中的开发者。 使用场景及目标:① 需要在短时间内为C#项目增加稳定的Socket通信功能;② 实现多设备间的数据交换,特别是对于智能家居、工业传感器等物联网应用场景。 其他说明:虽然该代码能够满足大多数中小型项目的通信需求,但对于需要高性能、低延迟的金融级交易系统则不太合适。同时,代码并未采用异步技术,因此在面对海量连接时可能需要进一步优化。
recommend-type

掌握XFireSpring整合技术:HELLOworld原代码使用教程

标题:“xfirespring整合使用原代码”中提到的“xfirespring”是指将XFire和Spring框架进行整合使用。XFire是一个基于SOAP的Web服务框架,而Spring是一个轻量级的Java/Java EE全功能栈的应用程序框架。在Web服务开发中,将XFire与Spring整合能够发挥两者的优势,例如Spring的依赖注入、事务管理等特性,与XFire的简洁的Web服务开发模型相结合。 描述:“xfirespring整合使用HELLOworld原代码”说明了在这个整合过程中实现了一个非常基本的Web服务示例,即“HELLOworld”。这通常意味着创建了一个能够返回"HELLO world"字符串作为响应的Web服务方法。这个简单的例子用来展示如何设置环境、编写服务类、定义Web服务接口以及部署和测试整合后的应用程序。 标签:“xfirespring”表明文档、代码示例或者讨论集中于XFire和Spring的整合技术。 文件列表中的“index.jsp”通常是一个Web应用程序的入口点,它可能用于提供一个用户界面,通过这个界面调用Web服务或者展示Web服务的调用结果。“WEB-INF”是Java Web应用中的一个特殊目录,它存放了应用服务器加载的Servlet类文件和相关的配置文件,例如web.xml。web.xml文件中定义了Web应用程序的配置信息,如Servlet映射、初始化参数、安全约束等。“META-INF”目录包含了元数据信息,这些信息通常由部署工具使用,用于描述应用的元数据,如manifest文件,它记录了归档文件中的包信息以及相关的依赖关系。 整合XFire和Spring框架,具体知识点可以分为以下几个部分: 1. XFire框架概述 XFire是一个开源的Web服务框架,它是基于SOAP协议的,提供了一种简化的方式来创建、部署和调用Web服务。XFire支持多种数据绑定,包括XML、JSON和Java数据对象等。开发人员可以使用注解或者基于XML的配置来定义服务接口和服务实现。 2. Spring框架概述 Spring是一个全面的企业应用开发框架,它提供了丰富的功能,包括但不限于依赖注入、面向切面编程(AOP)、数据访问/集成、消息传递、事务管理等。Spring的核心特性是依赖注入,通过依赖注入能够将应用程序的组件解耦合,从而提高应用程序的灵活性和可测试性。 3. XFire和Spring整合的目的 整合这两个框架的目的是为了利用各自的优势。XFire可以用来创建Web服务,而Spring可以管理这些Web服务的生命周期,提供企业级服务,如事务管理、安全性、数据访问等。整合后,开发者可以享受Spring的依赖注入、事务管理等企业级功能,同时利用XFire的简洁的Web服务开发模型。 4. XFire与Spring整合的基本步骤 整合的基本步骤可能包括添加必要的依赖到项目中,配置Spring的applicationContext.xml,以包括XFire特定的bean配置。比如,需要配置XFire的ServiceExporter和ServicePublisher beans,使得Spring可以管理XFire的Web服务。同时,需要定义服务接口以及服务实现类,并通过注解或者XML配置将其关联起来。 5. Web服务实现示例:“HELLOworld” 实现一个Web服务通常涉及到定义服务接口和服务实现类。服务接口定义了服务的方法,而服务实现类则提供了这些方法的具体实现。在XFire和Spring整合的上下文中,“HELLOworld”示例可能包含一个接口定义,比如`HelloWorldService`,和一个实现类`HelloWorldServiceImpl`,该类有一个`sayHello`方法返回"HELLO world"字符串。 6. 部署和测试 部署Web服务时,需要将应用程序打包成WAR文件,并部署到支持Servlet 2.3及以上版本的Web应用服务器上。部署后,可以通过客户端或浏览器测试Web服务的功能,例如通过访问XFire提供的服务描述页面(WSDL)来了解如何调用服务。 7. JSP与Web服务交互 如果在应用程序中使用了JSP页面,那么JSP可以用来作为用户与Web服务交互的界面。例如,JSP可以包含JavaScript代码来发送异步的AJAX请求到Web服务,并展示返回的结果给用户。在这个过程中,JSP页面可能使用XMLHttpRequest对象或者现代的Fetch API与Web服务进行通信。 8. 项目配置文件说明 项目配置文件如web.xml和applicationContext.xml分别在Web应用和服务配置中扮演关键角色。web.xml负责定义Web组件,比如Servlet、过滤器和监听器,而applicationContext.xml则负责定义Spring容器中的bean,包括数据源、事务管理器、业务逻辑组件和服务访问器等。 总之,通过上述整合使用原代码的知识点,可以深入理解XFire与Spring框架的结合使用,以及如何开发和部署基本的Web服务。这些技术知识有助于进行更高层次的Web服务开发,以及在复杂的IT环境中灵活运用各种框架和工具。
recommend-type

【Unity2018汉化大揭秘】:一步到位优化中文用户体验

# 摘要 本论文详细介绍了Unity2018汉化项目的实施过程,从理论准备到实践步骤,再到后期的测试与优化,最终分享了汉化经验和心得。首先,强调了汉化项目对于用户体验提升和产品国际化的重要性,并分析了汉化资源的分类、识别与管理方法。接着,详细阐述了汉化工具的选择、脚本编写、资源手动调整等实践步骤,以及汉化质量测试、体验优化和项目维护更新的重要性。论文最后通过案例研究,分析了汉化中的挑战和应对策略,并预测了汉化技术未来的发展方向。整个汉化过程不仅涉及技术层面的操作,还包含了深入的理论研究和实践心得分享,对提升汉化项目的效率和质量具有指导意义。 # 关键字 Unity汉化;用户体验;国际化;资源
recommend-type

iPhone

<think>我们注意到用户意图不明确,但提到了“照片提取”和“其他功能帮助”。因此,我们需要通过搜索来获取关于iPhone照片提取的常见方法以及其他可能的功能帮助。由于用户问题比较宽泛,我们将重点放在照片提取上,因为这是明确提到的关键词。同时,我们也会考虑一些其他常用功能的帮助。首先,针对照片提取,可能涉及从iPhone导出照片、从备份中提取照片、或者从损坏的设备中恢复照片等。我们将搜索这些方面的信息。其次,关于其他功能帮助,我们可以提供一些常见问题的快速指南,如电池优化、屏幕时间管理等。根据要求,我们需要将答案组织为多个方法或步骤,并在每个步骤间换行。同时,避免使用第一人称和步骤词汇。由于
recommend-type

驾校一点通软件:提升驾驶证考试通过率

标题“驾校一点通”指向的是一款专门为学员考取驾驶证提供帮助的软件,该软件强调其辅助性质,旨在为学员提供便捷的学习方式和复习资料。从描述中可以推断出,“驾校一点通”是一个与驾驶考试相关的应用软件,这类软件一般包含驾驶理论学习、模拟考试、交通法规解释等内容。 文件标题中的“2007”这个年份标签很可能意味着软件的最初发布时间或版本更新年份,这说明了软件具有一定的历史背景和可能经过了多次更新,以适应不断变化的驾驶考试要求。 压缩包子文件的文件名称列表中,有以下几个文件类型值得关注: 1. images.dat:这个文件名表明,这是一个包含图像数据的文件,很可能包含了用于软件界面展示的图片,如各种标志、道路场景等图形。在驾照学习软件中,这类图片通常用于帮助用户认识和记忆不同交通标志、信号灯以及驾驶过程中需要注意的各种道路情况。 2. library.dat:这个文件名暗示它是一个包含了大量信息的库文件,可能包含了法规、驾驶知识、考试题库等数据。这类文件是提供给用户学习驾驶理论知识和准备科目一理论考试的重要资源。 3. 驾校一点通小型汽车专用.exe:这是一个可执行文件,是软件的主要安装程序。根据标题推测,这款软件主要是针对小型汽车驾照考试的学员设计的。通常,小型汽车(C1类驾照)需要学习包括车辆构造、基础驾驶技能、安全行车常识、交通法规等内容。 4. 使用说明.html:这个文件是软件使用说明的文档,通常以网页格式存在,用户可以通过浏览器阅读。使用说明应该会详细介绍软件的安装流程、功能介绍、如何使用软件的各种模块以及如何通过软件来帮助自己更好地准备考试。 综合以上信息,我们可以挖掘出以下几个相关知识点: - 软件类型:辅助学习软件,专门针对驾驶考试设计。 - 应用领域:主要用于帮助驾考学员准备理论和实践考试。 - 文件类型:包括图片文件(images.dat)、库文件(library.dat)、可执行文件(.exe)和网页格式的说明文件(.html)。 - 功能内容:可能包含交通法规知识学习、交通标志识别、驾驶理论学习、模拟考试、考试题库练习等功能。 - 版本信息:软件很可能最早发布于2007年,后续可能有多个版本更新。 - 用户群体:主要面向小型汽车驾照考生,即C1类驾照学员。 - 使用方式:用户需要将.exe安装文件进行安装,然后根据.html格式的使用说明来熟悉软件操作,从而利用images.dat和library.dat中的资源来辅助学习。 以上知识点为从给定文件信息中提炼出来的重点,这些内容对于了解“驾校一点通”这款软件的功能、作用、使用方法以及它的发展历史都有重要的指导意义。
recommend-type

【DFLauncher自动化教程】:简化游戏启动流程,让游戏体验更流畅

# 摘要 DFLauncher是一个功能丰富的游戏启动和管理平台,本论文将介绍其安装、基础使用、高级设置、社区互动以及插件开发等方面。通过对配置文件的解析、界面定制、自动化功能的实现、高级配置选项、安全性和性能监控的详细讨论,本文阐述了DFLauncher如何帮助用户更高效地管理和优化游戏环境。此外,本文还探讨了DFLauncher社区的资源分享、教育教程和插件开发等内容,
recommend-type

自适应卡尔曼滤波是什么意思

<think>嗯,用户这次想深入了解自适应卡尔曼滤波(AKF)的概念和原理。从对话历史看,用户之前研究过相机自动对焦系统的降噪技术,其中提到过自适应卡尔曼滤波的应用场景。用户可能是个工程师或研究者,正在探索信号处理在具体场景的实现细节。 用户提供的三篇参考文献很有价值:[1]是基础理论综述,[2]聚焦多传感器场景,[3]讨论噪声协方差自适应方法。需要特别注意相机AF系统的特殊需求——实时性要求高(每秒数十次对焦计算)、噪声环境复杂(机械振动/弱光干扰),这些在解释原理时要结合具体案例。 技术要点需要分层解析:先明确标准卡尔曼滤波的局限(固定噪声参数),再展开自适应机制。对于相机AF场景,重
recommend-type

EIA-CEA 861B标准深入解析:时间与EDID技术

EIA-CEA 861B标准是美国电子工业联盟(Electronic Industries Alliance, EIA)和消费电子协会(Consumer Electronics Association, CEA)联合制定的一个技术规范,该规范详细规定了视频显示设备和系统之间的通信协议,特别是关于视频显示设备的时间信息(timing)和扩展显示识别数据(Extended Display Identification Data,简称EDID)的结构与内容。 在视频显示技术领域,确保不同品牌、不同型号的显示设备之间能够正确交换信息是至关重要的,而这正是EIA-CEA 861B标准所解决的问题。它为制造商提供了一个统一的标准,以便设备能够互相识别和兼容。该标准对于确保设备能够正确配置分辨率、刷新率等参数至关重要。 ### 知识点详解 #### EIA-CEA 861B标准的历史和重要性 EIA-CEA 861B标准是随着数字视频接口(Digital Visual Interface,DVI)和后来的高带宽数字内容保护(High-bandwidth Digital Content Protection,HDCP)等技术的发展而出现的。该标准之所以重要,是因为它定义了电视、显示器和其他显示设备之间如何交互时间参数和显示能力信息。这有助于避免兼容性问题,并确保消费者能有较好的体验。 #### Timing信息 Timing信息指的是关于视频信号时序的信息,包括分辨率、水平频率、垂直频率、像素时钟频率等。这些参数决定了视频信号的同步性和刷新率。正确配置这些参数对于视频播放的稳定性和清晰度至关重要。EIA-CEA 861B标准规定了多种推荐的视频模式(如VESA标准模式)和特定的时序信息格式,使得设备制造商可以参照这些标准来设计产品。 #### EDID EDID是显示设备向计算机或其他视频源发送的数据结构,包含了关于显示设备能力的信息,如制造商、型号、支持的分辨率列表、支持的视频格式、屏幕尺寸等。这种信息交流机制允许视频源设备能够“了解”连接的显示设备,并自动设置最佳的输出分辨率和刷新率,实现即插即用(plug and play)功能。 EDID的结构包含了一系列的块(block),其中定义了包括基本显示参数、色彩特性、名称和序列号等在内的信息。该标准确保了这些信息能以一种标准的方式被传输和解释,从而简化了显示设置的过程。 #### EIA-CEA 861B标准的应用 EIA-CEA 861B标准不仅适用于DVI接口,还适用于HDMI(High-Definition Multimedia Interface)和DisplayPort等数字视频接口。这些接口技术都必须遵循EDID的通信协议,以保证设备间正确交换信息。由于标准的广泛采用,它已经成为现代视频信号传输和显示设备设计的基础。 #### EIA-CEA 861B标准的更新 随着技术的进步,EIA-CEA 861B标准也在不断地更新和修订。例如,随着4K分辨率和更高刷新率的显示技术的发展,该标准已经扩展以包括支持这些新技术的时序和EDID信息。任何显示设备制造商在设计新产品时,都必须考虑最新的EIA-CEA 861B标准,以确保兼容性。 #### 结论 EIA-CEA 861B标准是电子显示领域的一个重要规范,它详细定义了视频显示设备在通信时所使用的信号时序和设备信息的格式。该标准的存在,使得不同厂商生产的显示设备可以无缝连接和集成,极大地增强了用户体验。对于IT专业人士而言,了解和遵守EIA-CEA 861B标准是进行视频系统设计、故障诊断及设备兼容性测试的重要基础。
recommend-type

【DFLauncher应用实战】:如何将DFLauncher融入矮人要塞并提升效率

# 摘要 DFLauncher是一款功能全面的游戏管理工具,旨在简化游戏安装、启动和维护过程。本文介绍了DFLauncher的基本使用方法,详细解析了其核心功能,包括游戏库管理、游戏配置优化、更新机制等。同时,文章探讨了DFLauncher在特定游戏“矮人要塞”中的集成应用,以及通过插件和脚本进行的高级定制。故障诊断与系统优化章节提供了实用的诊断方法和性能提升技巧。最后,本文展望了DFLauncher的未来发展方向,并鼓励社区贡献和用户反馈,以满足不断变化的用户需求。 # 关键字 DFLauncher;游戏管理工具;安装配置;性能优化;故障诊断;社区贡献;定制化扩展;网络功能集成 参考资源
recommend-type

银河麒麟系统打开屏保

<think>嗯,用户的问题是关于银河麒麟操作系统如何开启屏幕保护程序。这个问题其实挺实用的,毕竟长时间盯着电脑屏幕容易造成视觉疲劳,屏幕保护能起到一定的保护作用。 从用户提供的引用内容来看,引用[2]提到了银河麒麟系统的常见问题处理,包括重启输入法和双屏配置问题,虽然不直接相关,但说明用户对系统设置有一定了解。引用[3]是关于安装cmake的,可能用户之前尝试过其他系统配置操作。 用户可能是在办公环境中使用银河麒麟系统,需要保护视力。考虑到银河麒麟是基于Linux开发的国产操作系统,它的屏幕保护设置应该和主流Linux发行版类似,但可能有自己的特色功能。 我回忆了一下Linux系统的屏