Peergine编程手册
python pegen 例子
python pegen 例子标题:Python PEGEN例子1. Python PEGEN简介Python PEGEN是一个用于生成解析器的Python库。
它可以根据用户定义的语法规则生成解析器代码,用于解析和处理特定格式的文本数据。
这样的解析器可以用于构建编译器、解释器、数据处理工具等应用。
2. 如何安装Python PEGEN安装Python PEGEN非常简单,只需使用pip命令即可。
在命令行中运行以下命令:pip install pegen3. Python PEGEN的基本语法Python PEGEN使用类似正则表达式的语法来定义语法规则。
用户可以定义终结符和非终结符,并使用操作符(如*、+、|等)来组合规则。
下面是一个简单的例子:expr = term ('+' term)*term = number | '(' expr ')'number = digit+4. 解析简单算术表达式下面是一个使用Python PEGEN解析简单算术表达式的例子:from pegen import Parserclass ArithmeticParser(Parser):expr = term ('+' term)*term = number | '(' expr ')'number = digit+parser = ArithmeticParser()result = parser.parse("1 + 2 * (3 + 4)")print(result) # 输出: 155. 解析自定义语言Python PEGEN不仅可以用于解析算术表达式,还可以用于解析自定义的语言。
下面是一个解析简单函数调用的例子:from pegen import Parserclass FunctionCallParser(Parser):expr = func_callfunc_call = identifier '(' arg_list? ')'arg_list = expr (',' expr)*identifier = letter (letter | digit)*letter = 'a' | 'b' | ... | 'z' | 'A' | 'B' | ... | 'Z'digit = '0' | '1' | ... | '9'parser = FunctionCallParser()result = parser.parse("print(a, b, c)")print(result) # 输出: ['print', 'a', 'b', 'c']6. 错误处理Python PEGEN提供了灵活的错误处理机制,可以捕获语法错误并提供有意义的错误提示。
ispLever使用教程
实例二
通过ispLever将一个复杂的数字 信号处理算法映射到FPGA芯片上 ,展示物理实现的高级特性和优 化技巧。
实例三
介绍如何使用ispLever的物理实 现功能来加速嵌入式系统设计的 过程,提高开发效率。
2024/1/26
27
06 仿真与验证
2024/1/26
28
仿真与验证概述
仿真
使用ispLever进行电路设计时,仿真是一 个重要环节,它可以帮助设计者预测电 路在实际环境中的行为。通过仿真,可 以检查电路的功能、性能和可靠性。
人工智能与机器学习
结合ispLever与AI/ML框架,实现高 性能、低功耗的AI/ML硬件加速器设 计。
38
使用技巧与注意事项
熟悉工具链与流程
在使用ispLever前,建议熟悉相关工具链和开发流程,以便高效地进行设计开发。
合理选择设计策略
根据实际需求和应用场景,合理选择设计策略和优化方法,以达到最佳性能。
提供常用功能的快捷按钮,方便用户 快速执行命令。
2024/1/26
14
界面介绍
工作区
显示当前打开的文件或项目,以及相关的编辑和预览窗口。
状态栏
显示当前操作状态和相关提示信息。
2024/1/26
15
界面介绍
1
用户可以通过视图菜单或工具栏中的按钮进行界 面元素的显示与隐藏。
2
支持自定义快捷键和工具栏按钮,提高操作效率 。
VS
验证
验证是在完成电路设计后,通过与实际硬 件或已知良好设计的比较来确认设计的正 确性和完整性。ispLever提供了多种验证 工具和技术,以确保设计的准确性和一致 性。
2024/1/26
Protégé基本教程【Protégé5
Protégé基本教程【Protégé5.5.0版本】⽬录Q&A1. 为什么protege⾥⾯owlviz tab中所有的东西都缩在左上⾓?因为没有安装graphviz,⾸先在官⽹()下载grahviz,下载好以后安装。
然后在protege⾥⾯点击file-preferences-owlviz⾥⾯,修改graphviz的地址就好了。
2. 怎么增加and关系(e.g. pizza and has topping)直接在这个框⾥⾯输⼊就⾏啦!⼀、前⾔参考⽂档:Protégé4OWL官⽅⼊门教程因为在⽹上看到的教程使⽤的Protégé版本⽐较⽼了,⽽且是英⽂的,这⾥做⼀个整理。
Protégé软件是斯坦福⼤学医学院⽣物信息研究中⼼基于Java语⾔开发的本体编辑和知识获取软件,或者说是本体开发⼯具,也是基于知识的编辑器,属于开放源代码软件。
这个软件主要⽤于语义⽹中本体的构建,是语义⽹中本体构建的核⼼开发⼯具,现在的最新版本为5.5.0版本。
Protégé提供了本体概念类,关系,属性和实例的构建,并且屏蔽了具体的本体描述语⾔,⽤户只需在概念层次上进⾏领域本体模型的构建。
(如果官⽹下载⽐较慢的话,我放⼀个百度⽹盘的链接在这⾥:)现在下载到的Protégé⼀般是⼀个压缩包,压缩包解压之后有Protege.exe和run.bat这两个⽂件,点击任何⼀个都可以打开Protégé。
Protégé⼀打开的界⾯主要是Active Ontology这个Tab的界⾯。
本体的名字可以在Ontology IRI⾥⾯修改。
Annotations是注释栏,可以对本体添加⼀些信息注释或者描述。
右边Ontology metrics会显⽰⼀些本体中相关元素的统计信息。
兄弟连区块链技术培训Fabric 1.0源代码分析(32) Peer #peer node start命令实现
兄弟连区块链技术培训Fabric 1.0源代码分析(32) Pee r #peer node start命令实现## 1、peer node加载子命令start和statuspeer node加载子命令start和status,代码如下:```gofunc Cmd() *mand {nodeCmd.AddCommand(startCmd()) //加载子命令startnodeCmd.AddCommand(statusCmd()) //加载子命令statusreturn nodeCmd}var nodeCmd = &mand{Use: nodeFuncName,Short: fmt.Sprint(shortDes),Long: fmt.Sprint(longDes),}//代码在peer/node/node.go```startCmd()代码如下:其中serve(args)为peer node start的实现代码,比较复杂,本文将重点讲解。
另statusCmd()代码与startCmd()相近,暂略。
```gofunc startCmd() *mand {flags := nodeStartCmd.Flags()flags.BoolVarP(&chaincodeDevMode, "peer-chaincodedev", "", false, " Whether peer in chaincode development mode")flags.BoolVarP(&peerDefaultChain, "peer-defaultchain", "", false, " Whether to start peer with chain testchainid")flags.StringVarP(&orderingEndpoint, "orderer", "o", "orderer:7050 ", "Ordering service endpoint") //ordererreturn nodeStartCmd}var nodeStartCmd = &mand{Use: "start",Short: "Starts the node.",Long: `Starts a node that interacts with the network.`,RunE: func(cmd *mand, args []string) error {return serve(args) //serve(args)为peer node start的实现代码},}//代码在peer/node/start.go```**注:如下内容均为serve(args)的代码,即peer node start命令执行流程。
兄弟连区块链教程Fabric1.0源代码分析Peer peer根命令入口及加载子命令
兄弟连区块链教程Fabric1.0源代码分析Peer peer根命令入口及加载子命令一兄弟连区块链教程Fabric1.0源代码分析Peer peer根命令入口及加载子命令,2018年下半年,区块链行业正逐渐褪去发展之初的浮躁、回归理性,表面上看相关人才需求与身价似乎正在回落。
但事实上,正是初期泡沫的渐退,让人们更多的关注点放在了区块链真正的技术之上。
# Fabric 1.0源代码笔记之 Peer #peer根命令入口及加载子命令## 1、加载环境变量配置和配置文件Fabric支持通过环境变量对部分配置进行更新,如:CORE_LOGGING_LEVEL为输出的日志级别、CORE_PEER_ID为Peer的ID等。
此部分功能由第三方包viper来实现,viper除支持环境变量的配置方式外,还支持配置文件方式。
viper使用方法参考:https:///spf13/viper。
如下代码为加载环境变量配置,其中cmdRoot为"core",即CORE_开头的环境变量。
```goviper.SetEnvPrefix(cmdRoot)viper.AutomaticEnv()replacer := strings.NewReplacer(".", "_")viper.SetEnvKeyReplacer(replacer)//代码在peer/main.go```加载配置文件,同样由第三方包viper来实现,具体代码如下:其中cmdRoot为"core",即/etc/hyperledger/fabric/core.yaml。
```goerr := common.InitConfig(cmdRoot)//代码在peer/main.go```如下代码为common.InitConfig(cmdRoot)的具体实现:```goconfig.InitViper(nil, cmdRoot)err := viper.ReadInConfig()//代码在peer/common/common.go```另附config.InitViper(nil, cmdRoot)的代码实现:优先从环境变量FABRIC_CFG_PATH中获取配置文件路径,其次为当前目录、开发环境目录(即:src//hyperledger/fabric/sampleconfig)、和OfficialPath(即:/etc/hyperledger/fabric)。
SESAM软件GeniE建模自学手册大全A4_GeniE_Semisub_PanelModel
Modelling in GeniE Part 0 - GeneralSESAM Tutorial in Panel ModellingMaking a panel model including tanks•The purpose of this workshop is to show how to make a parametric input file (journal file) to create a panel model of a semi-submersible.•The tutorial is based on a pre-defined input file where main dimensions of the semi-submersible are variables. This means that by changing the variables in the journal fileprior to reading it into GeniE different panel models may be created.•The objective is that the user will gain experiences from learning how the journal file has been built up. The journal file was build from a combination of editing a journal file and agraphic modelling session where the input is based on the variables and not coordinatevalues as for normal modelling. The journal file contains comments so that the user easilycan understand the steps.•The tutorial is meant for the user that has enough knowledge in GeniE to understand how journal files may be created for advanced usage. The user does not need to knowprogramming in scripting language – if so the journal input file may be even moreadvanced.•The panel model that will be created by reading in the journal file is a semi-submersible with 8 columns and 4 tanks, one in each end of the pontoons.•The journal file will create a finite element mesh and export a FEM-file called Semi_sub_panel_T1.FEM to the directory where you have saved the input journal file. Thisfile may be used by HydroD for stability or hydrodynamic analysis.Modelling in GeniEP o n _H e i g h tXZPon_LengthRad_Large Rad_Small Rad_LargeRad_Small CC_LargeCC_Small C o l _H e i g h tD e p t hPart 1 – Main dimensionsCC_Columns D e p t hYZCC_Columns/2Pon_DepthP o n _H e i g h tC o l _H e i g h t •The main dimensions of the platform are variables, seen from the side•The main dimensions, seen from top•The variables as defined in the predefined journal fileFor references, see previous pageThe settings for number of elements along a line Md_Line are used to control the mesh around the column and along the height of thepontoon•Mesh details changing default values6 elements on a quarter part of column6 elements along height of pontoon•The variables as defined in the predefined journal file Using the default values gives the following•The variables as defined in the predefined journal fileUsing the default values gives the following dummy hydro pressure and tank fillings needed by HydroDThere are 4 tanks, one in each corner•Changing pontoon height and diameter of small column gives the followingPon_Height=12m and Rad_Small=4m The tanks change accordinglyD e f a u l t v a l u e s•An example on how the journal file has been built upThe variables may be changed from editing the journal fileThe variables are used in all relevant commands to generate the structure and the panel modellingAll steps have comments so it is easy to understand the sequence of commands and modelling•The complete finite element modelCreated in GeniE and includes necessary data for HydroD, tank4 shownModel imported to HydroD, some of the tanks are filled and equilibrium position is computed。
2024ispLEVER教程
ispLEVER教程•教程简介与背景•ispLEVER 基础操作•原理图设计与编辑技巧•PCB 布局布线实战演练•仿真测试与验证方法论述•团队协作与版本控制策略分享目录CONTENTS01教程简介与背景ispLEVER概述ispLEVER 是Lattice半导体公司提供的一款集成开发环境(IDE),用于设计、模拟和编程Lattice FPGA和CPLD器件。
它提供了一套完整的工具链,包括设计输入、综合、布局布线、时序分析、仿真和下载等,方便用户进行FPGA/CPLD设计。
ispLEVER支持多种设计输入方式,如原理图、硬件描述语言(HDL)和混合输入等,并提供了丰富的IP核和库函数,以加速设计过程。
教程目标与内容本教程的目标是帮助读者掌握ispLEVER的基本操作和设计流程,能够独立完成简单的FPGA/CPLD设计。
教程内容包括ispLEVER的安装与配置、设计输入、综合与布局布线、时序分析、仿真和下载等关键步骤的详细讲解。
通过本教程的学习,读者将了解FPGA/CPLD设计的基本原理和方法,并具备一定的实践能力和问题解决能力。
1 2 3在学习本教程之前,读者应具备数字电路和计算机组成原理的基本知识,了解FPGA/CPLD的基本概念和原理。
读者需要掌握一种硬件描述语言(如VHDL或Verilog),以便进行FPGA/CPLD设计。
对于初学者,建议具备一定的编程基础,如C/C 或Python等,以便更好地理解和应用ispLEVER 中的相关概念和工具。
预备知识与技能要求本教程采用理论与实践相结合的方法,通过详细的步骤讲解和实例演示,帮助读者逐步掌握ispLEVER的使用方法。
对于遇到的问题和困难,可以通过查阅ispLEVER的官方文档或在线论坛寻求帮助和解决方案。
学习方法与建议在学习过程中,建议读者结合实例进行操作练习,加深对相关概念和工具的理解和掌握。
此外,鼓励读者在学习过程中积极思考和探索,尝试将所学知识应用于实际项目中,以提高学习效果和实践能力。
2024年ispLEVER培训教程-(多应用版)
ispLEVER培训教程-(多应用版)ispLEVER培训教程一、概述ispLEVER是MentorGraphics公司推出的一款功能强大的电子设计自动化(EDA)软件,广泛应用于集成电路(IC)的设计与验证。
本教程旨在帮助用户快速掌握ispLEVER的基本操作,了解其各项功能,为IC设计工作提供有力支持。
二、教程结构1.ispLEVER简介:介绍ispLEVER的基本概念、功能和特点。
2.ispLEVER安装与启动:指导用户完成ispLEVER的安装、启动及环境配置。
3.ispLEVER基本操作:讲解ispLEVER的基本操作,包括项目管理、文件操作、视图切换等。
4.ispLEVER设计流程:介绍ispLEVER的设计流程,包括原理图设计、布局布线、版图绘制等。
5.ispLEVER高级功能:讲解ispLEVER的高级功能,如时序分析、功耗分析、DFM等。
6.ispLEVER实用技巧:分享ispLEVER的使用技巧,提高设计效率。
7.ispLEVER常见问题解答:解答用户在使用ispLEVER过程中可能遇到的问题。
三、ispLEVER简介ispLEVER是一款基于Windows操作系统的EDA软件,支持多种IC设计流程,包括数字、模拟、混合信号等。
其主要特点如下:1.高度集成:ispLEVER集成了原理图设计、布局布线、版图绘制、仿真验证等功能,用户可以在一个平台上完成整个设计流程。
2.强大的仿真引擎:ispLEVER内置了多种仿真引擎,如DC、AC、TRAN、NOISE等,可满足不同类型电路的仿真需求。
3.丰富的库资源:ispLEVER提供了丰富的器件库和工艺库,支持多种工艺节点,方便用户进行设计。
4.易学易用:ispLEVER界面友好,操作简便,支持快捷键和鼠标操作,降低用户学习成本。
5.高效的设计流程:ispLEVER支持层次化设计,可提高设计复用率;支持团队协作,提高设计效率。
四、ispLEVER安装与启动1.安装前准备:确保计算机满足ispLEVER的系统要求,如操作系统、内存、硬盘空间等。
SimpleBGC 32bit脚本语言参考手册说明书
Scripting Language ReferenceSimpleBGC 32bitActual firmware version: 2.70b5 and aboveUpdated: 17. Oct. 2021OverviewScripting language is intended to control a gimbal by user-written program. This program is uploaded to controller and executed there without a connection to PC. Program can be started by a command from remote controller (RC), menu button or GUI button.There is a simple editor in the SimpleBGC GUI with the syntax checking and tracing of the execution process, but you can use any text editors you like to edit scripts.General rules•Each line can contain only one command•Command may have up to 10 named parameters separated by space.•All values must be in decimal notation with a fractional part separated by a dot. Fractional part can be omitted.•You can add comments starting line with the # character, but comments are not saved to the board. Command notation:ANGLE RA(10) PA(10) ...command parameter name value other parametersSome commands may have one-letter abbreviation, for example “ANGLE” has a shortcut “A”.Parameters controlled in real-time (frw. ver. 2.60b3)Values of parameters in any command can be dynamically updated during the execution of a program by linking them to any of RC signal sources. Just specify the signal source name and the desired range of the parameter's value, and RC signal will be captured and mapped to this range at the start of the command. Note that the value is not updated during the command execution.All available RC signal source names are listed in the Appendix 3.Usage:<PARAMETER_NAME>(<RC_SOURCE_NAME>[<min_value>,<max_value>])The advanced scripting version supports also variables as parameter values. Variables may be set by the command SET_ADJ_VAR.Usage:<PARAMETER_NAME>(<VARIABLE_NAME>[<offset>,<scale>]), where parameter value is calculated as “<variable_value>*<scale> + <offset>”Examples:ANGLE RA(ADC1[-50,50]) PA(RC_VIRT_CH_1[0,90])SPEED YS(TMP_VAR_1[0,1])Advanced functionsSome versions of SBGC32 controller having big FLASH and RAM memory size, support advanced functions which do not present in the basic version of script processor:•Temporarily variables can be set by SET_ADJ_VAR command and used as a signal source in other commands;•Basic arithmetic operations;•IF .. GOTO command to implement control flow of the script (loops, conditional forks);•Motion synchronization option to synchronize trajectory between axes in commands ANGLE, INC.Advanced script functions are supported in the following controllers:•“Extended” series: “Extended”, “Extended long”, “Pro”, “CAN_MCU”, “OEM”•“Plus” series: “Regular+”, “Tiny+”Command referenceA, ANGLE — rotation to the absolute angle with a given speedCommand stops the program and waits until the angle reaches a given value. Rotation is done by the shortest path. If you want to turn the camera on the relative angle greater than ± 180 degrees, use the INC command instead. You can set the speed for each axis. If speed is not set, will be used the current value defined in the settings or command “CONFIG”.Parameters:RA(10.0) — target angle by the ROLL axis, in degreesPA(10.0) - target angle by the PITCH axisYA(10.0) - target angle by the YAW axisRS(10.0) — speed by the ROLL axis, degree/sec. in range 0..2000, special value 0 is used to synchronize motion with other axis.PS(10.0) - speed by the PITCH axisYS(10.0) - speed by the YAW axisTIMEOUT(60.0) – wait timeout. If not specified, it is 60 seconds by default.(supported in firmware ver.2.59+)Example:A RA(0) PA(0) YA(0)# go to home position by all axesA YA(70) YS(1)# rotate YAW to 70 degree with the speed 1 degree/sec.Motion synchronizationThe advanced scripting version in firmware 2.70b5 and above provides an option to synchronize a motion of any axis with the motion of another axis by specifying its speed parameter = 0. The last axis with the 'angle' parameter preceding the zero 'speed' parameter in the parameter string is selected as a sample for synchronization. Target angles should be specified for both axes and should differ from current angles. Example:A RA(0) PA(0) YA(0)# move to the initial positionA PA(20) PS(50) YA(90) YS(0)# YAW axis is asked to be synchronized with the PITCH axis. YAW travels 90°, but it takes exactly the same time as PITCH traveling 20°. Both axes have perfectly matched acceleration / deacceleration ramps.Wrong examples:A YA(90) YS(0)# error: sync sample is not definedA PA(0) YA(90) YS(0)# error: target angle in the sample should differ from its current angleI, INC - rotation by the relative angle with a given speedCommand stops the program and waits until the angle rotates by a given value. Angle should not exceed two full turns. The motion synchronization option is supported.Parameters:RA(10.0) — target angle by the ROLL axis, in degrees. Range -720..720PA(10.0) - target angle by the PITCH axisYA(10.0) - target angle by the YAW axisRS(10.0) — speed by the ROLL axis, degree/sec. in range 0..2000, special value 0 is used to synchronize motion with other axis.PS(10.0) - speed by the PITCH axisYS(10.0) - speed by the YAW axisTIMEOUT(60.0) – wait timeout. If not specified, it is 60 seconds by default.(supported in firmware ver.2.59+)Example:I YA(270)# rotate by YAW by 270 degree from current positionS, SPEED - turn with a given speed until it encounters another command SPEED, ANGLE, INC or the end of the program.The camera starts moving and program execution continues without delay.Parameters:RS(10.0) — speed by ROLL axis, degree/sec. Range -2000..2000.PS(10.0) - speed by PITCH axisYS(10.0) - speed by YAW axisExample:S YS(5.5)# panning by YAW with the speed 5.5 degree/secS RS(0) PS(0) YS(0)# full stopR, RESET — set the YAW angle = 0 for the current positionParameters:noT, TRIGGER — trigger the state of the output pinsParameters:1(0) — pin ID * and its state:0 – LOW (GND)1 — HIGH (+3.3V)2 – FLOATING (frw.ver. 2.66+)3 – FLOATING + PULLUP 3.3V (frw.ver. 2.66+)TIMEOUT(0.01) (optional) – if specified, program execution is delayed by a given time, in seconds.** At the end of the timeout the specified pins will be inverted (HIGH → LOW, LOW → HIGH). Don't set this parameter if you need to keep pin'sstate after triggering. A necessary delay may be created by the separate 'DELAY' command.* Mapping between Pin ID and physical port can be found in the Appendix 1. The pin should be free of otherfunctions (for example, not be used as an input in the RC settings tab).** Accuracy is ±1 millisecond. Specifying a timeout can be useful for example, to manually set the shutterspeed when shooting HDR images.Example:T 1(1) 2(1)# switch outputs ID=1,2 to a HIGH stateT 1(1) TIMEOUT(0.020)# switch output ID=1 to a HIGH state and return back to LOW after 20ms SERVO — set PWM signal pulse width on the specified pinThis command is used to control the servos connected to the special pins that supports output of PWM signal. PWM rate can be changed in the GUI (RC - PWM Output - PWM Rate, Hz).Parameters:1(1500) — Servo ID* and pulse duration, microseconds. For regular servo values are in the range 900-2100. Special value -1 frees pin and makes it high-impedance input.TIME(3)** — travel time to target position, in secondsTIMEOUT(1) — when target is reached, program execution is delayed by a giventime, in seconds.* Mapping between Servo ID and physical port can be found in the Appendix 1. The pin should be free of other functions (for example, not be used as an input in the RC settings tab).**Firmware ver. 2.5x and aboveExample:SERVO 1(1500) 2(1500)# move two servos to a middle positionSERVO 1(1000) TIME(3)# slowly move from 1500 to 1000 in 3 secondsSERVO 1(2000) TIMEOUT(1)# set new value and wait 1 secondSERVO 1(-1) 2(-1)# free two outputsD, DELA Y - delay of program executionParameters:TIMEOUT(10) — delay, in seconds. Accuracy ±1 milliseconds.Example:D TIMEOUT(0.300)# delay for 300 millisecondsW, WAIT – waiting for the specified angle or speedProgram execution is delayed until all specified conditions will be satisfied, or a given timeout will be expired. Parameters:RA(10.0) — angle by the ROLL axis, in degreesPA(10.0) — angle by the PITCH axisYA(10.0) — angle by the YAW axisRS(0) - speed by the ROLL axis, in degrees/sec.PS(0) - speed by the PITCH axisYS(0) - speed by the YAW axisTIMEOUT(10) – max. time of waiting, in seconds. Default is 60 sec.Example:W YA(30)# wait for YAW angle=30 degreeW RA(0) PA(0) YA(0)# wait for angle=0 for all axesW YS(0) TIMEOUT(1)# wait to stop motion by YAW axis, but not more than 1 second. CONFIG — configure some parameters used in program executionParameters:ACC_LIMIT_R(100), ACC_LIMIT_P(100), ACC_LIMIT_Y(100) — acceleration limit for the ROLL, PITCH, YAW axes, degrees/sec²SPEED_R(10), SPEED_P(10), SPEED_Y(10) — speed for the ROLL, PITCH, YAW axes, degree/sec. Range is 0..2000. Initial value is taken from the “RC SPEED” parameters INIT_SYSTEM_ON_FINISH(1) (ver. 2.60b3+) – if set to 1 (default), system will be re-initialized when script finishes (all parameters and modes of operation will be returned to default). If set to 0, system will be left in it's current state.JERK_SLOPE_R(50), JERK_SLOPE_P(50), JERK_SLOPE_Y(50) (ver. 2.66+) — jerk limiter for the ROLL, PITCH, YAW axis, the rise/fall time in msThe changed parameters are not saved to the persistent memory and will be reset to their original values when program is finished.Example:С ACC_LIMIT_R(100) SPEED_Y(5) # set an acceleration limit for the ROLL axis to 100 degree/sec² and a speed for YAW axis to 5 degree/sec.MENU_CMD — execute a menu command(frw. ver. 2.60b3+)Parameters:CMD_ID(10) – command ID to run. Full list of commands is listed in the Appendix 2. In case of any command is missed there, it can be found in the Serial API documentation. Script parser does not wait for command to be finished!TIMEOUT(1) – program execution is delayed by a given time, in seconds.SET_ADJ_VAR — set the value of adjustable variable (frw. ver. 2.61)Parameters:NAME(GYRO_TRUST) – name of variable. All names are provided in the SBGC32 User Manual, "Adjustable variables" section.VALUE(100) – new value to set.You can specify up to 5 pairs NAME - VALUE in a single commandExample:SET_ADJ_VAR NAME(RC_SPEED_PITCH) VALUE(60) NAME(RC_SPEED_ROLL) VALUE(50)The advanced scripting version supports temporarily variables and arithmetic operations on them. Variables can be used as parameters in other commands, can be sent for external logging, or used for flow control (see IF .. GOTO command definition). System keeps their values between script executions, so you need to reset values at the start of the script, if needed.Variables:•TMP_VAR_1 .. TMP_VAR_10 (floating point type) – may be used in a script only•API_VIRT_CH_1 .. API_VIRT_CH_32 (int16 type) – may be used as a source ofcontrol signal in all places where RC channels are assigned, value ±16384encodes the full RC range.Operations:OPERATOR(=+-*/%) – do arithmetic operation on two values, where 1st value isresult of all previous calculations and 2nd value is a value of the nextparameter in sequence. If OPERATOR goes next to the NAME parameter, the current value of the variable is used.Examples:SET_ADJ_VAR NAME(TMP_VAR_1) VALUE(1) NAME(TMP_VAR_2) VALUE(1)Result: TMP_VAR_1 = 1, TMP_VAR_2 = 1SET_ADJ_VAR NAME(TMP_VAR_1) OPERATOR(+) VALUE(10)Result: TMP_VAR_1 = 11SET_ADJ_VAR NAME(TMP_VAR_3) VALUE(TMP_VAR_1[0,1]) OPERATOR(+) VALUE(TMP_VAR_2[-5,4])OPERATOR(*) VALUE(10)Result: TMP_VAR_3 = (11 + (1*4 - 5))*10 = 100PLA Y_SOUND — plays standard sound and blinks LED (frw. ver. 2.68)Parameters:CMD_ID(1) – sound to play:•1 – calibration•2 – confirmation•4 – error•8 – alarm•16 – single click•32 – action complete•64 – startup melodyModifiers (can be combined with the ID by OR operator):•16384 – silent mode: do not emit sound, just blink LEDTIMEOUT(1) – program execution is delayed by a given time, in seconds. If notimeout is specified, program goes to a next command, playing sound in thebackground.IF — conditional flow control of the script (frw. ver. 2.69b7)The advanced scripting version supports a flow control using IF .. GOTO command together with theSET_ADJ_VAR command and temporarily variables.Parameters:NAME(<VARIABLE_NAME>) – name of the variable to compare, one of the:•TMP_VAR_1..TMP_VAR_10 – floating point type•API_VIRT_CH_1..API_VIRT_CH_32 – int16 type•all adjustable variables listed in “User Manual”VALUE(<value | RC source[min,max] | variable[offset,scale]>) – value to compare.It may be a regular decimal value or RC signal source/variable.COND(<condition>) – condition to be used in a comparison of variable and thefollowing VALUE parameter. Both values are rounded to integers before comparing, excepting >> and << operations.•= - equal•!= - not equal•> - greater•>= - greater or equal•< - less•<= - less or equal•>> - greater, not rounded•<< - less, not roundedGOTO(<line number | label_name>) – line number in script to jump if condition is true. It's recommended to use labels instead. You can place label before anycommand or on empty line, in a form of “LABEL_NAME: mand..”Command expects two values, provided by the NAME or VALUE parameters, one COND parameter and one GOTO parameter. In case of (NAME|VALUE)x2 and COND parameters are missed, GOTO will do unconditional jump.Example: repeat INC command 10 times to rotate YAW axis by 10-degree steps, sending a short pulse to pin AUX1 after each step.SET_ADJ_VAR NAME(TMP_VAR_1) VALUE(0)LOOP1: SET_ADJ_VAR NAME(TMP_VAR_1) OPERATOR(+) VALUE(1)INC YA(10)TRIGGER 16(1) TIMEOUT(0.5)IF NAME(TMP_VAR_1) COND(<) VALUE(10) GOTO(LOOP1)Appendix 1. Mapping between pin IDs and physical ports Labeling on the board Trigger pin ID Servo ID RC_ROLL1-RC_PITCH23 RC_YAW5-EXT_FC_ROLL31 EXT_FC_PITCH42 AUX1164 AUX217-AXU318-BUZZER32-Appendix 2: Menu commands MENU_CMD_PROFILE1 = 1MENU_CMD_PROFILE2 = 2MENU_CMD_PROFILE3 = 3MENU_CMD_SWAP_PITCH_ROLL = 4MENU_CMD_SWAP_YAW_ROLL = 5MENU_CMD_CALIB_ACC = 6MENU_CMD_RESET = 7MENU_CMD_SET_ANGLE = 8MENU_CMD_CALIB_GYRO = 9MENU_CMD_MOTOR_TOGGLE = 10MENU_CMD_MOTOR_ON = 11MENU_CMD_MOTOR_OFF = 12MENU_CMD_FRAME_UPSIDE_DOWN = 13 MENU_CMD_PROFILE4 = 14MENU_CMD_PROFILE5 = 15MENU_CMD_AUTO_PID = 16MENU_CMD_LOOK_DOWN = 17MENU_CMD_HOME_POSITION = 18MENU_CMD_RC_BIND = 19MENU_CMD_CALIB_GYRO_TEMP = 20 MENU_CMD_CALIB_ACC_TEMP = 21MENU_CMD_BUTTON_PRESS = 22MENU_CMD_RUN_SCRIPT1 = 23MENU_CMD_RUN_SCRIPT2 = 24MENU_CMD_RUN_SCRIPT3 = 25MENU_CMD_RUN_SCRIPT4 = 26MENU_CMD_RUN_SCRIPT5 = 27MENU_CMD_CALIB_MAG = 33MENU_CMD_LEVEL_ROLL_PITCH = 34 MENU_CMD_CENTER_YAW = 35MENU_CMD_UNTWIST_CABLES = 36MENU_CMD_SET_ANGLE_NO_SAVE = 37 MENU_HOME_POSITION_SHORTEST = 38 MENU_CENTER_YAW_SHORTEST = 39 MENU_ROTATE_YAW_180 = 40MENU_ROTATE_YAW_180_FRAME_REL = 41 MENU_SWITCH_YAW_180_FRAME_REL = 42 MENU_SWITCH_POS_ROLL_90 = 43MENU_START_TIMELAPSE = 44MENU_CALIB_MOMENTUM = 45MENU_LEVEL_ROLL = 46MENU_LOAD_PROFILE_SET1 = 48MENU_LOAD_PROFILE_SET2 = 49MENU_LOAD_PROFILE_SET3 = 50MENU_LOAD_PROFILE_SET4 = 51MENU_LOAD_PROFILE_SET5 = 52MENU_LOAD_PROFILE_SET_BACKUP = 53 MENU_INVERT_RC_ROLL = 54MENU_INVERT_RC_PITCH = 55MENU_INVERT_RC_YAW = 56MENU_SNAP_TO_FIXED_POSITION = 57 MENU_CAMERA_REC_PHOTO_EVENT = 58 MENU_CAMERA_PHOTO_EVENT = 59 MENU_MOTORS_SAFE_STOP = 60 MENU_CALIB_ACC_AUTO = 61Appendix 3: RC signal source namesHardware inputs for PWM format:RC_ROLL_PWMRC_PITCH_PWMRC_YAW_PWMFC_ROLL_PWMFC_PITCH_PWMRC input should be enabled (i.e. assigned to control of any axis or CMD channel in the RC settings).Analog inputs (joystick connection):ADC1ADC2ADC3Sum-PPM or serial protocols (Spektrum, s-bus):RC_VIRT_CH_1RC_VIRT_CH_2..RC_VIRT_CH_31Desired serial protocol should be selected in the RC settings;Channels 20..31 have special meaning: they are linked to the sin, cos of the angles of motors.Serial API virtual channels (can be set by the external devices or mobile applications connected by SBGC Serial API protocol):API_VIRT_CH_1API_VIRT_CH_2..API_VIRT_CH_31Example 1: Shooting 3-row spherical panorama with increment of 60 degrees in 20 seconds, AUX1 controls the shutter.# Setup a high speed for a quick completion of the panoramaCONFIG SPEED_R(200) SPEED_P(200) SPEED_Y(200) ACC_LIMIT_R(500) ACC_LIMIT_P(1000) ACC_LIMIT_Y(500) # Reset the origin of the YAW: Start recording with the current azimuthR# Turn off the shutter pinT 16(0)# Make 1st shot in the zenith position: raise the camera verticallyA RA(0) PA(-90) YA(0)# Make a shotT 16(1) TIMEOUT(0.100)# Tilt 45 degrees up to make the 1st rowA RA(0) PA(-45) YA(0)T 16(1) TIMEOUT(0.100)# Panning with increment of 60 degrees clockwiseA YA(60)T 16(1) TIMEOUT(0.100)A YA(120)T 16(1) TIMEOUT(0.100)A YA(180)T 16(1) TIMEOUT(0.100)A YA(240)T 16(1) TIMEOUT(0.100)A YA(300)T 16(1) TIMEOUT(0.100)# Camera is tilted 0 degrees to make 2nd rowA RA(0) PA(0) YA(0)T 16(1) TIMEOUT(0.100)# Panning with increment of 60 degrees counterclockwise (avoid double-twisting of the wires)A YA(-60)T 16(1) TIMEOUT(0.100)A YA(-120)T 16(1) TIMEOUT(0.100)A YA(-180)T 16(1) TIMEOUT(0.100)A YA(-240)T 16(1) TIMEOUT(0.100)A YA(-300)T 16(1) TIMEOUT(0.100)# Tilt 45 degrees down to make the 3rd rowA RA(0) PA(45) YA(0)T 16(1) TIMEOUT(0.100)# Panning with increment of 60 degrees clockwiseA YA(60)T 16(1) TIMEOUT(0.100)A YA(120)T 16(1) TIMEOUT(0.100)A YA(180)T 16(1) TIMEOUT(0.100)A YA(240)T 16(1) TIMEOUT(0.100)A YA(300)T 16(1) TIMEOUT(0.100)# Shoot in the nadir positionA YA(0) PA(90)T 16(1) TIMEOUT(0.100)# Returns the camera to its original position (untwist wires) A RA(0) PA(0)I YA(-360)### End of program ###Example 2: Pan at 5 deg/sec by 90 degrees. AUX1 operates recording # Reset the origin of the YAW: Start recording with the current azimuthR# Tilt the camera 30 degrees down and level itA RA(0) PA(30) YA(0)# Start recordingT 16(1)# Writing freeze for 3 seconds.D TIMEOUT(3)# Setup low acceleration for smooth start and stop of the motionCONFIG ACC_LIMIT_Y(5)# Panning with a speed of 5 degree/sec. clockwiseS YS(5)# Wait until turned by 90 degrees.W YA(90)# Stop panning (de-acceleration starts here)S YS(0)# Wait until de-acceleration is finishedW YS(0)# Writing freeze for 3 seconds.D TIMEOUT(3)# Stop recordingT 16(0)### End of program ###Example 3: Time-lapse shooting with minimized gyroscope drift# Let system to know that the frame is still, to compensate a drift of gyroscope;SET_ADJ_VAR NAME(FRAME_HEADING_ANGLE) VALUE(0)# Set the 'gyro trust' parameter low enough to better compensate drift of gyroscopeSET_ADJ_VAR NAME(GYRO_TRUST) VALUE(60)# (Optional) move camera to the desired initial position. Skip this command to start from the current position#ANGLE PA(0) RA(0)# Pan left with the speed 0.1 degrees/sec and tilt up with the speed half slower.SPEED YS(0.1) PS(-0.05)# Wait 10 minutesDELAY TIMEOUT(600)。
4.2inch e-Paper Module 用户手册说明书
1产品概述●本品是4.2英寸电子墨水屏模块,分辨率为400x300,带有内部控制器,使用SPI 接口通信。
●具有耗低、视角宽、阳光直射下仍可清晰显示等优点,常用于货架标签、工业仪表等显示应用。
特点● 无需背光,断电可长时间保持最后一屏的显示内容 ● 功耗非常低,基本只在刷新时耗电● SPI 控制接口,可接入Raspberry /Arduino/Nucleo 等主控板 ●提供完善的配套资料手册(Raspberry/Arduino/STM32等示例程序)产品参数工作电压: 3.3V通信接口:3-wire SPI、4-wire SPI外形尺寸:90.1mm × 77.0mm × 1.18mm显示尺寸:84.8mm × 63.6mm点距:0.212 × 0.212分辨率:400 × 300显示颜色:黑、白灰度等级: 2刷新功耗:26.4mW(typ.)待机功耗:<0.017mW可视角度:>170°接口说明VCC: 3.3VGND:GNDDIN:SPI通信MOSI引脚CLK:SPI通信SCK引脚CS:SPI片选引脚(低电平有效)DC:数据/命令控制引脚(高电平表示数据,低电平表示命令)RST:外部复位引脚(低电平复位)BUSY:忙状态输出引脚(低电平表示忙)23工作原理 器件介绍本产品使用的电子纸采用“微胶囊电泳显示”技术进行图像显示,其基本原理是悬浮在液体中的带电纳米粒子受到电场作用而产生迁移。
电子纸显示屏是靠反射环境光来显示图案的,不需要背光,即使是在阳光底下,电子纸显示屏依然清晰可视,可视角度几乎达到了180°。
因此,电子纸显示屏非常适合阅读。
通信协议CS 用于从机片选。
仅当CS 为低电平时,模块才会工作。
DC 用于模块的数据/命令控制。
当DC 为低电平时,接收到的数据会被当做指令执行。
SCLK 用于SPI 通信时钟。
Literate Programming 教程说明书
Literate Programming using nowebTerry TherneauOctober11,20191IntroductionLet us change or traditional attitude to the construction of pro-grams.Instead of imagining that our main task is to instruct acomputer what to do,let us concentrate rather on explaining to hu-mans what we want the computer to do.(Donald E.Knuth,1984).This is the purpose of literate programming(LP for short).It reverses the ususal notion of writing a computer program with a few included comments,to one of writing a document with some embedded code.The primary organization of the document can then revolve around explaining the algorithm and logic of the code.Many different tools have been created for literate programming,and most have roots in the WEB system created by D.Knuth[2].Some of these have been language specific,e.g.CWEB or PascalWeb;this article focuses on Norman Ramsey’s noweb,an simple LP tool that is language agnostic[3,1].Most R users will already be familiar with the basic structure of a noweb document,since the noweb system was the inspiration or Sweave.2Why use LP for SDocumentation of code is often an afterthought,particularly in a high level language like S.Indeed,I have one colleague who proclaims his work to be “self-documenting code”and eschews comment lines.The counter argument is proven any time we look at someone else’s code(what are they doing?),and in fact by looking at any of our own code after a lapse of time.When we write code the thought process is from an overall structure to algorithm to R function to code;the result is clear and simple as long as that overall structure remains in our thought,but reconstructing that milleau is not easy given the code alone. For a larger project like a package,documentation is even more relevant.When I make a change to the survival package I ususallyfind that the revision is2/3 increased commentary and only1/3modified code,and a major portion of the time was spent puzzling out details that once were obvious.My use of LP methods was motivated by the coxme package.This is the most mathematically challenging part of the surival suite,and due to the need1to use sparse matrix methods it is algorithmically complex as well.It was one of the better programming decisions I’ve made.The old adage“more haste,less speed”holds for R code in general,but for packages and complex algorithms in particular.Many of you will have had the experience of puzzling over a coding or mathematics issue,thenfinally going to a colleage for advice.Then,while explaining the problem to them a solution suddenly becomes clear.The act of explaining was the key.In the same way, writing down and organizing the program logic within a document will get one to the endpoint of a working and reliable program faster.The literate programming literature contains more and better stated argu-ments for the benefit of this approach.3CodingLike an Sweavefile,the nowebfile consists of interleaved text and code chunks, the format is nearly identical.Here is thefirst section of the coxme code(after the document’s header and and an introduction).\section{Main program}The[[coxme]]code starts with a fairly standard argument list.<<coxme>>=coxme<-function(formula,data,weights,subset,na.action,init,control,ties=c("efron","breslow"),varlist,vfixed,vinit,sparse=c(50,.02),x=FALSE,y=TRUE,refine.n=0,random,fixed,variance,...){time0<-proc.time()#debugging lineties<-match.arg(ties)Call<-match.call()<<process-standard-arguments>><<decompose-formula>><<build-control-structures>><<call-computation-routine>><<finish-up>>}The arguments to the function are described below,omitting those that are identical to the\Verb!coxph!function.\begin{description}\item...The typeset code looks like this:2coxme =coxme<-function(formula,data,weights,subset,na.action,init,control,ties=c("efron","breslow"),varlist,vfixed,vinit,sparse=c(50,.02),x=FALSE,y=TRUE,refine.n=0,random,fixed,variance,...){time0<-proc.time()#debugging lineties<-match.arg(ties)Call<-match.call()process-standard-argumentsdecompose-formulabuild-control-structurescall-computation-routinefinish-up}In thefinal pdf document each of the chunks is hyperlinked to any prior or later instances of that chunk name.The structure of a noweb document is very similar to Sweave.The basic rules are1.Code sections begin with the name of the chunk surrounded by anglebrackets:<<chunk-name>>=;text chunks begin with an ampersand@.The primary difference with Sweave is that the name is required—it is the key to organizing the code—whereas in Sweave it is optional and usually omitted.There are no options within the brackets.2.Code chunks can refer to other chunks by including their names in anglebrackets without the trailing=sign.These chunks can refer to others, which refer to others,etc.In the created code the indentation of a ref-erence is obeyed.For instance in the above example the reference to “<<finish-up>>”is indented four spaces;when the definition offinish-up is plugged in that portion as a whole will be moved over4spaces.When the<<finish-up>>chunk is defined later in the document it starts at the left margin.As an author what this means is that you don’t have to remember the indentation from several pages ago,and the standard emacs indentation rules for R code work in each chunk de-novo.3.Code chunks can be in any order.4.The construct[[x<-3]]will cause the text in the interior of the bracketsto be set in the same font as a code chunk.5.Include\usepackage{noweb}in the latex document.It in turn makes useof the fancyvrb and hyperref packages.36.One can use either.Rnw or.nw as the suffix on source code.If thefirst isused then emacs will automatically set the default code mode to S,but is not as willing to recognize C code chunks.If the.nw suffix is used and you have a proper noweb mode installed1,the emacs menu bar(noweb:modes) can be used to set the default mode for the entirefile or for a chunk.The ability to refer to a chunk of code but then to defer its definition until later is an important feature.As in writing a textbook,it allows the author to concentrate on presenting the material in idea order rather than code order.To create the tex document,use the R command noweave(file)where“file”is the name of the.Rnw source.It is necessary to have a copy of noweb.sty available before running the latex or pdflatex command,a copy can be found in the inst directory of the distribution.Optional arguments to noweave areout The name of the outputfile.The default is the name of the inputfile,with thefile extension replaced by“.tex”.indent The number of spaces to indent code from the left margin.The default value is1.To extract a code chunk use the notangle command in R.Arguments are file the name of the.Rnw sourcefile.target the name of the chunk to extract.By default,notangle will extract the chunk named“*”,which is usually a dummy at the beginning of thefile that names all the top level chunks.If this is not found thefirst named chunk is extracted.During extraction any included chunks are pulled in and properly indented.out The name of the outputfile.By default this will be the inputfilename with thefile extension replaced by“.R”.For Unix users the stand alone noweb package is an alternative route.I was not able tofind a simple installation process for MacIntosh,and no version of the package at all for Windows.For R users the package option is simpler, although the standalone package has a longer list of options.Many of these, however,are concerned with creating cross-references in the printed text,which is mostly obviated by the hyperlinks.The noweave program will create a texfile with the exact same number of lines as the input,which is a help when tracking back any latex error messages —almost.The R version fails at this if the@that ends a code chunk has other text after the ampersand on the same line.Most coders don’t do this so it is rarely an issue.1The phrase proper noweb mode requires some explanation.The classic nw mode for emacs has not been updated for years,and does not work properly in emacs22or higher.However, in versions2and earlier of ESS Rnw mode was built on top of nw mode,and ESS included a noweb.elfile that was updated to work with later emacs versions.If you are using ESS2.15, say,then noweb mode worksfine.The newer ESS version12created Rnw mode from scratch, does not include a nowebfile,and emacs reverts to the old,non-working nw code.44Incorporation into RIn my own packages,noweb sourcefiles are placed in a noweb directory.Myown style,purely personal,is to have source codefiles that are fairly small,2to10pages,because Ifind them easier to edit.I then include a Makefile:below isan example for a project with one C program and several R functions.makefile =PARTS=main.Rnw\basic.Rnw\build.Rnw\formula.Rnw\varfun.Rnw varfun2.Rnw\fit.Rnw\ranef.Rnw\lmekin.Rnw\bdsmatrix.Rnwall:fun docfun:../R/all.R../src/bds.cdoc:../inst/doc/sourcecode.pdfR=R--vanilla--slave../R/all.R:all.nwecho"require(noweb);notangle(’all.nw’)">$(R)echo"#Automatically created from all.nw by noweb">tempcat temp all.R>$@../src/bds.c:all.nwecho"/*Automatically created from all.nw by noweb*/">tempecho"require(noweb):notangle(’all.nw’,target=’bds’,out=’bds.c’)">$(R)$cat temp bds.c>$@../inst/doc/sourcecode.pdf:all.nwecho"require(noweb);noweave(’all.nw’)">$(R)texi2dvi--pdf all.texmv all.pdf$@all.nw:$(PARTS)cat($PARTS)>all.nwclean:-rm all.nw all.log all.aux all.toc all.tex all.pdf-rm temp all.R bds.cThefirstfile“main”contains the definition of<<*>>=early on<<*>>=5<<bdsmatrix>><<ghol>><<print.bdsmatrix>>...listing the top level chuncks defined in each of my sub-files,which in turn contain all the R function definitions.For a more sophisticated Makefile that creates each function as a separate.Rfile look at the source code for the coxme package on Rforge.One can add a configure script to the top level directory of the package to cause this Makefile to be run automatically when the package is built.See the source code for the coxme library for an example which had input from several CRAN gurus.I found out that it is very hard to write a Makefile that works across all the platforms that R runs on,and this one is not yet perfected for that task—though it does work on the Rforge servers.When submitting to CRAN my current strategy is to run make all locally to create the documentation and functions from the nowebfiles,and not include a configurefile.I then do a standard submission process:R CMD build to make the tar.gzfile for submission,R CMD check to check it thoroughly,and then submit the tarfile. 5DocumentationThis document is written in noweb,and found in the vignettes directory of my source ing a nowebfile as a vignette is very unusual—this may be the only case that ever arises—since the goal of noweb is to document source code and the goal of vignettes is to document usage of the function.We made use of the vignetteEngines facility available in R version3in order to use noweb instead of Sweave as the default engine for the document.The noweb function itself is written(not surprisingly)in noweb,and the pdf form of the code can be found in the inst/doc directory.References[1]Johnson,Andrew L.and Johnson,Brad C.(1997).Literate Programmingusing noweb,Linux Journal,42:64–69.[2]Donald Knuth(1984).Literate Programming.The Computer Journal(British Programming Society),27(2):97–111.[3]Norman Ramsay(1994).Literate programming simplified.IEEE Software,11(5):97–105.6。
兄弟连区块链技术培训Fabric 1.0源代码分析(34) Peer #peer chaincode命令及子命令实现
兄弟连区块链技术培训Fabric 1.0源代码分析(34) Peer #peer cha incode命令及子命令实现# Fabric 1.0源代码笔记之 Peer #peer chaincode命令及子命令实现## 1、peer chaincode install子命令实现(安装链码)### 1.0、peer chaincode install子命令概述peer chaincode install,将链码的源码和环境封装为一个链码安装打包文件,并传输到背书节点。
peer chaincode install支持如下两种方式:* 指定代码方式,peer chaincode install -n <链码名称> -v <链码版本> -p <链码路径>* 基于链码打包文件方式,peer chaincode install <链码打包文件>### 1.1、初始化Endorser客户端```gocf, err = InitCmdFactory(true, false)//代码在peer/chaincode/install.go```cf, err = InitCmdFactory(true, false)代码如下:```gofunc InitCmdFactory(isEndorserRequired, isOrdererRequired bool) (*Chainc odeCmdFactory, error) {var err errorvar endorserClient pb.EndorserClientif isEndorserRequired {//获取Endorser客户端endorserClient, err = common.GetEndorserClientFnc() //func GetEn dorserClient() (pb.EndorserClient, error)}//获取签名signer, err := common.GetDefaultSignerFnc()var broadcastClient common.BroadcastClientif isOrdererRequired {//此处未用到,暂略}//构造ChaincodeCmdFactoryreturn &ChaincodeCmdFactory{EndorserClient: endorserClient,Signer: signer,BroadcastClient: broadcastClient,}, nil}//代码在peer/chaincode/common.go```### 1.2、构造ChaincodeDeploymentSpec消息(链码信息及链码文件打包)```goif ccpackfile == "" { //指定代码方式,重新构造构造ChaincodeDeploymentSpec 消息ccpackmsg, err = genChaincodeDeploymentSpec(cmd, chaincodeName, chai ncodeVersion)} else { //基于链码打包文件方式,直接读取ChaincodeDeploymentSpec消息var cds *pb.ChaincodeDeploymentSpecccpackmsg, cds, err = getPackageFromFile(ccpackfile)}//代码在peer/chaincode/install.go```ccpackmsg, err = genChaincodeDeploymentSpec(cmd, chaincodeName, chaincod eVersion)代码如下:```gofunc genChaincodeDeploymentSpec(cmd *mand, chaincodeName, chain codeVersion string) (*pb.ChaincodeDeploymentSpec, error) {//已经存在,直接报错if existed, _ := ccprovider.ChaincodePackageExists(chaincodeName, ch aincodeVersion); existed {return nil, fmt.Errorf("chaincode %s:%s already exists", chainco deName, chaincodeVersion)}spec, err := getChaincodeSpec(cmd)cds, err := getChaincodeDeploymentSpec(spec, true)return cds, nil}//代码在peer/chaincode/install.go```spec, err := getChaincodeSpec(cmd)代码如下:```gofunc getChaincodeSpec(cmd *mand) (*pb.ChaincodeSpec, error) { spec := &pb.ChaincodeSpec{}err := checkChaincodeCmdParams(cmd) //检查参数合法性input := &pb.ChaincodeInput{}//flags.StringVarP(&chaincodeCtorJSON, "ctor", "c", "{}",ctor为链码具体执行参数信息,默认为{}err := json.Unmarshal([]byte(chaincodeCtorJSON), &input)//flags.StringVarP(&chaincodeLang, "lang", "l", "golang",lang为链码的编写语言,默认为golangchaincodeLang = strings.ToUpper(chaincodeLang)spec = &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value[chaincod eLang]),ChaincodeId: &pb.ChaincodeID{Path: chaincodePath, Name: chaincod eName, Version: chaincodeVersion},Input: input,}return spec, nil}//代码在peer/chaincode/common.go```cds, err := getChaincodeDeploymentSpec(spec, true)代码如下:```gofunc getChaincodeDeploymentSpec(spec *pb.ChaincodeSpec, crtPkg bool) (*p b.ChaincodeDeploymentSpec, error) {var codePackageBytes []byteif chaincode.IsDevMode() == false && crtPkg {var err errorerr = checkSpec(spec) //检查spec合法性codePackageBytes, err = container.GetChaincodePackageBytes(spe c) //打包链码文件及依赖文件}//构造ChaincodeDeploymentSpecchaincodeDeploymentSpec := &pb.ChaincodeDeploymentSpec{ChaincodeSpec: spec, CodePackage: codePackageBytes}return chaincodeDeploymentSpec, nil//代码在peer/chaincode/common.go```### 1.3、创建lscc Proposal并签名```gocreator, err := cf.Signer.Serialize() //获取签名者//按ChaincodeDeploymentSpec构造Proposal,即链码ChaincodeDeploymentSpec消息作为参数传递给lscc系统链码并调用//调用createProposalFromCDS(chainID, cds, creator, policy, escc, vscc, " deploy")prop, _, err := utils.CreateInstallProposalFromCDS(msg, creator)var signedProp *pb.SignedProposalsignedProp, err = utils.GetSignedProposal(prop, cf.Signer) //签名提案//代码在peer/chaincode/install.go```createProposalFromCDS(chainID, cds, creator, policy, escc, vscc, "deploy ")代码如下:```gofunc createProposalFromCDS(chainID string, msg proto.Message, creator [] byte, policy []byte, escc []byte, vscc []byte, propType string) (*peer.P roposal, string, error) {var ccinp *peer.ChaincodeInputvar b []bytevar err errorb, err = proto.Marshal(msg)switch propType {case "deploy":fallthroughcase "upgrade":cds, ok := msg.(*peer.ChaincodeDeploymentSpec)ccinp = &peer.ChaincodeInput{Args: [][]byte{[]byte(propType), [] byte(chainID), b, policy, escc, vscc}}case "install":ccinp = &peer.ChaincodeInput{Args: [][]byte{[]byte(propType), b}}}lsccSpec := &peer.ChaincodeInvocationSpec{ //构造lscc ChaincodeInvoc ationSpecChaincodeSpec: &peer.ChaincodeSpec{Type: peer.ChaincodeSpec_GOLANG,ChaincodeId: &peer.ChaincodeID{Name: "lscc"},Input: ccinp}}return CreateProposalFromCIS(common.HeaderType_ENDORSER_TRANSACTION, chainID, lsccSpec, creator)}//代码在protos/utils/proputils.go```### 1.4、提交并处理Proposal```goproposalResponse, err := cf.EndorserClient.ProcessProposal(context.Backg round(), signedProp)//代码在peer/chaincode/install.go```## 2、peer chaincode instantiate子命令实现(实例化链码)### 2.0、peer chaincode instantiate概述peer chaincode instantiate命令通过构造生命周期管理系统链码(LSCC)的交易,将安装过的链码在指定通道上进行实例化调用。
simplegraph包用户指南说明书
Package‘simplegraph’August31,2023Title Simple Graph Data Types and Basic AlgorithmsVersion1.0.1Author Gabor CsardiMaintainer Gabor Csardi<**********************>Description Simple classic graph algorithms for simple graph classes.Graphs may possess vertex and edge attributes.'simplegraph'hasno dependencies and it is written entirely in R,so it is easy toinstall.License MIT+file LICENSEURL https:///gaborcsardi/simplegraphBugReports https:///gaborcsardi/simplegraph/issuesSuggests testthatImports methods,utilsRoxygenNote7.2.3Encoding UTF-8NeedsCompilation noRepository CRANDate/Publication2023-08-3107:40:02UTCR topics documented:adjacent_vertices (2)bfs (3)degree (4)edges (4)graph (5)incident_edges (7)is_loopy (8)is_multigraph (8)is_simple (9)12adjacent_vertices is_weighted (10)order (11)predecessors (11)remove_loops (12)remove_multiple (13)sanitize (13)simplegraph (14)simplify (14)size (15)strength (15)topological_sort (16)transpose (17)vertex_ids (18)vertices (19)Index21 adjacent_vertices Adjacent vertices for all vertices in a graphDescriptionA vertex is adjacent is it is either a successor,or a predecessor.Usageadjacent_vertices(graph)Argumentsgraph The graph.ValueA named list of character vectors,the adjacent vertices for each vertex.See AlsoOther simple queries:edges(),order(),vertices()ExamplesG<-graph(list(A=c("B","C"),B="C",C="A"))adjacent_vertices(G)bfs3 bfs Breadth-first search of a graphDescriptionBreadth-first search of a graphUsagebfs(graph,from=vertex_ids(graph))Argumentsgraph Input graph.from Character vector,which vertices to start the search from.By default all vertices are attempted.ValueCharacter vector of the named of the visited vertices,in the order of their visit.Examplesfuncs<-graph(list(drop_internal=character(0),get_deps=c("get_description","parse_deps","%||%","drop_internal"),get_description="pkg_from_filename",parse_deps="str_trim",cran_file=c("get_pkg_type","r_minor_version","cran_file"),download_urls=c("split_pkg_names_versions","cran_file"),filename_from_url=character(0),get_pkg_type=character(0),pkg_download=c("dir_exists","download_urls","filename_from_url","try_download"),r_minor_version=character(0),try_download=character(0),drop_missing_deps=character(0),install_order=character(0),restore=c("pkg_download","drop_missing_deps","install_order","get_deps"),snap=character(0),%||% =character(0),data_frame=character(0),dir_exists=character(0),pkg_from_filename=character(0),split_pkg_names_versions="data_frame",str_trim=character(0)))bfs(funcs)4edges degree Degree of verticesDescriptionDegree of verticesUsagedegree(graph,mode=c("out","in","total","all"))Argumentsgraph Input graph.mode Whether to calculate out-degree,in-degree,or the total degree.ValueNamed numeric vector of degrees.ExamplesG<-graph(list(A=c("B","C"),B="C",C="A"))degree(G,mode="out")degree(G,mode="in")degree(G,mode="total")edges Edges of a graphDescriptionEdges of a graphUsageedges(graph)Argumentsgraph The graphValueData frame of edge data and metadata.The tail and head vertices are in thefist two columns.The rest of the columns are metadata.See AlsoOther simple queries:adjacent_vertices(),order(),vertices()Examplesbridges<-graph(list("Altstadt-Loebenicht"=c("Kneiphof","Kneiphof","Lomse"),"Kneiphof"=c("Altstadt-Loebenicht","Altstadt-Loebenicht","Vorstadt-Haberberg","Vorstadt-Haberberg","Lomse"),"Vorstadt-Haberberg"=c("Kneiphof","Kneiphof","Lomse"),"Lomse"=c("Altstadt-Loebenicht","Kneiphof","Vorstadt-Haberberg")))edges(bridges)graph Create a graphDescriptionGraphs can be specified as adjacency lists or(two)data frames.Usagegraph(x,...)Argumentsx A data frame,or a named list of character vectors.See details below....Additional arguments,see details below.DetailsIf thefirst argument is a data frame,then it is interpreted as vertex data,and a second data frame must be supplied as edge data.Thefirst column of the vertex data must contain(character)vertex ids.Thefirst two columns of the edge data frame must contain the directed edges of the graph, in the order of tail and head,as characters referring to the nodes ids.Other columns are kept as metadata.If thefirst argument is not a data frame,but a list,then it is interpreted as an adjacency list.It must be named,and the names will be used as vertex ids.Each list element must be a character vector containing the successors of each vertex.ValueA graph object.Examplesfuncs<-graph(list(drop_internal=character(0),get_deps=c("get_description","parse_deps","%||%","drop_internal"),get_description="pkg_from_filename",parse_deps="str_trim",cran_file=c("get_pkg_type","r_minor_version","cran_file"),download_urls=c("split_pkg_names_versions","cran_file"),filename_from_url=character(0),get_pkg_type=character(0),pkg_download=c("dir_exists","download_urls","filename_from_url","try_download"),r_minor_version=character(0),try_download=character(0),drop_missing_deps=character(0),install_order=character(0),restore=c("pkg_download","drop_missing_deps","install_order","get_deps"),snap=character(0),%||% =character(0),data_frame=character(0),dir_exists=character(0),pkg_from_filename=character(0),split_pkg_names_versions="data_frame",str_trim=character(0)))funcsvertices<-data.frame(stringsAsFactors=FALSE,name=c("Tom Hanks","Cate Blanchett","Matt Damon","Kate Winslet","Saving Private Ryan","Contagion","The Talented Mr.Ripley"),what=c("actor","actor","actor","actor","movie","movie","movie"),born=c("1956-07-09","1966-05-26","1970-10-08","1975-10-05",NA,NA,NA),incident_edges7 gender=c("M","F","M","F",NA,NA,NA),year=c(NA,NA,NA,NA,1998,2011,1999))edges<-data.frame(stringsAsFactors=FALSE,actor=c("Tom Hanks","Cate Blanchett","Matt Damon","Matt Damon","Kate Winslet"),movie=c("Saving Private Ryan","The Talented Mr.Ripley","Saving Private Ryan","The Talented Mr.Ripley","Contagion"))actors<-graph(vertices,edges)actorsincident_edges Incident edgesDescriptionIncident edgesUsageincident_edges(graph,mode=c("out","in","all","total"))Argumentsgraph Input graph.mode Whether to use out edges,in edges or all edges.ValueA list of data frames,each a set of edges.ExamplesG<-graph(list(A=c("B","C"),B="C",C="A"))incident_edges(G,mode="out")incident_edges(G,mode="in")incident_edges(G,mode="all")8is_multigraphis_loopy Is this a loopy graph?DescriptionA loopy graph has at least one loop edge:an edge from a vertex to itself.Usageis_loopy(graph)Argumentsgraph The input graph.ValueLogical scalar.See AlsoOther multigraphs:is_multigraph(),is_simple(),remove_loops(),remove_multiple(),simplify()ExamplesG<-graph(list(A=c("A","B","B"),B=c("A","C"),C="A"))is_loopy(G)G2<-simplify(G)is_loopy(G2)is_multigraph Is this a multigraph?DescriptionA multigraph has at least one pair or multiple edges,edges connecting the same(ordered)pair ofvertices.Usageis_multigraph(graph)Argumentsgraph Input graph.is_simple9ValueLogical scalar.See AlsoOther multigraphs:is_loopy(),is_simple(),remove_loops(),remove_multiple(),simplify()ExamplesG<-graph(list(A=c("A","B","B"),B=c("A","C"),C="A"))is_multigraph(G)G2<-simplify(G)is_multigraph(G2)is_simple Is this a simple graph?DescriptionA simple graph contains no loop and multiple edges.Usageis_simple(graph)Argumentsgraph The input graph.ValueLogical scalar.See AlsoOther multigraphs:is_loopy(),is_multigraph(),remove_loops(),remove_multiple(),simplify() ExamplesG<-graph(list(A=c("A","B","B"),B=c("A","C"),C="A"))is_simple(G)G2<-simplify(G)is_simple(G2)10is_weighted is_weighted Is the graph weighted?DescriptionIs the graph weighted?Usageis_weighted(graph)Argumentsgraph The graph.ExamplesG<-graph(data.frame(stringsAsFactors=FALSE,id=c("a","b","c","d")),data.frame(stringsAsFactors=FALSE,from=c("a","a","b","b","c"),to=c("b","d","d","c","a"),weight=c(1,2,1,3,2)))is_weighted(G)G2<-graph(data.frame(stringsAsFactors=FALSE,id=c("a","b","c","d")),data.frame(stringsAsFactors=FALSE,from=c("a","a","b","b","c"),to=c("b","d","d","c","a")))is_weighted(G2)order11 order Order of a graphDescriptionThe order of the graph is the number of vertices.Usageorder(graph)Argumentsgraph The graph.ValueNumeric scalar,the number of vertices.See AlsoOther simple queries:adjacent_vertices(),edges(),vertices()ExamplesG<-graph(list(A=c("B","C"),B="C",C="A"))order(G)predecessors Predecessors and successorsDescriptionPredecessors and successorsUsagepredecessors(graph)successors(graph)Argumentsgraph Input graph12remove_loops ValueNamed list of character vectors,the predecessors or the successors of each vertex.ExamplesG<-graph(list(A=c("B","C"),B="C",C="A"))predecessors(G)successors(G)remove_loops Remove loop edges from a graphDescriptionRemove loop edges from a graphUsageremove_loops(graph)Argumentsgraph Input graphValueGraph,with loop edges removed.See AlsoOther multigraphs:is_loopy(),is_multigraph(),is_simple(),remove_multiple(),simplify() ExamplesG<-graph(list(A=c("A","B","B"),B=c("A","C"),C="A"))is_loopy(G)is_loopy(remove_loops(G))remove_multiple13 remove_multiple Remove multiple edges from a graphDescriptionRemove multiple edges from a graphUsageremove_multiple(graph)Argumentsgraph Input graph.ValueGraph,without the multiple edges.(More precisely,from each set of multiple edges,only one,the first one,is kept.)See AlsoOther multigraphs:is_loopy(),is_multigraph(),is_simple(),remove_loops(),simplify()ExamplesG<-graph(list(A=c("A","B","B"),B=c("A","C"),C="A"))is_multigraph(G)is_multigraph(remove_multiple(G))sanitize Check the validity of a graph data structureDescriptionThis is mainly for internal checks,but occasionally it might be useful externally.Usagesanitize(x,...)Argumentsx Graph....Extra arguments are curently ignored.14simplifyExamplesG<-graph(list(A=c("B","C"),B="C",C="A"))sanitize(G)G<-c(G,list("this is not good"=c(1,2,3)))try(sanitize(G))simplegraph Simple Graph Data Types and Basic AlgorithmsDescriptionSimple classic graph algorithms for simple graph classes.Graphs may possess vertex and edgeattributes.’simplegraph’has no dependencies and it is writting entirely in R,so it is easy to install.See AlsoUseful links:•https:///gaborcsardi/simplegraph•Report bugs at https:///gaborcsardi/simplegraph/issuessimplify Remove multiple and loop edges from a graphDescriptionRemove multiple and loop edges from a graphUsagesimplify(graph)Argumentsgraph Input graph.ValueAnother graph,with the multiple and loop edges removed.See AlsoOther multigraphs:is_loopy(),is_multigraph(),is_simple(),remove_loops(),remove_multiple()size15ExamplesG<-graph(list(A=c("A","B","B"),B=c("A","C"),C="A"))is_simple(G)G2<-simplify(G)is_simple(G2)size The size of the graph is the number of edgesDescriptionThe size of the graph is the number of edgesUsagesize(graph)Argumentsgraph The graph.ValueNumeric scalar,the number of edges.ExamplesG<-graph(list(A=c("B","C"),B="C",C="A"))size(G)strength Vertex strength:sum of weights of incident edgesDescriptionThis is also called weighed degree.Usagestrength(graph,mode=c("out","in","total","all"))Argumentsgraph Input graph.mode Whether to consider incoming(in),outgoing(out)or all(total)edges.16topological_sortDetailsFor non-weighted graphs,the degree is returned as a fallback.ValueNamed numeric vector.ExamplesG<-graph(data.frame(stringsAsFactors=FALSE,id=c("a","b","c","d")),data.frame(stringsAsFactors=FALSE,from=c("a","a","b","b","c"),to=c("b","d","d","c","a"),weight=c(1,2,1,3,2)))strength(G)G2<-graph(data.frame(stringsAsFactors=FALSE,id=c("a","b","c","d")),data.frame(stringsAsFactors=FALSE,from=c("a","a","b","b","c"),to=c("b","d","d","c","a")))strength(G2)topological_sort Topological sorting of a graphDescriptionTopological sorting of a graphUsagetopological_sort(graph)Argumentsgraph Input graph.transpose17ValueCharacter vector of vertex ids,in topological order.Examplesfuncs<-graph(list(drop_internal=character(0),get_deps=c("get_description","parse_deps","%||%","drop_internal"),get_description="pkg_from_filename",parse_deps="str_trim",cran_file=c("get_pkg_type","r_minor_version","cran_file"),download_urls=c("split_pkg_names_versions","cran_file"),filename_from_url=character(0),get_pkg_type=character(0),pkg_download=c("dir_exists","download_urls","filename_from_url","try_download"),r_minor_version=character(0),try_download=character(0),drop_missing_deps=character(0),install_order=character(0),restore=c("pkg_download","drop_missing_deps","install_order","get_deps"),snap=character(0),%||% =character(0),data_frame=character(0),dir_exists=character(0),pkg_from_filename=character(0),split_pkg_names_versions="data_frame",str_trim=character(0)))topological_sort(remove_loops(funcs))transpose Transpose a graphDescriptionThe transposed graph have the same vertices,and the same number of edges,but all edge directions are opposite comparated to the original graph.Usagetranspose(graph)Argumentsgraph Input graph18vertex_ids ValueTransposed graph.Examplesfuncs<-graph(list(drop_internal=character(0),get_deps=c("get_description","parse_deps","%||%","drop_internal"),get_description="pkg_from_filename",parse_deps="str_trim",cran_file=c("get_pkg_type","r_minor_version","cran_file"),download_urls=c("split_pkg_names_versions","cran_file"),filename_from_url=character(0),get_pkg_type=character(0),pkg_download=c("dir_exists","download_urls","filename_from_url","try_download"),r_minor_version=character(0),try_download=character(0),drop_missing_deps=character(0),install_order=character(0),restore=c("pkg_download","drop_missing_deps","install_order","get_deps"),snap=character(0),%||% =character(0),data_frame=character(0),dir_exists=character(0),pkg_from_filename=character(0),split_pkg_names_versions="data_frame",str_trim=character(0)))edges(transpose(funcs))vertex_ids Vertex ids of a graphDescriptionVertex ids of a graphUsagevertex_ids(graph)Argumentsgraph The graph.ValueCharacter vector of vertex ids.ExamplesG<-graph(list(A=c("B","C"),B="C",C="A"))vertex_ids(G)vertices Vertices of a graph,with metadataDescriptionVertices of a graph,with metadataUsagevertices(graph)Argumentsgraph The graph.ValueCharacter vector of vertex names.See AlsoOther simple queries:adjacent_vertices(),edges(),order() Examplesbridges<-graph(list("Altstadt-Loebenicht"=c("Kneiphof","Kneiphof","Lomse"),"Kneiphof"=c("Altstadt-Loebenicht","Altstadt-Loebenicht","Vorstadt-Haberberg","Vorstadt-Haberberg","Lomse"),"Vorstadt-Haberberg"=c("Kneiphof","Kneiphof","Lomse"),"Lomse"=c("Altstadt-Loebenicht","Kneiphof","Vorstadt-Haberberg" )))vertices(bridges)Index∗multigraphsis_loopy,8is_multigraph,8is_simple,9remove_loops,12remove_multiple,13simplify,14∗simple queriesadjacent_vertices,2edges,4order,11vertices,19adjacent_vertices,2,5,11,19bfs,3degree,4edges,2,4,11,19graph,5incident_edges,7is_loopy,8,9,12–14is_multigraph,8,8,9,12–14is_simple,8,9,9,12–14is_weighted,10order,2,5,11,19 predecessors,11remove_loops,8,9,12,13,14 remove_multiple,8,9,12,13,14 sanitize,13simplegraph,14simplegraph-package(simplegraph),14 simplify,8,9,12,13,14size,15strength,15successors(predecessors),11topological_sort,16transpose,17vertex_ids,18vertices,2,5,11,1921。
Pedigree函数包用户指南说明书
Package‘pedigree’October14,2022Type PackageTitle Pedigree FunctionsVersion1.4.2Date2022-08-13Depends MatrixImports methods,HaploSim(>=1.8.4),reshapeDescription Pedigree related functions.License GPL(>=2)Author Albart Coster[aut,cre]Maintainer Albart Coster<**********************>NeedsCompilation yesRepository CRANDate/Publication2022-08-1320:50:02UTCR topics documented:pedigree-package (2)add.Inds (2)blup (3)calcG (4)calcInbreeding (4)countGen (5)countOff (6)gblup (6)makeA (8)makeAinv (8)orderPed (9)trimPed (10)Index1112add.Inds pedigree-package Package to deal with pedigree dataDescriptionPackage with functions to analyse and transform pedigree data.A pedigree is a data.frame where thefirst column contains an ID,and the second and third columns contain ID offirst and second parent.Author(s)Albart Coster:<********************>See AlsotrimPed orderPed countGen makeA makeAinv calcInbreeding add.Indsadd.Inds Function to add missing individuals to a pedigreeDescriptionFunction add.Inds()adds missing individuals to a pedigree and returns the complete pedigree as a data.frame with the same headers as the original pedigree.Remeber to check for errors beforehand with function errors.ped.Unknown parents should be coded as NA.Usageadd.Inds(ped)Argumentsped data.frame with three columns:id,id parent1,id parent2Valuedata.frame of three columns with identical header as input.Author(s)Albart Coster,********************See AlsoorderPedblup3ExamplesID<-3:5DAM<-c(1,1,3)SIRE<-c(2,2,4)pedigree<-data.frame(ID,DAM,SIRE)pedigree<-add.Inds(pedigree)blup Function to calculate breeding values using an animal model DescriptionFit an animal model to data,use a given variance ratio(α=σ2eσ2a ).Calculate inverse of the additivegenetic relationship matrix using function makeInv()of this package.Usageblup(formula,ped,alpha,trim=FALSE)Argumentsformula formula of the model,do not include the random effect due to animal(generally ID).ped data.frame with columns corresponding to ID,SIRE,DAM and the columns in the formula.alpha Variance ratio(σ2eσ2a).trim If TRUE,trims the pedigree using the available phenotype data using function trimPed.ValueVector of solutions to the model,including random animal effects.See AlsoSamplePedigree,gblup,makeAinv,blupExamplesexample(gblup)sol<-blup(P~1,ped=ped,alpha=1/h2-1)4calcInbreedingcalcG Function to calculate a relationship matrix from marker data(usuallyallele count data),G matrix.DescriptionFunction to calculate a relationship matrix from marker data.Option to return the inverse of matrix.Inverse calculated using Matrix package.UsagecalcG(M,data=NULL,solve=FALSE)ArgumentsM Matrix of marker genotypes,usually the count of one of the two SNP alleles at each markers(0,1,or2).data Optional logical vector which can tell of which individuals we have phenotypes.solve Logic,if TRUE then function returns the inverse of the relationship matrix. ValueMatrix of class dgeMatrix.See AlsoSamplePedigree,gblup,makeAinv,blupExamplesexample(gblup)G<-calcG(M)Ginv<-calcG(M,solve=TRUE)calcInbreeding Calculates inbreeding coefficients for individuals in a pedigree.DescriptionCalculates inbreeding coefficients of individuals in a pedigree.UsagecalcInbreeding(ped)countGen5 Argumentsped data.frame with three columns:id,id parent1,id parent2ValueLogical.Examplesid<-1:6dam<-c(0,0,1,1,4,4)sire<-c(0,0,2,2,3,5)ped<-data.frame(id,dam,sire)(F<-calcInbreeding(ped))countGen Count generation number for each individual in a pedigree.DescriptionCounts generation number for individuals in a pedigreee.UsagecountGen(ped)Argumentsped data.frame with three columns:id,id parent1,id parent2ValueNumeric vectorExamplesid<-1:5dam<-c(0,0,1,1,4)sire<-c(0,0,2,2,3)ped<-data.frame(id,dam,sire)(gens<-countGen(ped))countOff Function that counts the number of offspring(and following genera-tions for each individual in a pedigree.DescriptionFunction to count the number of offspring for each individual in a pedigree.With loops,offspring of later generations will be counted several times.UsagecountOff(ped)Argumentsped data.frame with three columns:id,id parent1,id parent2ValueNumeric vector with number of offspring for each individual in the pedigree.Author(s)Albart CosterExamplesexample(countGen)countOff(ped)gblup Function to calculate breeding values using an animal model and arelationship matrix calculated from the markers(G matrix) DescriptionFit an animal model to data,use a given variance ratio(α=σ2eσ2a ).Calculate genetic relationshipmatrix using the function calcG of this package.Usagegblup(formula,data,M,lambda)Argumentsformula formula of the model,do not include the random effect due to animal(generallyID).data data.frame with columns corresponding to ID and the columns mentioned inthe formula.M Matrix of marker genotypes,usually the count of one of the two SNP alleles ateach markers(0,1,or2).lambda Variance ratio(σ2e)σ2aValueVector of solutions to the model,including random animal effects.See AlsoSamplePedigree,gblup,makeAinv,blupExamples##Example Code from SampleHaplotypeshList<-HaploSim::SampleHaplotypes(nHaplotypes=20,genDist=1,nDec=3,nLoc=20)##create objectsh<-HaploSim::SampleHaplotype(H0=hList[[1]],H1=hList[[2]],genDist=1,nDec=3)##code from the Example SamplePedigreeID<-1:10pID0<-c(rep(0,5),1,1,3,3,5)pID1<-c(rep(0,4),2,2,2,4,4,6)ped<-data.frame(ID,pID0,pID1)phList<-HaploSim::SamplePedigree(orig=hList,ped=ped)##own codeh2<-0.5ped<-phList$pedhList<-phList$hListqtlList<-HaploSim::ListQTL(hList=hList,frqtl=0.1,sigma2qtl=1)qtl<-tapply(unlist(qtlList),list(rep(names(qtlList),times=unlist(lapply(qtlList,length))), unlist(lapply(qtlList,function(x)seq(1,length(x))))),mean,na.rm=TRUE) qtl<-reshape::melt(qtl)names(qtl)<-c("POS","TRAIT","a")HH<-HaploSim::getAll(hList,translatePos=FALSE)rownames(HH)<-sapply(hList,function(x)x@hID)QQ<-HH[,match(qtl$POS,colnames(HH))]g<-QQped$G<-with(ped,g[match(hID0,rownames(g))]+g[match(hID1,rownames(g))])sigmae<-sqrt(var(ped$G)/h2-var(ped$G))ped$P<-ped$G+rnorm(nrow(ped),0,sigmae)M<-with(ped,HH[match(hID0,rownames(HH)),]+HH[match(hID1,rownames(HH)),])rownames(M)<-ped$ID8makeAinv sol<-gblup(P~1,data=ped[,c( ID , P )],M=M,lambda=1/h2-1)makeA Makes the A matrix for a part of a pedigreeDescriptionMakes the A matrix for a part of a pedigree and stores it in afile called A.txt.UsagemakeA(ped,which)Argumentsped data.frame with three columns:id,id parent1,id parent2which Logical vector specifying between which indiduals additive genetic relationship is required.Goes back through the whole pedigree but only for subset of indi-viduals.ValueLogical.Examplesid<-1:6dam<-c(0,0,1,1,4,4)sire<-c(0,0,2,2,3,5)ped<-data.frame(id,dam,sire)makeA(ped,which=c(rep(FALSE,4),rep(TRUE,2)))A<-read.table("A.txt")if(file.exists("A.txt"))file.remove("A.txt")makeAinv Makes inverted A matrix for a pedigreeDescriptionMakes inverted A matrix for a pedigree and stores it in afile called Ainv.txt.UsagemakeAinv(ped)orderPed9 Argumentsped data.frame with three columns:id,id parent1,id parent2ValueLogical.Examplesid<-1:6dam<-c(0,0,1,1,4,4)sire<-c(0,0,2,2,3,5)ped<-data.frame(id,dam,sire)makeAinv(ped)Ai<-read.table( Ainv.txt )nInd<-nrow(ped)Ainv<-matrix(0,nrow=nInd,ncol=nInd)Ainv[as.matrix(Ai[,1:2])]<-Ai[,3]dd<-diag(Ainv)Ainv<-Ainv+t(Ainv)diag(Ainv)<-ddif(file.exists("Ainv.txt"))file.remove("Ainv.txt")orderPed Orders a pedigreeDescriptionOrders a pedigree so that offspring follow parents.UsageorderPed(ped)Argumentsped data.frame with three columns:id,id parent1,id parent2Valuenumerical vector10trimPedExamplesid<-1:6dam<-c(0,0,1,1,4,4)sire<-c(0,0,2,2,3,5)pedigree<-data.frame(id,dam,sire)(ord<-orderPed(pedigree))pedigree<-pedigree[6:1,](ord<-orderPed(pedigree))pedigree<-pedigree[order(ord),]pwrong<-pedigreepwrong[1,2]<-pwrong[6,1]trimPed Function to trim a pedigree based on available dataDescriptionTrims a pedigree given a vector of data.Branches without data are trimmed off the pedigree. UsagetrimPed(ped,data,ngenback=NULL)Argumentsped data.frame with three columns:id,id parent1,id parent2data TRUE-FALSE vector.Specifies if data for an individual is available.ngenback Number of generations back.Specifies the number of generations to keep before the individuals with data.ValueLogical vector specifying if an individual should stay in the pedigree.Examplesid<-1:5dam<-c(0,0,1,1,4)sire<-c(0,0,2,2,3)data<-c(FALSE,FALSE,TRUE,FALSE,FALSE)ped<-data.frame(id,dam,sire)yn<-trimPed(ped,data)ped<-ped[yn,]Index∗utilitiesadd.Inds,2blup,3calcG,4calcInbreeding,4countGen,5countOff,6gblup,6makeA,8makeAinv,8orderPed,9pedigree-package,2trimPed,10add.Inds,2,2blup,3,3,4,7calcG,4calcInbreeding,2,4countGen,2,5countOff,6gblup,3,4,6,7makeA,2,8makeAinv,2–4,7,8orderPed,2,9pedigree(pedigree-package),2pedigree-package,2SamplePedigree,3,4,7trimPed,2,3,1011。
Peerless-AV 防水可编程遥控器说明书
Peerless-AV® Waterproof ProgrammableRemote Controlof codes and designed to operate all Peerless-AV outdoor displays, Peerless-AV outdoor soundbarsas well as third-party satellite/cable boxes, Blu-ray/DVD Players, VCR’s, and miscellaneos audio andautomation equipment.CONTENTSUniversal Remote Control Button Guide (3)Peerless-AV Outdoor Soundbar Remote Control Button Guide (4)Battery Installation and Replacement (5)Device Table (6)Programming the Remote using Device Codes (6)Programming the Remote by Searching for Codes (7)Manufacturer's Codes (7)Setup Codes foor Peerless-AV Outdoor Soundbar (7)Setup Codes for Cable Box (8)Setup Codes for Satellite Receivers (10)Setup Codes for TV's (11)Setup Codes for VCR & TV/VCD (15)Setup Codes for TV/VCR (18)Setup Codes for DVD, DVR & Blu-ray (19)Setup Codes for DVR (21)Setup Codes for CD, LD, Home Automation, & PVR (21)Setup Codes for Laser Discs (22)Setup Codes for Home Automation (22)Remove the two screws from the battery holder as shown. Pull the battery holder out of the bottom of the remote control and remove the batteries.Insert two new 1.5V AAA batteries into the battery holder as shown. Ensure the positive and negative marks on the batteries are correctly oriented with the markings on the inside of the remove control's battery compartment.Insert the battery holder back into the battery compartment of the remote control. Tighten both battery holder screws, making sure the screws are tightened all the way to maintain a waterproof seal (do not over tighten).Note: The Peerless-AV Waterproof Universal Remote Control is supplied with batteries already installed.If the Red LED light on the remote fails to illuminate when a button is pressed, the batteries may need to be replaced. Follow the directions below to replace the batteries.Device TableProgramming the Remote using Device CodesNOTE:Please refer to Table 1a when in the "PROGRAMMING THE REMOTE USING DEVICE CODES" section. After programming is complete, the Universal Remote Control will be able to control the following types of devices:To have universal control of your devices through the Peerless-AV Programmable Remote, perform the following steps; otherwise skip this section. Fully read and understand the process before attempting to program the remote .If none of the listed codes work with your device, proceed to the "PROGRAMMING THE REMOTE BY SEARCHING FOR CODES" section (page 7).1. Turn on the device that you would like to program into your remote using the power button the the device.2. On the Peerless-AV Universal remote control, press and hold the button that you are trying to program (TV, DVD, CBL, or AUX) and the OK button simultaneously for 2 seconds. The Red LED on the remote will illuminate.3. In the "MANUFACTURER'S CODES" section (page 7), locate the type and brand name of the device you are trying to program into the remote. Once you have located it, enter the first 3-digit code for your device. If the device that you are trying to control turns off, press the Device button that you were trying to program (TV, DVD, CBL, or AUX). The Red LED will blink two times.4. To confirm the code works properly, press the Device button again then press the Power button. The device should turn on; however, if the device did not turn on, please repeat steps 1-3 abovewith the next code for that manufacturer.NOTE:If Peerless-AV Display is unresponsive to commands being sent, press the TV button and send the commands again.Table1a TV Controls the Peerless-AV display DVD Blu-ray, DVD, DVR, VCR, TV/VCR CBL Cable Box, Satellite BoxAUXPeerless-AV Xtreme ™ Outdoor Soundbar CD, LD, Home Automation, PVR DeviceProgramming the Remote by Searching for Codes1. Turn on the device that you would like to program into your remote using the power button thethe device.2. On the Peerless-AV Universal remote control, press and hold the button that you are trying toprogram (TV, DVD, CBL, or AUX) and the OK button simultaneously for 2 seconds. The Red LED on the remote will illuminate.3. Press and release the CH Up button once to start the code search through the list of availablecodes. Each time the CH Up button is pressed, the remote will send an Off command to the device using the next code on the list. Each time the CH Up button is pressed, the Red LED on the remote control will illuminate for verification.4. Continue pressing the CH up button until the device you are trying to control turns off. Thenpress the Device button that you were trying to program (TV, DVD, CBL, or AUX). The Red LED will blink two times.5. To confirm the code will work properly, press the Device button again. Then press the powerbutton. The device should turn on; However, if the device did not turn on, please repeat steps 1-4 above.Manufacturer's CodesPeerless AV Outdoor Soundbar CodesBrand CodesPeerless-AV079CABLE BOX CodesBrand CodesABC107109113117131135144ALLEGRO112ANTRONIX045121ARCHER0451********AT&T207CABLE TENNA121CABLE VIEW121CENTURY132COLOUR VOICE002003COMTRONICS039110CONTEC114DIRECTOR202DIRECTV206GARRARD132GC ELECTRONICS045GEMINI045048GENERAL INSTRUMENT202092099100125126127131135 HAMLIN139142145HITACHI135HYTEX144JASCO132JERROLD202048107109117125126127131135 MAGNAVOX111MEMOREX106MOTOROLA201202MOVIE TIME033144NSC033144OAK006114144PANASONIC123129PHILIPS002003048111132PIONEER204005091093102122PULSAR106RADIOSHACK112RCA129REALISTIC045REGAL145REMBRANDT135RUNCO106CABLE BOX Codes (continued)Brand CodesSAMSUNG005039SCIENTIFIC-ATLANTA204205091096097098113115122 SIGNAL039048SIGNATURE135SL MARX039SPRUCER129STANDARD COMPONENTS086STARCOM048117131STARGATE039048STARSIGHT CABLE SERVICE119STARQUEST048TANDY047TELEVIEW039TEXSCAN086TOCOM101107TOSHIBA106TUSA048TV 86033UNIKA045121132UNITED ARTISTS144UNITED CABLE131UNIVERSAL045121130132136VIDEOWAY037VIEWSTAR033047110111VIDEO TECH036ZENITH038103104106112138200NEW MODEL105SATELLITE RECEIVER CodesBrand CodesAT&T207CHANNEL MASTER155159164CHAPPARAL168170174CHEYENNE174DISH NETWORK192DIRECTV206DARKE069070072DX ANTENNA156158ECHOSPHERE192ECHOSTAR160165171192FUJITSU176182GE152184GENERAL INSTRUMENTS016147149188191195198 HITACHI DBS180185HUGHES SATELLITE DBS163167173185197JERROLD050KENWOOD161LUXOR165MACOM STATE172MAGNAVOX DBS194MEMOREX199NORSTAT177183PANASONIC DBS151PRIMESTAR053PHILIPS194PROSCAN152184RCA DBS152184REALISTIC154196SCIENTIFIC ATLANTA157SIERRA I, II, III174SONY DBS189STARSIGHT197STAR TRAK162STS158169175SUPER GUIDE166TOSHIBA181TOSHIBA DBS148150179UNIDEN178187UNIDEN DBS197VIDEO CHPHER II070ZENITH063069070071072153186TV CodesBrand CodesADMIRAL068119120147149155AIKO185AKAI001006067ALARON139AMARK012020096100AMERICA ACTION190AMPRO121170ANAM008012013107128129AOC001002006012022ARCHER187AUDIOVOX047BAYSONIC190BELCOR183BELL & HOWELL120BRADFORD190BROCKWOOD183BROCKSONIC042044CANDLE001002079106183CAPEHART022CARNIVALE183CARVER188CETRONIC035CINERAL185186CITIZEN0010002034035076079096106CLASSIC035CONCERTO002CONTEC032035CORONADO081096CRAIG035107CROSLEY188CROWN0350********CURTIS MATHES001002076096120155CXC035DAEWOO000002013016033034035040047055074075083096098124142DAYTRON002096DENON189DUMONT183DYNASTY035DYNATECH162EARTHWALK194ELECTROBAND047096133EMERSON002006007023031032035038041042044047096100173ENVISION183FISHER025026FUJITSU193FUNAI007035FUNAI TV/VCR060FUTURETECH035GENERAL ELECTRIC001002031080081082112116117121129147147149155156167GIBRALTER183GOLDSTAR (LG)002003006009010011012019087096098100GRADIENTE183GRUNPY190193HALLMARK002HARLEY DAVIDSON193HARMAN/KARDON188HARVARD190HITACHI002089090094096100119139161 INFINITY109188INKEL130JBL109JCPENNY001002006052076080082096112122133149JENSEN004JVC054056065088092116KEC190KENWOOD001054KLOSS079097KMC100KTV001006023035096100115LODGENET119120LOGIK119120LUXMAN002LXI053068069070099109149MAD057099QUASAR0811********RADIOSHACK002035049096098RCA001002006122123129133139140147148149155156REALISTIC041049051RUNCO119121137166167168171SAMPO001002022SAMSUNG002076078096098100114149SANSEI186SANSUI191SANYO025026030036037103145169SCIMITSU183SCOTCH183SCOTT002007035042096SEARS002007025026030052078096099100145149SELECO160SEMP182SHARP002007048049050051068069070071096100137164165SHOGUN183SIGNATURE006007051066069082100119120 SMIVOX190SONY018024061062125173SOUNDESIGN002007035106SPECTRICON012SSS002035183190STARLITE190SUPREMACY079SYLVANIA001021066074097098105106109110112149SYMPHONIC053TANDY068TATUNG081129162TECHNICS116128TECHNOL ACE193TECHWOOD002TEKNIKA002007035041076079096100106110119120133TELEFUNKEN183TELERENT100119120TERA014TMK002TOSHIBA008052076078099162TOTEVISON096UNIVERSAL080082VECTOR RESEARCH183VIDEO CONCEPTS067VIDIKRON108163VIDTECH002WARDS002007021049066080082096105109119156WESTINGHOUSE047WHITE WESTING HOUSE191YAMAHA001002YORK002YUPITERU035ZENITH034040119121131ZENITH TV/VCR060087ZONDA012VCR & TV/VCD CodesBrand CodesADMIRAL074AIWA000090AKAI030049050051055060AMPRO099ANAM088089AUDIO DYNAMICS016020030BELL & HOWELL005109BROKSONIC053054059105122CANON057087089CAPEHART019CITIZEN063CRAIG001012CURTIS MATHES087089092DAEWOO018019025048064065070109DAX016020030DAYTRON018019DBX020030DYNATECH075090ELECTROHOME010EMERSON017021041045046048051053054058059060062089090104105122FISHER038039109FUNAI090GENERAL ELECTRIC012087089096097099108112114116143144GO VIDEO003004012014GOLSTAR (LG)020*********HARMAN KARDON020052HITACHI022030069077078079090112INSTANT REPLAY087088089J.C. PENNEY012020062078079087088089JCL089JENSEN030JVC006010020022024026027029030089 KENWOOD005022029030090LLOYD'S090LOGIK015LXI038048062063078090MAGNIN012MAGNAVOX031032034035087089090092100 MARANTZ020031033034089MARTA062063MATSUI045056MEI089MEMOREX005012013062075086087089090099 MGA010051052MINOLTA078MITSUBISHI009010051052076078091111 MONTGOMERY WARD037074087090108110MTC012090MULTITECH015090NEC016020029030NORDMENDE030OPTONICA036075ORION041PANASONIC080085087089101102PENTAX078079089112PHILCO0310********PHILIPS022031036062087088089090PILOT062PINOEER029078079082083PORTLAND018019PULSAR099QUARTZ005QUASAR005080085087089101102RADIO SHACK062RCA012078079080088089090092096097108113114115116118REALISTIC005012036039062074075087089090109RICO071RUNCO099SALORA005SAMSUNG008012048049081114116SANSUI001029030SANYO005012013SCOTT009046048054122SEARS005038039048062063078079109117 SHARP036073074075089SHINTOM015SIGNATURE037074087090108110SONY038068071072075089SOUNDESIGN090STS078SYLVANIA010031034087088089090SYMPHONIC090TANDY090109TASHIKO063TATUNG030TEAC030090TECHNICS089101TEKNIKA0470********THOMAS090TMK017TOSHIBA010022039044048078079TOTEVISION012062UNITECH012VECTOR RESEARCH009020VICTOR029VIDEO CONCEPTS020051090VIDEO SONIC012WARDS012015036048075078089090 YAMAHA020030090ZENITH027029062071090093098099104 TV/VCR CodesBrand CodesADVENTURA121129BROKSONIC136137DAEWOO124125EMERSON122123133FUNAI121129GOLDSTAR (LG)132135138139HITACHI121129LXI121129MAGNAVOX120128130PANASONIC126127RCA120RS126127SAMSUNG131SANSUI136137SHARP119120SYLVANIA121129SYMPHONIC121129XR-1000121129ZENITH121124129132135136137138139DVD, DVR, & Blu-Ray CodesBrand CodesADVENT200ALLEGRO194APEX DIGITAL167172173177178179187206209217 AUDIOVOX176BLAUPUNKT172BLUE PARADE157BROKSONIC169193CINEVISION196CURTIS MATHES208CYBERHOME183DAEWOO175188DENON147222DVD2000149EMERSON160168185ENTERPRISE160FISHER166FUNAI168GE150172182223224GO VIDEO171174GPX170GREENHILL172HARMAN/KARDON159HITACHI145146158HITEKER167INITIAL172JENSEN200JVC156161192213KENWOOD147153KLH172176201KOSS165LASONIC180LITE-ON205LG225MAGNAVOX148168220226MARANTZ154MEMOREX169MICROSOFT150MINTEX172189MITSUBISHI149211227MOTOROLA203MOXELL203DVD, DVR, & Blu-Ray Codes (continued)Brand CodesNESA172NORCENT199ONKYO148ORITRON165PANASONIC147163************ PHILIPS148154164190197PIONEER151157163214229POLK AUDIO154PRIMA200PROSCAN150PROVIEW203QWESTAR165RCA150157172176186202RIO194ROTEL161SAMSUNG158184198207218230233 SANSUI169SANYO166169195SHARP162SHINSONIC152189SONIC BLUE194SONY152191215219231SYLVANIA168185SYMPHONIC168TEAC176TECHNICS147THETA DIGITAL157TOSHIBA148169204TREDEX181URBAN/CONCEPTS148VENTURER176XBOX150YAMAHA147154155232ZENITH148160194232DVR CodesBrand Codes PANASONIC140PHILIPS141REPLAY TV140221SONIC BLUE140221SONY142TIVO141142CD, LD, HOME AUTOMATION & PVR CodesBrand CodesAKAI000001CROWN001DENON002FISHER003025GOLDSTAR (LG)037HAMAN/KARDON004JVC005KENWOOD006028055MAGNAVOX009MITSUBISHI010NAD012013034NAKAMICHI014015NEC016ONKYO017PANASONIC018019PHILIPS008020021041PIONEER022042RADIOSHACK023026027RCA024SANYO043SHARP030SONY030031032044SOUNDESIGN038046TEAC033TECHNICS036YAMAHA035048049050051052053054 ZENITH045047LASER DISC CodesBrand Codes DENON067PIONEER067PROSCAN068RCA068SANYO065SONY066ZENITH065HOME AUTOMATION CodesBrand Codes GE (AUX 3601)069RADIOSHACK (AUX 3600)071PHILIPS (VCR2039)070ECHO STAR (VCR2040)072ENGThis page intentionally left blank.Peerless-AV EuropeUnit 3 Watford Interchange, Colonial Way, Watford, Herts, WD24 4WP, United Kingdom Customer Care44 (0) 1923 200 100 Peerless-AV de Mexico Ave de las Industrias 413 Parque Industrial Escobedo Escobedo N.L Mexico 66050 Servicio al Cliente01-800-849-65-77Peerless-AV2300 White Oak CircleAurora, IL 60502Email:*********************** Ph: (800) 865-2112Fax: (800) 359-6500。
MuPAD 1.4 动态模块用户手册和编程指南说明书
Dynamic Modules
Springer
Berlin Heidelberg New York Barcelona Budapest Hong Kong London Milan Paris Singapore Tokyo
Andreas Sorgatz
Dynamic Modules
User's Manual and Programming Guide for MuPAD 1.4
Cover Design: Kiinkel + Lopka, Werbeagentur, Heidelberg
SPIN 10693570 33/3142 - 5 4 3 2 1 0
Preface
Today, integration of software packages into computer algebra systems (CAS)
The author accepts no responsibility for this manual or the programs described in it. The author of this manual and the developers of MuPAD and contributions available on the accompanying CD-ROM assume no responsibility for direct or indirect damages, losses, costs, claims for loss of profits or charges or expenses of any kind.
linprog包的说明书
Package‘linprog’October13,2022Version0.9-4Date2022-03-09Title Linear Programming/OptimizationAuthor Arne HenningsenMaintainer Arne Henningsen<*************************>Depends R(>=2.4.0),lpSolveDescription Can be used to solve Linear Programming/LinearOptimization problems by using the simplex algorithm.License GPL(>=2)URL /NeedsCompilation noRepository CRANDate/Publication2022-03-0921:10:08UTCR topics documented:print.solveLP (2)readMps (3)solveLP (4)summary.solveLP (8)writeMps (9)Index1112print.solveLP print.solveLP Print Objects of Class solveLPDescriptionThis method prints the results of the Linear Programming algorithm.Usage##S3method for class solveLPprint(x,digits=6,...)Argumentsx an object returned by solveLP.digits number of digits to print....currently ignored.Valueprint.solveLP invisibly returns the object given in argument x.Author(s)Arne HenningsenSee AlsosolveLP,summary.solveLP,readMps,writeMpsExamples##example of Steinhauser,Langbehn and Peters(1992)##Not run:library(linprog)##Production activitiescvec<-c(1800,600,600)#gross marginsnames(cvec)<-c("Milk","Bulls","Pigs")##Constraints(quasi-fix factors)bvec<-c(40,90,2500)#endowmentnames(bvec)<-c("Land","Stable","Labor")##Needs of Production activitiesAmat<-rbind(c(0.7,0.35,0),c( 1.5,1,3),c(50,12.5,20))readMps3 ##Maximize the gross marginres<-solveLP(cvec,bvec,Amat,TRUE)##print the resultsprint(res)readMps Read MPS FilesDescriptionThis function reads MPSfiles-the standard format for Linear Programming problems.UsagereadMps(file,solve=FALSE,maximum=FALSE)Argumentsfile a character string naming thefile to read.solve logical.Should the problem be solved after reading it from thefile(using solveLP)?maximum logical.Should we maximize or minimize(the default)?DetailsEquality constraints and’greater than’-bounds are not implemented yet.ValuereadMps returns a list containing following objects:name the name of the Linear Programming problem.cvec vector c.bvec vector b.Amat matrix A.res if solve is TRUE,it contains the results of the solving process(an object of class solveLP).Author(s)Arne HenningsenSee AlsosolveLP,writeMpsExamples##example of Steinhauser,Langbehn and Peters(1992)##Production activitiescvec<-c(1800,600,600)#gross marginsnames(cvec)<-c("Cows","Bulls","Pigs")##Constraints(quasi-fix factors)bvec<-c(40,90,2500)#endowmentnames(bvec)<-c("Land","Stable","Labor")##Needs of Production activitiesAmat<-rbind(c(0.7,0.35,0),c( 1.5,1,3),c(50,12.5,20))##Write to MPS filewriteMps("steinh.mps",cvec,bvec,Amat,"Steinhauser")##delete all LP objectsrm(cvec,bvec,Amat)##Read LP data from MPS file and solve it.lp<-readMps("steinh.mps",TRUE,TRUE)##Print the resultslp$res##remove the MPS filefile.remove("steinh.mps")solveLP Solve Linear Programming/Optimization ProblemsDescriptionMinimizes(or maximizes)c x,subject to Ax<=b and x>=0.Note that the inequality signs<=of the individual linear constraints in Ax<=b can be changed with argument const.dir.UsagesolveLP(cvec,bvec,Amat,maximum=FALSE,const.dir=rep("<=",length(bvec)),maxiter=1000,zero=1e-9,tol=1e-6,dualtol=tol,lpSolve=FALSE,solve.dual=FALSE,verbose=0)Argumentscvec vector c(containing n elements).bvec vector b(containing m elements).Amat matrix A(of dimension m×n).maximum logical.Should we maximize or minimize(the default)?const.dir vector of character strings giving the directions of the constraints:each value should be one of"<,""<=,""=,""==,"">,"or">=".(In each pair the two valuesare identical.)maxiter maximum number of iterations.zero numbers smaller than this value(in absolute terms)are set to zero.tol if the constraints are violated by more than this number,the returned component status is set to3.dualtol if the constraints in the dual problem are violated by more than this number,the returned status is non-zero.lpSolve logical.Should the package’lpSolve’be used to solve the LP problem?solve.dual logical value indicating if the dual problem should also be solved.verbose an optional integer variable to indicate how many intermediate results should be printed(0=no output;4=maximum output).DetailsThis function uses the Simplex algorithm of George B.Dantzig(1947)and provides detailed results(e.g.dual prices,sensitivity analysis and stability analysis).If the solution x=0is not feasible,a2-phase procedure is applied.Values of the simplex tableau that are actually zero might get small(positive or negative)numbers due to rounding errors,which might lead to artificial restrictions.Therefore,all values that are smaller(in absolute terms)than the value of zero(default is1e-10)are set to0.Solving the Linear Programming problem by the package lpSolve(of course)requires the instal-lation of this package,which is available on CRAN(https:///package= lpSolve).Since the lpSolve package uses C-code and this(linprog)package is not optimized for speed,the former is much faster.However,this package provides more detailed results(e.g.dual values,stability and sensitivity analysis).This function has not been tested extensively and might not solve all feasible problems(or might even lead to wrong results).However,you can export your LP to a standard MPSfile via writeMps and check it with other software(e.g.lp_solve,see /5.5/).Equality constraints are not implemented yet.ValuesolveLP returns a list of the class solveLP containing following objects:opt optimal value(minimum or maximum)of the objective function.solution vector of optimal values of the variables.iter1iterations of Simplex algorithm in phase1.iter2iterations of Simplex algorithm in phase2.basvar vector of basic(=non-zero)variables(at optimum).con matrix of results regarding the constraints:1st column=maximum values(=vector b);2nd column=actual values;3rd column=differences between maximum and actual values;4th column=dual prices(shadow prices);5th column=valid region for dual prices.allvar matrix of results regarding all variables(including slack variables):1st column=optimal values;2nd column=values of vector c;3rd column=minimum of vector c that does not change the solution;4th column=maximum of vector c that does not change the solution;5th column=derivatives to the objective function;6th column=valid region for these derivatives.status numeric.Indicates if the optimization did succeed:0=success;1=lpSolve did not succeed;2=solving the dual problem didnot succeed;3=constraints are violated at the solution(internal error or largerounding errors);4=simplex algorithm phase1did notfind a solution withinthe number of iterations specified by argument maxiter;5=simplex algorithmphase2did notfind the optimal solution within the number of iterations speci-fied by argument maxiter.lpStatus numeric.Return code of lp(only if argument lpSolve is TRUE).dualStatus numeric.Return code from solving the dual problem(only if argument solve.dual is TRUE).maximum logical.Indicates whether the objective function was maximized or minimized.Tabfinal’Tableau’of the Simplex algorith.lpSolve logical.Has the package’lpSolve’been used to solve the LP problem.solve.dual logical.Argument solve.dual.maxiter numeric.Argument maxiter.Author(s)Arne HenningsenReferencesDantzig,George B.(1951),Maximization of a linear function of variables subject to linear inequal-ities,in Koopmans,T.C.(ed.),Activity analysis of production and allocation,John Wiley\&Sons, New York,p.339-347.Steinhauser,Hugo;Cay Langbehn and Uwe Peters(1992),Einfuehrung in die landwirtschaftliche Betriebslehre.Allgemeiner Teil,5th ed.,Ulmer,Stuttgart.Witte,Thomas;Joerg-Frieder Deppe and Axel Born(1975),Lineare Programmierung.Einfuehrung fuer Wirtschaftswissenschaftler,Gabler-Verlag,Wiesbaden.See AlsoreadMps and writeMpsExamples##example of Steinhauser,Langbehn and Peters(1992)##Production activitiescvec<-c(1800,600,600)#gross marginsnames(cvec)<-c("Cows","Bulls","Pigs")##Constraints(quasi-fix factors)bvec<-c(40,90,2500)#endowmentnames(bvec)<-c("Land","Stable","Labor")##Needs of Production activitiesAmat<-rbind(c(0.7,0.35,0),c( 1.5,1,3),c(50,12.5,20))##Maximize the gross marginsolveLP(cvec,bvec,Amat,TRUE)##example1.1.3of Witte,Deppe and Born(1975)##Two types of Feedcvec<-c(2.5,2)#prices of feednames(cvec)<-c("Feed1","Feed2")##Constraints(minimum(<0)and maximum(>0)contents)bvec<-c(-10,-1.5,12)names(bvec)<-c("Protein","Fat","Fibre")##Matrix AAmat<-rbind(c(-1.6,-2.4),c(-0.5,-0.2),c( 2.0, 2.0))##Minimize the costsolveLP(cvec,bvec,Amat)#the same optimisation using argument const.dirsolveLP(cvec,abs(bvec),abs(Amat),const.dir=c(">=",">=","<="))##There are also several other ways to put the data into the arrays,e.g.: bvec<-c(Protein=-10.0,Fat=-1.5,Fibre=12.0)cvec<-c(Feed1=2.5,Feed2=2.0)Amat<-matrix(0,length(bvec),length(cvec))8summary.solveLP rownames(Amat)<-names(bvec)colnames(Amat)<-names(cvec)Amat["Protein","Feed1"]<--1.6Amat["Fat","Feed1"]<--0.5Amat["Fibre","Feed1"]<- 2.0Amat["Protein","Feed2"]<--2.4Amat["Fat","Feed2"]<--0.2Amat["Fibre","Feed2"]<- 2.0solveLP(cvec,bvec,Amat)summary.solveLP Summary Results for Objects of Class solveLPDescriptionThese methods prepare and print summary results of the Linear Programming algorithm.Usage##S3method for class solveLPsummary(object,...)##S3method for class summary.solveLPprint(x,...)Argumentsobject an object returned by solveLP.x an object returned by summary.solveLP....currently ignored.Valuesummary.solveLP returns an object of class summary.solveLP.print.summary.solveLP invisi-bly returns the object given in argument x.Author(s)Arne HenningsenSee AlsosolveLP,print.solveLP,readMps,writeMpsExamples##example of Steinhauser,Langbehn and Peters(1992)##Not run:library(linprog)##Production activitiescvec<-c(1800,600,600)#gross marginsnames(cvec)<-c("Milk","Bulls","Pigs")##Constraints(quasi-fix factors)bvec<-c(40,90,2500)#endowmentnames(bvec)<-c("Land","Stable","Labor")##Needs of Production activitiesAmat<-rbind(c(0.7,0.35,0),c( 1.5,1,3),c(50,12.5,20))##Maximize the gross marginres<-solveLP(cvec,bvec,Amat,TRUE)##prepare and print the summary resultssummary(res)writeMps Write MPS FilesDescriptionThis function writes MPSfiles-the standard format for Linear Programming problems.UsagewriteMps(file,cvec,bvec,Amat,name="LP")Argumentsfile a character string naming thefile to write.cvec vector c.bvec vector b.Amat matrix A.name an optional name for the Linear Programming problem.DetailsThe exported LP can be solved by running other software on this MPSfile(e.g.lp_solve,see /5.5/).Author(s)Arne HenningsenSee AlsosolveLP,readMpsExamples##example of Steinhauser,Langbehn and Peters(1992)##Production activitiescvec<-c(1800,600,600)#gross marginsnames(cvec)<-c("Cows","Bulls","Pigs")##Constraints(quasi-fix factors)bvec<-c(40,90,2500)#endowmentnames(bvec)<-c("Land","Stable","Labor")##Needs of Production activitiesAmat<-rbind(c(0.7,0.35,0),c( 1.5,1,3),c(50,12.5,20))##Write to MPS filewriteMps("steinh.mps",cvec,bvec,Amat,"Steinhauser") ##remove the MPS filefile.remove("steinh.mps")Index∗optimizeprint.solveLP,2readMps,3solveLP,4summary.solveLP,8writeMps,9lp,6print.solveLP,2,8print.summary.solveLP(summary.solveLP),8readMps,2,3,7,8,10solveLP,2,3,4,8,10summary.solveLP,2,8writeMps,2,3,5,7,8,911。
PeerSim中文教程
PeerSim中文教程(1):解析 Cycle-based 模式仿真本文介绍了PeerSim的基本概念,并解析了两个示例以更清晰地说明PeeSim的仿真流程。
Peersim支持两种仿真模式,即Cycle-based的模型和传统的event-based的模型,本文专注于前者,Cycle-based模型是一个简化的模型,拥有更好的伸缩性及性能,在拥有4GB内存的情况下,event-driven模式目前最多支持十万节点级别,而cycle-based模式则支持千万个节点级别。
但是Cycle-based模型缺少对传输层的仿真和并行处理,节点之间是直接通信的,仿真核心以一定的顺序周期性地给以节点控制。
在运行时,可以进行任意的操作,如调用其它对象的方法并执行一些计算。
Cycle-based模型损失了一些真实性,虽然一些简单的协议可以忽略这些差别,但是在选择使用这个模型时,需要注意这些区别。
我们可以相对简单地将Cycle-based的仿真移植到Event-driven引擎上,但在本文中不讨论这个话题。
一.基本介绍PeerSim鼓励基于接口的模块化编程,每一个组件都能被其它实现了相同接口的组件代替,一般的仿真过程如下:1.选择网络大小(即节点数量)。
2.选择要实验的一个或多个协议并进行初始化。
3.选择一个或多个Control对象来监视感兴趣的属性,并在仿真时修改一些参数(比如,网络大小,协议的内部状态,等等)。
4.根据配置文件,调用Simulator类运行仿真。
在仿真时创建的对象都是实现了一个或多个接口的类的实例,主要的接口如下所示:Node P2P网络是由节点组成的,节点是协议的容器。
Node接口提供了对节点所包含的协议的访问方法,并为节点提供了固定的ID。
CDProtocol 这是一个特定的协议,被设计用来在Cycle-based模型中运行,它只定义了在每一个周期中要运行的操作。
Linkable 一般都由协议来实现,这个接口为其它协议提供了访问邻居节点集合的服务,节点间相同的linkable协议类的实例定义了一个覆盖网络。
Peergine编程手册
Peergine编程手册V 1.1.22012-05介绍1. 关于PeerginePeergine是一个功能强大的对等通信中间件,用C/C++编程语言开发。
为了适应多种运行环境,Peergine被封装成ActiveX控件(pgATX)、NPAPI插件和JNI插件等,能够在Internet Explorer、Chrome、Firefox和Safari等浏览器以及Windows Script Host、Java Runtime Environment等环境中运行。
支持Windows、Linux和Android操作系统。
旨在能方便地构建具有丰富的对等通信功能的Web应用,包括浏览器端和服务器端。
注:本编程手册以ActiveX控件(pgATX)的编程接口为例,说明Peergine中间件的使用方法。
NPAPI插件、JNI插件的编程接口与ActiveX控件是兼容的。
2. Peergine的功能特性1) 全新的网络编程模式以面向对象的方法,把复杂的多点对等通信交互过程封装成通信对象,提供简单、直观的编程接口。
即便是对网络通信知识缺乏了解的编程人员,也能够构建出功能强大的对等通信应用。
参考“基于对象的多点通信会话”章节。
2) 强大的对等通信功能以通信对象类的形式实现各种对等通信功能,目前支持的通信对象类为:节点类:提供对象的两点通信范围控制。
节点的登录/注销,两个节点之间的远程过程调用,两个节点之间的消息传输,数据签名的生成和校验。
参考“使用节点类”章节。
通信组类:提供对象的多点通信范围控制。
支持手动控制组成员、自动控制组成员和主(Master)成员控制功能。
参考“使用通信组类”章节消息传输类:多个节点之间单向传输消息。
参考“使用消息传输类”章节。
文件传输类:两个节点之间的文件传输。
支持PUT和GET传输方式,文件的断点续传。
参考“使用文件传输类”章节音频传输类:实时捕捉和传输音频。
支持两点对话模式和多点会议模式。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Peergine编程手册V 1.1.22012-05介绍1. 关于PeerginePeergine是一个功能强大的对等通信中间件,用C/C++编程语言开发。
为了适应多种运行环境,Peergine被封装成ActiveX控件(pgATX)、NPAPI插件和JNI插件等,能够在Internet Explorer、Chrome、Firefox和Safari等浏览器以及Windows Script Host、Java Runtime Environment等环境中运行。
支持Windows、Linux和Android操作系统。
旨在能方便地构建具有丰富的对等通信功能的Web应用,包括浏览器端和服务器端。
注:本编程手册以ActiveX控件(pgATX)的编程接口为例,说明Peergine中间件的使用方法。
NPAPI插件、JNI插件的编程接口与ActiveX控件是兼容的。
2. Peergine的功能特性1) 全新的网络编程模式以面向对象的方法,把复杂的多点对等通信交互过程封装成通信对象,提供简单、直观的编程接口。
即便是对网络通信知识缺乏了解的编程人员,也能够构建出功能强大的对等通信应用。
参考“基于对象的多点通信会话”章节。
2) 强大的对等通信功能以通信对象类的形式实现各种对等通信功能,目前支持的通信对象类为:节点类:提供对象的两点通信范围控制。
节点的登录/注销,两个节点之间的远程过程调用,两个节点之间的消息传输,数据签名的生成和校验。
参考“使用节点类”章节。
通信组类:提供对象的多点通信范围控制。
支持手动控制组成员、自动控制组成员和主(Master)成员控制功能。
参考“使用通信组类”章节消息传输类:多个节点之间单向传输消息。
参考“使用消息传输类”章节。
文件传输类:两个节点之间的文件传输。
支持PUT和GET传输方式,文件的断点续传。
参考“使用文件传输类”章节音频传输类:实时捕捉和传输音频。
支持两点对话模式和多点会议模式。
支持会议发言控制,实时音量变化显示,音频录制。
参考“使用音频传输类”章节视频传输类:实时捕捉和传输视频。
支持本地预览模式、两点对话模式和多点会议模式。
支持会议模式中视频的加入/离开,视频显示窗口的调整和转移,抓拍视频照片,视频录制。
参考“使用视频传输类”章节。
白板共享类:多个节点共享白板,可设置绘制每种图形的参数,可设置绘制每种图形时的鼠标光标,保存白板内容到图片文件,从图片文件装入内容到白板。
参考“使用白板共享类”章节。
文件分块共享类:类似BitTorrent和eMule,多个节点以分块的方式对等传输文件。
顺序传输模式,分散传输模式,可设置文件传输的数据块大小,实时将获取到的文件数据转发到本地HTTP服务器上以便使用播放器或浏览器来播放文件。
参考“使用文件分块共享类”章节。
数据表传输类:多个节点之间用访问数据库的方式传输数据。
支持文件传输模式,每个文件对应到数据表的一条记录进行传输,实现文件的批量同步。
参考“使用数据表传输类”章节。
媒体流直播类:多个节点之间对等直播媒体流。
支持实时捕捉音频流、实时捕捉视频流和A VI文件播放的方式提供媒体源。
支持媒体源的快速切换,丢帧重传,自动选择网络状况好的节点进行中继转发。
支持媒体流录制。
参考“使用媒体流直播类”章节。
3) 自适应的网络互通机制以IPV4和IPV6的UDP协议为基础进行网络通信。
对于UDP协议通信受限的节点,通过承载在TCP之上的隧道连接到中继服务器,然后转换成UDP协议通信。
支持TCP、HTTP和WebSocket三种协议的隧道,以适应多种通信环境。
通过中继服务器还可以完成IPV4和IPV6之间的转换。
支持位于IPV4私网中的节点的NA T穿越,自动探测NAT会话的老化时间,以恰当的时间间隔刷新NAT 会话,防止老化。
各种协议之间的转换互通,由Socket适配层自动适应,对上层通信对象透明。
参考“配置和运行中继服务器”章节。
一个通信节点只占用一个UDP端口,并此端口上实现出多点通信机制,因此占用防火强或NAT的会话资源少。
支持HTTP代理方式通信,在代理后面的主机也能连接到Peergine网络。
实现QOS机制,每个节点都有4个优先级队列,分别对消息/信令、音频、视频和文件4种流量进行优先级调度,保证高优先级流量的服务质量。
支持对通信数据进行加密,加密的密钥自动协商生成,无需配置。
4) 控件提供丰富的辅助功能Peergine在封装成控件时,又增加实现了辅助功能,包括常用的文件操作、文件缓冲区操作、本地Cookie存储、本地HTTP服务器、A VI文件播放等。
这些辅助功能通过命令执行函数utilCmd()来调用。
请参考“控件的命令列表”章节。
5) 多种OS和运行环境Peergine封装成了ActiveX控件、NPAPI插件和JNI插件等接口形式,可以运行在Internet Explorer、Chrome、Firefox和Safari浏览器中,以及Windows Script Host和Java Runtime Enviroment运行环境中。
支持Windows、Linux和Android操作系统。
可用JavaScript和Java编程语言构建Web应用的浏览器端和服务器端。
3. 基于对象的多点通信会话1) 概念在以往的网络编程方法中,例如,TCP连接、SIP会话等,通信会话一般指两点之间协商建立起来的通信交互。
且也已经有了相应成熟的网络编程模型,例如Socket API。
但在对等通信应用中,通信交互往往是多点对多点的,而且参与通信交互的节点会动态变化。
如果依然使用两点通信的模型去搭建对等通信应用,那将是相当复杂、困难的事情,需要富有经验的网络编程人员才能完成。
我们能否找到一种方法,让对等通信编程也变得直观、简单呢?其实,人们使用网络的行为可以简单表达为一句话:“多个人通过网络连接在一起做同一件事”。
比如,多个人在一个聊天室里交谈、多个人在顶一个帖子、多个人在观看一个视频等等。
我们可以把其中的“多个人”抽象为多个通信节点,“同一件事”抽象为一个通信会话,也就是把使用网络的行为抽象为一个“多点通信会话”。
两点通信会话与多点通信会话的比较示意图,如下:图1. (a) 两点通信会话连接,(b) 多点通信会话连接进一步,我们把一个多点通信会话封装成一个通信对象,用面向对象的方法来表述网络通信的特征,这样就使对等网络编程变得更加简单、直观。
Peergine 就是这种以通信对象为基础的对等通信系统。
在系统中不同的通信业务类型表述为相对应的通信对象类,例如消息传输类、音频传输类、视频传输类等,而每一个通信对象实例表示一个通信会话。
2) 同名通信对象Peergine 系统中的一个通信对象通过一个名称来标识。
每个通信节点有一个节点自身对象,其对象名称就是节点的名称,这个节点自身对象的名称必须是整个网络中唯一的。
在每个通信节点上除了节点自身对象以外,还可以创建多个各种类型的通信对象,这些通信对象的名称必须在本节点范围内唯一。
在不同的通信节点上就可以存在名称相同的通信对象,我们把这样的一套通信对象称为“同名通信对象”。
在Peergine 系统中,一套同名通信对象就是一个多点通信会话。
位于不同节点上的相同名称的通信对象之间自动地建立起通信会话,然后在其中一个节点上调用该对象的方法,就可以完成与其它各节点之间的通信交互。
同名通信对象建立通信会话的过程,称为“通信对象的同步”。
如下图,有NodeA 、NodeB 、NodeC 三个节点,它们的自身对象分别为 NodeA 、NodeB 、NodeC 。
在节点NodeA 可以创建一个节点对象NodeB 与节点NodeB 的自身对象同名,这时节点NodeA 上的NodeB 和节点NodeB 的自身对象就是同名通信对象,它们之间自动建立会话连接。
同样节点NodeA 、NodeB 、NodeC 上都有通信组对象Group0和消息传输对象Data0,它们都组成相应的同名通信对象。
(a)(b)图2. 同名通信对象机制3) 通信范围控制当很多节点上都有名称相同的通信对象时,如何确定哪些节点上的同名通信对象才能组成一个多点通信会话呢?这就涉及到同名通信对象的通信范围问题。
在Peergine 系统中有两种可以用来确定通信范围的通信对象,它们分别是节点对象和通信组对象。
对于节点对象,它的通信范围由对象名称决定。
例如上图中,在节点NodeA 上创建节点对象NodeB ,它跟节点NodeB 的自身对象同名,所以它的通信范围就是节点B 。
使用节点对象可以建立两点之间的通信会话。
对于通信组对象,它的通信范围由它所包含的组成员决定。
通信组对象的成员就是其通信范围内的节点的自身对象的名称。
添加或删除通信组对象的成员可以改变通信组的通信范围。
使用通信组对象可以建立多点之间的通信会话。
对于其它业务类型的通信对象,例如消息传输对象、文件传输对象,它们没有控制通信范围的机制,则可以通过关联节点对象或通信组对象来控制通信范围。
当它们关联节点对象时,实现两点之间的通信交互,当它们关联通信组对象时,实现多点之间的通信交互。
一个节点对象或通信组对象可以被多个通信对象关联。
参考“使用通信组类”章节。
4. 控件与应用程序的交互方式 1) 系统概述Peergine 中间件的系统框图如下,它位于应用程序和网络层的中间。
上方通过控件提供的API 与应用程序交互,下方通过OS 的Socket API 与网络协议栈交互。
图3.系统框图调用通信对象类的方法时,应用程序与pgATX控件之间的交互通过4个编程接口来完成。
分别为发送请求ObjectRequest()、接收请求OnExtRequest()、发送应答ObjectExtReply()和接收应答OnReply(),其中OnExtRequest()和OnReply()是回调函数,需要在控件初始化时注册才能使用。
但并不是所有的方法的调用都需要4个函数的交互过程,有些方法只需要其中1个或2个函数的交互。
Peergine系统用到的交互方式由下文的小章节逐个说明。
2) 方式1:本端应用程序发送请求、接收应答。
对端应用程序接收请求、发送应答。
图4.交互方式13) 方式2:本端应用程序发送请求、接收应答。
对端控件接收请求、发送应答。
图5.交互方式24) 方式3:本端控件发送请求、接收应答。
对端应用程序接收请求、发送应答。
图6.交互方式3 2) 方式4:本端应用程序发送请求。
对端应用程序接收请求。
图7.交互方式4 5) 方式5:本端应用程序发送请求,本端应用程序接收应答。
图8.交互方式5 6) 方式6:本端应用程序发送请求触发本端控件上报事件给应用。
图9.交互方式6 7) 方式7:本端应用程序调用本端控件的方法但没有输出。