Receiving Program

本文介绍了一个涉及从WIP接收批次到库存的过程、不同系统间的库存数据同步(包括Oracle MFG、Reflection和MES等),以及Web版本的简单功能实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.Receive batch from WIP to inventory.

 

2.Synch inventory data amongst different system,such as Oracle MFG,Reflection and MES.

 

3.Web version, simple functions.

 

# SPDX-FileCopyrightText: 2018 Dan Halbert for Adafruit Industries # # SPDX-License-Identifier: MIT """ `Gamepad` ==================================================== * Author(s): Dan Halbert """ import struct import time from adafruit_hid import find_device class Gamepad: """Emulate a generic gamepad controller with 16 buttons, numbered 1-16, and two joysticks, one controlling ``x` and ``y`` values, and the other controlling ``z`` and ``r_z`` (z rotation or ``Rz``) values. The joystick values could be interpreted differently by the receiving program: those are just the names used here. The joystick values are in the range -127 to 127.""" def __init__(self, devices): """Create a Gamepad object that will send USB gamepad HID reports. Devices can be a list of devices that includes a gamepad device or a gamepad device itself. A device is any object that implements ``send_report()``, ``usage_page`` and ``usage``. """ self._gamepad_device = find_device(devices, usage_page=0x1, usage=0x05) # Reuse this bytearray to send mouse reports. # Typically controllers start numbering buttons at 1 rather than 0. # report[0] buttons 1-8 (LSB is button 1) # report[1] buttons 9-16 # report[2] joystick 0 x: -127 to 127 # report[3] joystick 0 y: -127 to 127 # report[4] joystick 1 x: -127 to 127 # report[5] joystick 1 y: -127 to 127 self._report = bytearray(6) # Remember the last report as well, so we can avoid sending # duplicate reports. self._last_report = bytearray(6) # Store settings separately before putting into report. Saves code # especially for buttons. self._buttons_state = 0 self._joy_x = 0 self._joy_y = 0 self._joy_z = 0 self._joy_r_z = 0 # Send an initial report to test if HID device is ready. # If not, wait a bit and try once more. try: self.reset_all() except OSError: time.sleep(1) self.reset_all() def press_buttons(self, *buttons): """Press and hold the given buttons.""" for button in buttons: self._buttons_state |= 1 << self._validate_button_number(button) - 1 self._send() def release_buttons(self, *buttons): """Release the given buttons.""" for button in buttons: self._buttons_state &= ~(1 << self._validate_button_number(button) - 1) self._send() def release_all_buttons(self): """Release all the buttons.""" self._buttons_state = 0 self._send() def click_buttons(self, *buttons): """Press and release the given buttons.""" self.press_buttons(*buttons) self.release_buttons(*buttons) def move_joysticks(self, x=None, y=None, z=None, r_z=None): """Set and send the given joystick values. The joysticks will remain set with the given values until changed One joystick provides ``x`` and ``y`` values, and the other provides ``z`` and ``r_z`` (z rotation). Any values left as ``None`` will not be changed. All values must be in the range -127 to 127 inclusive. Examples:: # Change x and y values only. gp.move_joysticks(x=100, y=-50) # Reset all joystick values to center position. gp.move_joysticks(0, 0, 0, 0) """ if x is not None: self._joy_x = self._validate_joystick_value(x) if y is not None: self._joy_y = self._validate_joystick_value(y) if z is not None: self._joy_z = self._validate_joystick_value(z) if r_z is not None: self._joy_r_z = self._validate_joystick_value(r_z) self._send() def reset_all(self): """Release all buttons and set joysticks to zero.""" self._buttons_state = 0 self._joy_x = 0 self._joy_y = 0 self._joy_z = 0 self._joy_r_z = 0 self._send(always=True) def _send(self, always=False): """Send a report with all the existing settings. If ``always`` is ``False`` (the default), send only if there have been changes. """ struct.pack_into( "<Hbbbb", self._report, 0, self._buttons_state, self._joy_x, self._joy_y, self._joy_z, self._joy_r_z, ) if always or self._last_report != self._report: self._gamepad_device.send_report(self._report) # Remember what we sent, without allocating new storage. self._last_report[:] = self._report @staticmethod def _validate_button_number(button): if not 1 <= button <= 16: raise ValueError("Button number must in range 1 to 16") return button @staticmethod def _validate_joystick_value(value): if not -127 <= value <= 127: raise ValueError("Joystick value must be in range -127 to 127") return value 使用这个库
08-16
``` Makefile compilation parameter description: 1. DEBUG: DEBUG=1: Indicates that the debug program is generated. other value: Indicates that the release program is generated. The default value of DEBUG is 1. 2. HW_VER: HW_VER=0: Indicates that the compiled program is used for fpga version. HW_VER=1: Indicates that the compiled program is used for fpga jtag version. HW_VER=2: Indicates that the compiled program is used for fpga simulation version. HW_VER=3: Indicates that the compiled program is used for asic simulation version. HW_VER=4: Indicates that the compiled program is used for first MPW version. HW_VER=5: Indicates that the compiled program is used for fpga rom version. other value: Not supported. The default value of HW_VER is 4. Description of the main working directory: 1. test: Store the test code. |-ddr_source: store the test code for running in ddr. HW_VER must be 0, 1, 4 when compiling. |-sram_source: store the test code for running in sram. HW_VER must be 0, 1, 4 when compiling. |-sim_source: store the test code for running in the simulation environment. HW_VER must be 2, 3 when compiling. |-fpga_rom_source: store the test code for running in the fpga rom. HW_VER must be 5 when compiling. 2. hal: Store the driver code. 3. romcode: Store the rom code of codetap-out version or FPGA version for receiving, burning, and running the program. 4. tools: Store the bin file processing and merging tools for rom code adaptation. 5. utest: Store utest test programs. 6. linker_scripts: store the link script using for compiling. 7. debug/release: store the compilation.```请解释这段代码
04-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值