`
Donald_Draper
  • 浏览: 999456 次
社区版块
存档分类
最新评论

DatagramChannelImpl 解析三(多播)

    博客分类:
  • NIO
nio 
阅读更多
DatagramChannelImpl 解析一(初始化):http://donald-draper.iteye.com/blog/2373245
DatagramChannelImpl 解析二(报文发送与接收):http://donald-draper.iteye.com/blog/2373281
引言:
上一篇看了报文的发送和接收,先来回顾一下,
   send(发送报文)方法,首先同步写锁,确保通道打开,然后检查地址,如果系统安全管理器不为null,则更具地址类型检查相应的权限,如果地址为多播地址,则检查多播权限,否则检查连接到socketaddress的权限;如果发送的buffer为direct类型,则直接发送,否则从当前线程缓冲区获取一个临时DirectByteBuffer,并将buffer中的数据写到临时DirectByteBuffer中,然后发送,发送后,释放临时DirectByteBuffer,即添加到当前线程缓存区以便重用。
      receive(接收报文)方法,首先同步读锁,确保通道打开,如果本地地址为null,则绑定local地址,并初始化报文通道的localAddress;获取buffer当前可用空间remaining,如果buffer为direct类型,则直接接收报文,否则,从当前线程缓冲区获取临时DirectByteBuffer,接收报文,写到临时缓冲区临时DirectByteBuffer,读取临时DirectByteBuffer,写到buffer中,释放临时DirectByteBuffer,即添加DirectByteBuffer到当前线程缓存区,以便重用。
     send(发送报文)和receive(接收报文)方法不需要通道已经处于连接状态,而read和write需要通道建立连接状态,这种方式与SocketChannel的读写操作相同,这样与SocketChannel无异,如果需要不如使用SocketChannel。如果使用DatagramChannel,建议使用send和recieve方法进行报文的发送和接收。
今天我们来看一下多播相关的方法为drop,block,unblock,join。
先看join方法
//添加到多播组inetaddress
 public MembershipKey join(InetAddress inetaddress, NetworkInterface networkinterface)
        throws IOException
    {
        return innerJoin(inetaddress, networkinterface, null);
    }
//添加到多播组,只接受源地址为inetaddress1的报文
    public MembershipKey join(InetAddress inetaddress, NetworkInterface networkinterface, InetAddress inetaddress1)
        throws IOException
    {
        if(inetaddress1 == null)
            throw new NullPointerException("source address is null");
        else
            return innerJoin(inetaddress, networkinterface, inetaddress1);
    }

从上面可以看出加入多播组实际上的操作是由innerJoin来完成
 private MembershipKey innerJoin(InetAddress inetaddress, NetworkInterface networkinterface, InetAddress inetaddress1)
     throws IOException
 {
     //非多播地址抛出异常
     if(!inetaddress.isMulticastAddress())
         throw new IllegalArgumentException("Group not a multicast address");
     //如果地址为ip6,但加入的多播组地址为ip4,则抛出参数异常
     if(inetaddress instanceof Inet4Address)
     {
         if(family == StandardProtocolFamily.INET6 && !Net.canIPv6SocketJoinIPv4Group())
             throw new IllegalArgumentException("IPv6 socket cannot join IPv4 multicast group");
     } else
     if(inetaddress instanceof Inet6Address)
     {
         //如果多播地址为ip6,协议非INET6,抛出异常
         if(family != StandardProtocolFamily.INET6)
             throw new IllegalArgumentException("Only IPv6 sockets can join IPv6 multicast group");
     } else
     {
         throw new IllegalArgumentException("Address type not supported");
     }
     //如果多播组源地址不为空,则校验源地址
     if(inetaddress1 != null)
     {
         if(inetaddress1.isAnyLocalAddress())//源地址含通配符,address == 0;
             throw new IllegalArgumentException("Source address is a wildcard address");
         if(inetaddress1.isMulticastAddress())//源地址为多播地址
             throw new IllegalArgumentException("Source address is multicast address");
         if(inetaddress1.getClass() != inetaddress.getClass())//源地址与多播地址类型不同
             throw new IllegalArgumentException("Source address is different type to group");
     }
     SecurityManager securitymanager = System.getSecurityManager();
     if(securitymanager != null)
         //检查多播地址权限,接受和连接权限
         securitymanager.checkMulticast(inetaddress);
     Object obj = stateLock;
     JVM INSTR monitorenter ;
     Object obj1;
     if(!isOpen())//确保通道打开
         throw new ClosedChannelException();
     if(registry == null)
     {
         //多播关系注册器为null,则创建
         registry = new MembershipRegistry();
         break MISSING_BLOCK_LABEL_229;
     }
     //检查多播成员关系注册器中是否存在多播地址为inetaddress,网络接口为networkinterface,
     //源地址为inetaddress1,多播成员关系key
     obj1 = registry.checkMembership(inetaddress, networkinterface, inetaddress1);
     if(obj1 != null)
         //有则直接返回
         return ((MembershipKey) (obj1));
     //否则根据网络协议族family,网络接口,源地址构造MembershipKeyImpl
     if(family == StandardProtocolFamily.INET6 && ((inetaddress instanceof Inet6Address) || Net.canJoin6WithIPv4Group()))
     {//Ip6
         int i = networkinterface.getIndex();
         if(i == -1)
             throw new IOException("Network interface cannot be identified");
         byte abyte0[] = Net.inet6AsByteArray(inetaddress);
         byte abyte1[] = inetaddress1 != null ? Net.inet6AsByteArray(inetaddress1) : null;
	 //加入多播组
         int l = Net.join6(fd, abyte0, i, abyte1);
         if(l == -2)
             throw new UnsupportedOperationException();
         obj1 = new MembershipKeyImpl.Type6(this, inetaddress, networkinterface, inetaddress1, abyte0, i, abyte1);
     } else
     {//Ip4
         Inet4Address inet4address = Net.anyInet4Address(networkinterface);
         if(inet4address == null)
             throw new IOException("Network interface not configured for IPv4");
         int j = Net.inet4AsInt(inetaddress);
         int k = Net.inet4AsInt(inet4address);
         int i1 = inetaddress1 != null ? Net.inet4AsInt(inetaddress1) : 0;
	 //加入多播组
         int j1 = Net.join4(fd, j, k, i1);
         if(j1 == -2)
             throw new UnsupportedOperationException();
         obj1 = new MembershipKeyImpl.Type4(this, inetaddress, networkinterface, inetaddress1, j, k, i1);
     }
     //添加多播成员关系key到注册器
     registry.add(((MembershipKeyImpl) (obj1)));
     obj1;
     obj;
     JVM INSTR monitorexit ;
     return;
     Exception exception;
     exception;
     throw exception;
 }

以上方法有两点要关注
1.
if(inetaddress1.isAnyLocalAddress())//源地址含通配符,address == 0;
     throw new IllegalArgumentException("Source address is a wildcard address");
 if(inetaddress1.isMulticastAddress())//源地址为多播地址
     throw new IllegalArgumentException("Source address is multicast address");

//Inet4Address
public final class Inet4Address extends InetAddress {
    final static int INADDRSZ = 4;
     /**是否为多播地址
     * Utility routine to check if the InetAddress is an
     * IP multicast address. IP multicast address is a Class D
     * address i.e first four bits of the address are 1110.
     * @return a <code>boolean</code> indicating if the InetAddress is
     * an IP multicast address
     * @since   JDK1.1
     */
    public boolean isMulticastAddress() {
        return ((address & 0xf0000000) == 0xe0000000);
    }

    /**
    是否为统配符地址
     * Utility routine to check if the InetAddress in a wildcard address.
     * @return a <code>boolean</code> indicating if the Inetaddress is
     *         a wildcard address.
     * @since 1.4
     */
    public boolean isAnyLocalAddress() {
        return address == 0;
    }

    /**
     * Utility routine to check if the InetAddress is a loopback address.
     *是否为环路地址
     * @return a <code>boolean</code> indicating if the InetAddress is
     * a loopback address; or false otherwise.
     * @since 1.4
     */
    private static final int loopback = 2130706433; /* 127.0.0.1 */
    public boolean isLoopbackAddress() {
        /* 127.x.x.x */
        byte[] byteAddr = getAddress();
        return byteAddr[0] == 127;
    }
    ...
}

//InetAddress
public class InetAddress implements java.io.Serializable {
    /**
     * Specify the address family: Internet Protocol, Version 4
     * @since 1.4
     */
    static final int IPv4 = 1;

    /**
     * Specify the address family: Internet Protocol, Version 6
     * @since 1.4
     */
    static final int IPv6 = 2;

    /* Specify address family preference */
    static transient boolean preferIPv6Address = false;

    /**
     * @serial
     */
    String hostName;

    /**
     * Holds a 32-bit IPv4 address.
     *
     * @serial
     */
    int address;

    /**
     * Specifies the address family type, for instance, '1' for IPv4
     * addresses, and '2' for IPv6 addresses.
     *
     * @serial
     */
    int family;
}

2.
//加入多播组
int j1 = Net.join4(fd, j, k, i1);

//Net
static int join4(FileDescriptor filedescriptor, int i, int j, int k)
        throws IOException
    {
        return joinOrDrop4(true, filedescriptor, i, j, k);
    }
 private static native int joinOrDrop4(boolean flag, FileDescriptor filedescriptor, int i, int j, int k)
        throws IOException;


//加入多播组
int l = Net.join6(fd, abyte0, i, abyte1);

//Net
static int join6(FileDescriptor filedescriptor, byte abyte0[], int i, byte abyte1[])
        throws IOException
    {
        return joinOrDrop6(true, filedescriptor, abyte0, i, abyte1);
    }
 private static native int joinOrDrop6(boolean flag, FileDescriptor filedescriptor, byte abyte0[], int i, byte abyte1[])
        throws IOException;

从上面可以看出,报文通道加入多播组,首先检查加入的多播组地址是否正确,然后校验源地址,检查多播成员关系注册器中是否存在多播地址为inetaddress,网络接口为networkinterface,源地址为inetaddress1的多播成员关系key,有则直接返回,否则根据网络协议族family,网络接口,源地址构造多播成员关系MembershipKeyImpl,添加到注册器MembershipRegistry。
再来看block方法

void block(MembershipKeyImpl membershipkeyimpl, InetAddress inetaddress)
        throws IOException
    {
        //如果断言,开启,则判断多播关系key通道是否为本通道
        if(!$assertionsDisabled && membershipkeyimpl.channel() != this)
            throw new AssertionError();
	//断言源地址是否为null
        if(!$assertionsDisabled && membershipkeyimpl.sourceAddress() != null)
            throw new AssertionError();
        synchronized(stateLock)
        {
	    //如果多播成员关系无效
            if(!membershipkeyimpl.isValid())
                throw new IllegalStateException("key is no longer valid");
            if(inetaddress.isAnyLocalAddress())//如果源地址为统配地址
                throw new IllegalArgumentException("Source address is a wildcard address");
            if(inetaddress.isMulticastAddress())//如果源地址为多播地址
                throw new IllegalArgumentException("Source address is multicast address");
            if(inetaddress.getClass() != membershipkeyimpl.group().getClass())//如果多播地址与源地址类型不同
                throw new IllegalArgumentException("Source address is different type to group");
            int i;
	    //如果为多播组为IP6
            if(membershipkeyimpl instanceof MembershipKeyImpl.Type6)
            {
                MembershipKeyImpl.Type6 type6 = (MembershipKeyImpl.Type6)membershipkeyimpl;
		//委托给net
                i = Net.block6(fd, type6.groupAddress(), type6.index(), Net.inet6AsByteArray(inetaddress));
            } else
            {
	        //如果为多播组为IP4
                MembershipKeyImpl.Type4 type4 = (MembershipKeyImpl.Type4)membershipkeyimpl;
		//委托给net
                i = Net.block4(fd, type4.groupAddress(), type4.interfaceAddress(), Net.inet4AsInt(inetaddress));
            }
            if(i == -2)
                throw new UnsupportedOperationException();
        }
    }

上面一个方法需要关注的为
1.
i = Net.block4(fd, type4.groupAddress(), type4.interfaceAddress(), Net.inet4AsInt(inetaddress));

//Net
static int block4(FileDescriptor filedescriptor, int i, int j, int k)
        throws IOException
    {
        return blockOrUnblock4(true, filedescriptor, i, j, k);
    }
 private static native int blockOrUnblock4(boolean flag, FileDescriptor filedescriptor, int i, int j, int k)
        throws IOException;

2.
i = Net.block6(fd, type6.groupAddress(), type6.index(), Net.inet6AsByteArray(inetaddress));

//Net
static int block6(FileDescriptor filedescriptor, byte abyte0[], int i, byte abyte1[])
        throws IOException
    {
        return blockOrUnblock6(true, filedescriptor, abyte0, i, abyte1);
    }
 static native int blockOrUnblock6(boolean flag, FileDescriptor filedescriptor, byte abyte0[], int i, byte abyte1[])
        throws IOException;

再来看unblock方法
 void unblock(MembershipKeyImpl membershipkeyimpl, InetAddress inetaddress)
    {
        //如果断言,开启,则判断多播关系key通道是否为本通道
        if(!$assertionsDisabled && membershipkeyimpl.channel() != this)
            throw new AssertionError();
	//断言源地址是否为null
        if(!$assertionsDisabled && membershipkeyimpl.sourceAddress() != null)
            throw new AssertionError();
        synchronized(stateLock)
        {
            if(!membershipkeyimpl.isValid())//如果多播成员关系无效
                throw new IllegalStateException("key is no longer valid");
            try
            {
                if(membershipkeyimpl instanceof MembershipKeyImpl.Type6)
                {
		    //如果为多播组为IP6
                    MembershipKeyImpl.Type6 type6 = (MembershipKeyImpl.Type6)membershipkeyimpl;
                    Net.unblock6(fd, type6.groupAddress(), type6.index(), Net.inet6AsByteArray(inetaddress));
                } else
                {
		   //如果为多播组为IP4
                    MembershipKeyImpl.Type4 type4 = (MembershipKeyImpl.Type4)membershipkeyimpl;
                    Net.unblock4(fd, type4.groupAddress(), type4.interfaceAddress(), Net.inet4AsInt(inetaddress));
                }
            }
            catch(IOException ioexception)
            {
                throw new AssertionError(ioexception);
            }
        }
    }

上面方法我们需要关注的是
1.
Net.unblock4(fd, type4.groupAddress(), type4.interfaceAddress(), Net.inet4AsInt(inetaddress));

//Net
static void unblock4(FileDescriptor filedescriptor, int i, int j, int k)
        throws IOException
    {
        blockOrUnblock4(false, filedescriptor, i, j, k);
    }

2.
Net.unblock6(fd, type6.groupAddress(), type6.index(), Net.inet6AsByteArray(inetaddress));

//Net
static void unblock6(FileDescriptor filedescriptor, byte abyte0[], int i, byte abyte1[])
        throws IOException
    {
        blockOrUnblock6(false, filedescriptor, abyte0, i, abyte1);
    }

从上面可以看出阻塞源地址报文与解除源地址报文阻塞,首先检查源地址,再将实际的阻塞与解除阻塞工作委托给Net完成。
再来看drop方法
//drop报文通道多播成员关系key
void drop(MembershipKeyImpl membershipkeyimpl)
    {
label0:
        {
	    //如果断言,开启,则判断多播关系key通道是否为本通道
            if(!$assertionsDisabled && membershipkeyimpl.channel() != this)
                throw new AssertionError();
            synchronized(stateLock)
            {
	        //如果多播成员关系key无效,调到label0
                if(membershipkeyimpl.isValid())
                    break label0;
            }
            return;
        }
        try
        {
            if(membershipkeyimpl instanceof MembershipKeyImpl.Type6)
            {
	        //如果为多播组为IP6
                MembershipKeyImpl.Type6 type6 = (MembershipKeyImpl.Type6)membershipkeyimpl;
                Net.drop6(fd, type6.groupAddress(), type6.index(), type6.source());
            } else
            {
	        //如果为多播组为IP6
                MembershipKeyImpl.Type4 type4 = (MembershipKeyImpl.Type4)membershipkeyimpl;
                Net.drop4(fd, type4.groupAddress(), type4.interfaceAddress(), type4.source());
            }
        }
        catch(IOException ioexception)
        {
            throw new AssertionError(ioexception);
        }
	//使多播成员关系key无效
        membershipkeyimpl.invalidate();
	//从报文通道注册器移除多播成员关系key
        registry.remove(membershipkeyimpl);
        obj;
        JVM INSTR monitorexit ;
          goto _L1
        exception;
        throw exception;
_L1:
    }

drop方法需要关注的为:
1.
Net.drop4(fd, type4.groupAddress(), type4.interfaceAddress(), type4.source());

//Net
static void drop4(FileDescriptor filedescriptor, int i, int j, int k)
        throws IOException
    {
        joinOrDrop4(false, filedescriptor, i, j, k);
    }

    private static native int joinOrDrop4(boolean flag, FileDescriptor filedescriptor, int i, int j, int k)
        throws IOException;

2.
Net.drop6(fd, type6.groupAddress(), type6.index(), type6.source());

//Net
  
 static void drop6(FileDescriptor filedescriptor, byte abyte0[], int i, byte abyte1[])
        throws IOException
    {
        joinOrDrop6(false, filedescriptor, abyte0, i, abyte1);
    }

    private static native int joinOrDrop6(boolean flag, FileDescriptor filedescriptor, byte abyte0[], int i, byte abyte1[])
        throws IOException;

从上面可以看出drop方法,首先判断多播成员关系key是否有效,如果有效,判断多播组为ip4还是ip6,然后委托给Net完成实际的drop工作。

总结:

       join(报文通道加入多播组)方法,首先检查加入的多播组地址是否正确,然后校验源地址,检查多播成员关系注册器中是否存在多播地址为inetaddress,网络接口为networkinterface,源地址为inetaddress1的多播成员关系key,有则直接返回,否则根据网络协议族family,网络接口,源地址构造多播成员关系MembershipKeyImpl,添加到注册器MembershipRegistry。
    阻塞源地址报文与解除源地址报文阻塞,首先检查源地址,再将实际的阻塞与解除阻塞工作委托给Net完成。
    drop方法,首先判断多播成员关系key是否有效,如果有效,判断多播组为ip4还是ip6,然后委托给Net完成实际的drop工作。

DatagramChannelImpl 解析四(地址绑定,关闭通道等):http://donald-draper.iteye.com/blog/2373519
分享到:
评论
3 楼 Donald_Draper 2019-06-18  
Donald_Draper 写道
刘落落cici 写道
能给我发一份这个类的源码吗DatagramChannelImpl
我想看一下 这个recive函数返回的这个发送方address是怎么确定的



https://github.com/Donaldhan/netty



java nio 反编译即可
2 楼 Donald_Draper 2019-05-28  
刘落落cici 写道
能给我发一份这个类的源码吗DatagramChannelImpl
我想看一下 这个recive函数返回的这个发送方address是怎么确定的



https://github.com/Donaldhan/netty
1 楼 刘落落cici 2018-05-23  
能给我发一份这个类的源码吗DatagramChannelImpl
我想看一下 这个recive函数返回的这个发送方address是怎么确定的

相关推荐

    DatagramChannelImpl.rar_java nio

    `DatagramChannelImpl`则是`DatagramChannel`的默认实现类,它实现了相关的底层操作。 `DatagramChannel`接口提供了以下主要功能: 1. **打开和关闭通道**:你可以通过`DatagramChannel.open()`方法创建一个新的`...

    【多智能体控制】基于matlab事件触发多智能体编队控制(含间歇控制)【含Matlab源码 13223期】.zip

    Matlab领域上传的视频是由对应的完整代码运行得来的,完整代码皆可运行,亲测可用,适合小白; 1、从视频里可见完整代码的内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可私信博主; 4.1 博客或资源的完整代码提供 4.2 期刊或参考文献复现 4.3 Matlab程序定制 4.4 科研合作

    《网页制作基础教程(Dreamweaver-CS3)》第11章-嵌入表单元素.ppt

    《网页制作基础教程(Dreamweaver-CS3)》第11章-嵌入表单元素.ppt

    V1_3_example.ipynb

    V1_3_example.ipynb

    《计算机应用基础项目教程》项目四-电子表格软件Excel2010的使用.pptx

    《计算机应用基础项目教程》项目四-电子表格软件Excel2010的使用.pptx

    《计算机系统结构》第4章-指令级并行.ppt

    《计算机系统结构》第4章-指令级并行.ppt

    西门子1200博途三部十层电梯控制系统及WinCC RT Pro界面设计详解

    内容概要:本文详细介绍了基于西门子S7-1200 PLC和WinCC RT Pro的三部十层电梯联控系统的设计与实现。主要内容涵盖硬件配置、核心算法如电梯间协同算法、方向判断函数、状态机设计、呼叫调度算法以及WinCC画面设计中的动画效果和平滑移动实现方法。文中还讨论了常见的调试问题及其解决方案,如方向锁死、编码器干扰等。此外,强调了状态机在电梯控制中的重要性,并提供了具体的代码示例来解释各个功能模块的工作原理。 适合人群:自动化工程师、PLC程序员、HMI开发者、工业控制系统设计师。 使用场景及目标:适用于希望深入了解电梯控制系统设计原理和技术实现的专业人士。目标是帮助读者掌握电梯联控系统的编程技巧,提高对工业控制项目的理解和应用能力。 其他说明:文章不仅提供详细的代码片段,还分享了许多实践经验,有助于读者更好地理解和应对实际工程项目中的挑战。

    飞猫智联u20一键打开adb并安装

    飞猫智联u20一键打开adb并安装

    DeepSeek:智能时代的全面到来和人机协作的新常态.pdf

    DeepSeek:智能时代的全面到来和人机协作的新常态.pdf

    电机控制领域PMSM无传感HFI高频谐波注入与滑模观测器仿真模型解析(基于28035)

    内容概要:本文深入探讨了永磁同步电机(PMSM)无传感器控制技术中的高频谐波注入(HFI)方案及其滑模观测器仿真模型。主要介绍了HFI的工作原理,即通过向电机定子绕组注入高频信号并检测其响应来估算转子位置和速度。文中提供了详细的代码实现,包括高频信号生成、电流检测与处理、滑模观测器核心算法等。此外,还分享了实际工程项目中的调试经验和常见问题解决方案,如参数选择、硬件配置、滤波处理等。 适合人群:从事电机控制系统开发的技术人员,尤其是对PMSM无传感器控制感兴趣的工程师。 使用场景及目标:适用于需要提高PMSM电机控制性能的应用场合,如工业自动化设备、伺服系统等。目标是在低速条件下实现精确的转子位置和速度估算,从而提升系统的整体性能。 其他说明:文章不仅提供了理论和技术细节,还结合了大量实践经验,帮助读者更好地理解和应用HFI技术。同时强调了实际工程中需要注意的各种细节,如参数整定、硬件配置、滤波处理等,确保方案的可靠性和稳定性。

    OAI-10th-Anniversary-Workshop

    5G 6G NR-NTN A Hardware perspective && OAI-10th-Anniversary-Workshop-Qualcomm-2.pdf An SMEs Journey Towards 5G6G NTN Disruptive Technologies Lasting Software--OAI-10th-Anniversary-Workshop-Lasting-Software.pdf Deploying Private 5G with the Open Air Interface- OAI-10th-Anniversary-Workshop-Firecell-.pdf End-to-End Open-Source 5G and O-RAN Prototyping in ARA for Low-Latency Agriculture Applications OAI-10th-Anniversary-Workshop-Iowa-State-University.pdf OAI 5G NR NTN – PHY and MAC Layer Contributions 20240913_Fraunhofer_IIS_OAI_NTN_reduced.pdf Open Source in Telecoms Driving 5G innovatio--OAI-10th-Anniversary-Workshop-Canonical.pdf OpenAirInterface Recent Developments & Roadmap OAI-10th-Anniversary-Workshop-Florian-Kaltenberger.pdf The road of artificial intelligence towards the 6G

    三菱FX2N PLC编码器脉冲数测量距离的技术解析及应用

    内容概要:本文详细介绍了如何使用三菱FX2N系列PLC通过编码器脉冲数计算输出距离的方法。首先,文章阐述了核心思路,即通过采集编码器产生的脉冲数,结合预先设定的脉冲数和输出长度参数,经过一系列浮点数运算得出输出距离。文中展示了详细的代码实现步骤,包括初始化部分、脉冲采集部分、浮点数运算部分和结果处理部分。此外,还讨论了一些常见的调试技巧和注意事项,如数据溢出处理、双编码器校验、方向信号处理等。 适合人群:从事自动化控制领域的工程师和技术人员,尤其是对PLC编程有一定基础的人群。 使用场景及目标:适用于需要精确测量距离的工业控制系统,如输送带系统、机械臂定位等。主要目标是帮助工程师掌握如何利用PLC和编码器实现高精度的距离测量。 其他说明:文章提供了丰富的代码示例和调试建议,有助于读者在实际项目中灵活运用相关技术和解决常见问题。同时强调了浮点运算在提高测量精度方面的优势及其潜在挑战。

    无刷直流电机BLDC转速电流双闭环调速系统的Matlab Simulink仿真研究

    内容概要:本文详细介绍了如何使用Matlab Simulink搭建无刷直流电机(BLDC)的转速电流双闭环调速系统。首先阐述了系统的基本架构,即外层转速环和内层电流环的作用及其相互关系。接着逐步讲解了各个模块的具体实现方法,包括电机模型参数设置、PI控制器参数配置、PWM信号生成、坐标变换等关键技术。通过仿真结果分析,展示了转速和电流响应曲线,探讨了参数调整对系统性能的影响。最终实现了对电机转速的精确控制,并提供了优化建议。 适合人群:从事电机控制领域的工程师和技术人员,尤其是有一定Matlab/Simulink基础的研究人员。 使用场景及目标:适用于希望深入了解BLDC电机控制原理及仿真的技术人员。目标是在理论基础上通过仿真工具掌握双闭环调速系统的构建与优化方法。 其他说明:文中不仅提供了详细的建模步骤,还分享了许多实用的经验技巧,如PI参数选择、PWM生成方式的选择、死区时间设置等,有助于提高实际应用中的系统性能。

    网课搜题 小猿题库多接口微信小程序源码 自带流量主.zip

    多接口小猿题库等综合网课搜题微信小程序源码带流量主,网课搜题小程序, 可以开通流量主赚钱 搭建教程 1, 微信公众平台注册自己的小程序 2, 下载微信开发者工具和小程序的源码 3, 上传代码到自己的小程序

    weixin287火锅店点餐系统的设计与实现+ssm(文档+源码)_kaic

    weixin287火锅店点餐系统的设计与实现+ssm(文档+源码)_kaic

    DotCom Secrets:在线增长策略揭秘

    《DotCom Secrets》是拉斯洛·布劳恩所著的一本关于如何使用在线营销策略来增长公司业务的书籍。本书揭示了在线营销巫师兄弟会不愿公开的秘密,强调了直接响应营销的重要性,并提供了构建和优化营销漏斗的系统方法。书中不仅介绍了如何通过各种在线渠道获取流量、提高转化率和销售,还提供了如何发现目标客户、构建价值阶梯以及如何利用“肥皂剧序列”等策略。拉斯洛·布劳恩通过本书,旨在帮助企业家在充满变数的互联网世界中找到坚实的营销基础。

    基于单片机的智能秤设计(程序+电路+仿真)(51+1602+HX711+10KG+BZ+KEY16)#0415

    包括:源程序工程文件、Proteus仿真工程文件、电路原理图文件、配套技术手册、论文资料等 1、采用51/52单片机(通用)作为主控芯片; 2、采用压力传感器+HX711模块检测压力; 3、可通过按键设置物品单价; 4、采用LCD1602对重量/单价/总价进行显示; 5、当物品超出传感器量程时,蜂鸣器进行过载报警。

    First Word Fall Through FIFO与Standard FIFO对比仿真

    First Word Fall Through FIFO特点是输出端口数据保持有效,读使能有效时即有数据输出。Standard FIFO在读使能有效时,数据一般延时1个时钟周期输出。通过仿真来查看这两种FIFO的特点。

    电力电子领域中二极管箝位型三电平逆变器(NPC)的SVPWM调制与中点电位平衡仿真

    内容概要:本文深入探讨了二极管箝位型三电平逆变器(NPC)的关键技术和挑战,主要包括三电平空间矢量调制(SVPWM)和中点电位平衡调制。SVPWM通过合成参考电压矢量使输出电压接近正弦波,而中点电位平衡则解决因直流侧电容充放电不平衡导致的问题。文中提供了详细的MATLAB代码示例,展示了如何实现这两种调制方法,并介绍了在MATLAB/Simulink中构建仿真模型的具体步骤。此外,文章还讨论了一些实用技巧,如使用坐标变换简化扇区判断、引入滞回比较稳定矢量位置、以及通过预测电流法改善中点电位平衡的动态响应。 适合人群:从事电力电子领域的研究人员和技术人员,尤其是对三电平逆变器有兴趣的工程师。 使用场景及目标:适用于需要深入了解NPC三电平逆变器工作原理的研究人员,帮助他们掌握SVPWM调制和中点电位平衡的技术细节,从而优化逆变器的设计和性能。 其他说明:文章不仅提供了理论分析,还包括大量实际工程中的经验和技巧,有助于读者更好地理解和应用相关技术。

Global site tag (gtag.js) - Google Analytics