npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kl-ins

v1.1.3

Published

```bash npm install kl-ins ```

Downloads

147

Readme

kl-ins

一、安装

npm install kl-ins

二、用法

import { ClientProxy, MoveIns, ReportData } from "kl-ins";

const proxy = new ClientProxy("测试客户端", "127.0.0.1", 7777);
proxy.setReportDataHandler(async ({ modNum, insNum, data }: ReportData) => {
  // 处理主动上报数据
});
(async () => {
  await proxy.connect();
  const moveIns = new MoveIns([
    {
      axisNum: 1,
      speed: 99.99,
      dest: 100.01,
      isRelative: true,
    },
  ]);
  console.log("mock返回数据:", moveIns.mockRespData());
  const res = await proxy.sendIns(moveIns);
  console.log("解析返回数据:", res);
})();

三、指令集

  1. 轴控制
  • EnumAxisIns(枚举有效轴号指令)
new EnumAxisIns();
  • HomeIns(复位回零指令)
new HomeIns(axisList: number[]);
  • JogStartIns(手动示教移动开始指令)
new JogStartIns(axisNum: number, speed: number, direction: number);
  • JogStopIns(手动示教移动停止指令)
new JogStopIns(axisNum: number);
  • MoveIns(运动指令)
new MoveIns(moveItemInfoList: [{
    axisNum: number,
    speed: number,
    dest: number,
    isRelative: boolean
}]
  • GetPosIns(获取轴速与位置指令)
new GetPosIns(axisList: number[]);
  1. IO 控制

  2. 周期性包

四、自定义指令

  1. 同步指令
import { SyncIns, Timeout } from "kl-ins";

// 同步方法需要使用Timeout注解,并传入超时时长,单位为毫秒
@Timeout(2_000)
class YourIns extends SyncIns {
  public static readonly NAME = "你的指令名称";
  public static readonly MOD_NUM = 1; //  模块号
  public static readonly INS_NUM = 1; // 指令号,同一模块指令号需保证唯一

  protected getPayload(): number[] {
    // 你需要实现这个方法,返回payload数组
  }

  public parseRespData(data: number[] | Buffer): any {
    // 你需要实现这个方法,返回解析后的结果
  }
}
  1. 异步指令
import { Ins } from "kl-ins";

class YourIns extends Ins {
  public static readonly NAME = "你的指令名称";
  public static readonly MOD_NUM = 1; //  模块号
  public static readonly INS_NUM = 1; // 指令号,同一模块指令号需保证唯一

  protected getPayload(): number[] {
    // 你需要实现这个方法,返回payload数组
    return [];
  }
}

五、备注

  1. 本工具包使用了装饰器特性,需要在tsconfig.json中打开装饰器设置,设置如下:
{
  "compilerOptions": {
    "target": "ES2020",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}