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

tmirob-robot-status

v2.1.0

Published

Made with create-react-library

Downloads

104

Readme

tmirob-robot-status

Made with create-react-library

NPM JavaScript Style Guide

Install

npm install --save tmirob-robot-status

Development

  1. cd tmirob-robot-status
  2. yarn install && yarn run start
  3. cd example
  4. yarn install && yarn run start

Usage

api

// robotApi
static getRobotStatusData(robotId) {
		const url = `${Config.serverUrl}rest/details/getRobotSections?serialNo=${robotId}`;
		return getApi(url);
}

demo

import React, {useState, useEffect} from 'react'
import TmirobRobotStatus from 'tmirob-robot-status'
import 'tmirob-robot-status/dist/index.css'
import robotsApi from '../../api/robotsApi'

const TestStatus = (props) => {
  const [robotId, setRobotId] = useState('SN1901B12101')
  const [robotInfo, setRobotInfo] = useState({})
  const [basicInfo, setBasicInfo] = useState({})
  const [pluginInfo, setPluginInfo] = useState({})
  const [funcInfo, setFuncInfo] = useState({})
	const [appStateInfo, setAppStateInfo] = useState({})
  
  const mapStatusData = (statusData) => {
    let resp = {}
    Object.keys(statusData).forEach((key) => {
      let data = statusData[key].map(item => {
        return {
          value: item.status,
          abnormal: item.errorCode !== '',
          abnormalMsg: item.msg
        }
      })
      resp[key] = data
    })
    return resp
  }
  
  const mapAppStateData = (appState) => {
    let resp = {}
    if(!isEmpty(appState)){
      Object.keys(appState).forEach((key) => {
        let data = appState[key].map(item => {
          return {
            value: item.msg,
            abnormal: item.status === 'error',
            abnormalMsg: ''
          }
        })
        resp[key] = data
      })
    }
    return resp
  }
  useEffect(() => {
    robotsApi.getRobotStatusData(robotId).then(res => {
      if(res.retval === 0) {
        const {basic_status, funtion_status,peripherals_status, Status } = res.result
        const {robot_id,robotType,current_floor,current_position,collision,is_offline, ...basicRest} = basic_status
        setRobotInfo({
          robot_id: robot_id[0].status,
          robotType: robotType[0].status,
          current_floor: current_floor[0].status,
          current_position: current_position[0].status,
          is_crash: collision[0].status,
          is_offline: is_offline[0].status,
        })
        
        let basicData = mapStatusData(basicRest)
        basicData['battery_level'][0]['charging'] = basicRest.charging[0].status
        basicData['rssi'][0]['ssid'] = basicRest.wifi_ssid[0].status
        setBasicInfo(basicData)
        let pluginData = mapStatusData(peripherals_status)
        setPluginInfo(pluginData)
        let moduleData = mapStatusData(funtion_status)
        setFuncInfo(moduleData)
        let stateData = mapAppStateData(Status)
        setAppStateInfo(stateData)
      }
    })
  },[robotId])
  return (
    <TmirobRobotStatus 
      goBack={() => console.log('goBack')}
      robotInfo={robotInfo}
      basicInfo={basicInfo}
      pluginInfo={pluginInfo}
      funcInfo={funcInfo}
      appStateInfo={appStateInfo}
    />
  )
}
export default TestStatus

Props

  • robotInfo
 const robotInfo = {
    robot_id: 'SN1901B12101',
    robotType: 'IdentityRobot',
    current_floor: '第二层',
    current_position: '1.0,2.0,2.3',
    is_crash: 'true',
    is_offline: 'false',
  }
  • basicInfo
const basicInfo = {
    emergency_stop: [{
      value: 'normal',
      abnormal: false,
      abnormalMsg: 'emergency stopped'
    }],
    paused: [{
      value: 'normal',
      abnormal: true,
      abnormalMsg: '机器人被暂停'
    }],
    control_mode: [{
      value: 'self_nav',
      abnormal: false,
      abnormalMsg: ''
    }],
    slave_connection: [{
      value: 'normal',
      abnormal: true,
      abnormalMsg: '无法连接从机'
    }],
  	// charging
    battery_level: [{
      charging: false,
      value: '3',
      abnormal: true,
      abnormalMsg: '电量过低'
    }],
    charge_current: [{
      value: '1000',
      abnormal: false,
      abnormalMsg: ''
    }],
    discharge_current: [{
      value: '1000',
      abnormal: false,
      abnormalMsg: ''
    }],
    cpu_occupation: [{
      value: '95',
      abnormal: true,
      abnormalMsg: 'CPU占用率过高'
    }],
  	// ssid
    rssi: [{
      value: '3',
      ssid: 'tmirob-5G',
      abnormal: true,
      abnormalMsg: '无线信号强度过低'
    }],
    linear_velocity: [{
      value: '5.5',
      abnormal: false,
      abnormalMsg: ''
    }],
    cpu_temperature: [{
      value: '70',
      abnormal: true,
      abnormalMsg: 'CPU占用率过高'
    }],
  }
  • pluginInfo
const pluginInfo = {
    lidar: [{
      value: 'normal',
      abnormal: false,
      abnormalMsg: ''
    }],
    motor_control_driver: [{
      // 同上,省略...
    }],
    agv_serial_board: [{
     	// ...
    }],
    main_control: [{
      // ...
    }],
    sensor_driver: [{
      // ...
    }],
    power_manager: [{
       // ...
    }],
    auto_charging_ir: [{
       // ...
    }],
    disinfecting_driver: [{
       // ...
    }],
    motor_adapter: [{
       // ...
    }],
    realsense: [{
      value: 'normal',
      abnormal: false,
      abnormalMsg: ''
    },{
      value: 'normal',
      abnormal: false,
      abnormalMsg: ''
    }]
  }
  • appStateInfo / funcInfo
const funcInfo = {
    localization: [{
      value: 'normal',
      abnormal: false,
      abnormalMsg: ''
    }],
    navigation: [{
      // 同上,省略...
    }],
    map_server: [{
      // ...
    }]
  }

Tips

  • 机器人离线时显示的状态数据是最近一次的状态
  • basicInfo下的机器人电量battery_level不只表示当前电量,还会显示是否为充电状态,由basic_status里的battery_levelcharging共同控制。
  • basicInfo下的wifi状态rssi不只表示 WiFi 强度(由basic_status里的rssi值决定),同时还可以显示 WiFi 名称(由basic_status里的wifi_ssid值决定)。