.netcore TSC打印机打印

news2024/9/23 6:34:35

此文章给出两种打印案例,

第一种是单列打印,第二种是双列打印

需要注意打印机名称的设置,程序中使用的打印机名称为999,电脑中安装打印机时名称也要为999。

以下是我在使用过程中总结的一些问题:

一 TSC打印机使用使用过程中遇到的问题

1、打印机刚连上就报警。

一般是纸张或色带安装有问题,纸张要放到档杆的下方。

2、打印机显示正常,DiagTool工具无法连接到打印机,无论点什么都提示“Port Open Error”。

如果使用USB模式,需要用线把打印机和电脑连接起来,同时打印机需插上网线。工具中,通讯接口选择USB,点击“读取状态”,正常显示待机中,点击“读取”,会重置工具中的各参数。

点击“网络设定”,指定IP地址,这里设置为192.168.50.222

如果用服务器连接打印机,这个时候已经添加了打印机,登录服务器,找到打印机,打开打印机属性-端口,打印机名称或ip地址设置为与打印机ip一致即可。

3、打印机打印完成后报警。

检查纸张,纸张安装过紧或档条没压住纸,都会导致此问题。

接下来上代码

二 打印方式

2.1 单列打印

这种打印方式示例中,打印的位置是可以配置的

using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Imagine.Mes.MesTrackV3.Application.CommonTool;
using Imagine.Mes.MesTrackV3.Application.Dtos;
using Volo.Abp.DependencyInjection;
using Newtonsoft.Json;
using System.IO;
using Newtonsoft.Json.Linq;

namespace Imagine.Mes.MesTrackV3.Application.Services
{
    /// <summary>
    /// 打印服务
    /// </summary>
    public interface IPrintService
    {
        /// <summary>
        /// 打印流程卡
        /// </summary>
        /// <param name="printType">打印枚举 0-二维码;1-条形码</param>
        /// <param name="body">流程卡集合</param>
        /// <returns></returns>
        Task PrintLotAsync(PrintEnum printType, List<PrintLotInDto> body);
    }
    public class PrintService : IPrintService,IScopedDependency
    {
        private readonly ILogger<PrintService> _logger;

        public PrintService(ILogger<PrintService> logger)
        {
            _logger = logger;
        }

        #region 打印流程卡
        /// <summary>
        /// 打印流程卡
        /// </summary>
        /// <param name="printType">打印枚举 0-二维码;1-条形码</param>
        /// <param name="body">流程卡集合</param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public async Task PrintLotAsync(PrintEnum printType, List<PrintLotInDto> body)
        {
            try
            {
                List<PrintLotInDto> printOutboundOrderList = new List<PrintLotInDto>();
                var jsonObject=await GetJsonFileAsync("CommonTool\\PrintLot.json");

                for (int i = 0; i < body.Count; i++)
                {
                    await PrintLotAsync(printType,jsonObject, new PrintLotInDto
                    {
                        LotNo = body[i].LotNo,
                        ProductCode = body[i].ProductCode,
                        ProductName = body[i].ProductName,
                        Quantity = body[i].Quantity,
                        WorkOrderNo = body[i].WorkOrderNo,
                        UnitName= body[i].UnitName
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"打印流程卡错误:{ex}");
                throw new Exception($"打印流程卡错误:{ex.Message}");
            }
        }
        /// <summary>
        /// 打印流程卡
        /// </summary>
        /// <param name="printType">打印类型:0-二维码;1-条形码</param>
        /// <param name="jsonObject"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        private async Task PrintLotAsync(PrintEnum printType, JObject jsonObject, PrintLotInDto param)
        {
            #region 模板
            string port = "999";
            string currentEncoding = "utf-16";
            string chineseFont = "宋体";

            byte[] lotNo = Encoding.GetEncoding(currentEncoding).GetBytes($"批 次 号:{param.LotNo}");
            byte[] productCode = Encoding.GetEncoding(currentEncoding).GetBytes($"产品编码:{param.ProductCode}");
            byte[] productName = Encoding.GetEncoding(currentEncoding).GetBytes($"产品名称:{param.ProductName}");
            byte[] quantity = Encoding.GetEncoding(currentEncoding).GetBytes($"数    量:{param.Quantity} {param.UnitName}");
            byte[] workOrderNo = Encoding.GetEncoding(currentEncoding).GetBytes($"工 单 号:{param.WorkOrderNo}");
            byte[] date = Encoding.GetEncoding(currentEncoding).GetBytes($"打印日期:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");

            byte status = TSCLIB_DLL.usbportqueryprinter();//0 = idle, 1 = head open, 16 = pause, following <ESC>!? command of TSPL manual
            //打印机共享名999
            int openport = TSCLIB_DLL.openport(@$"{port}");
            //M 纸张宽度  ,N 纸张高度
            TSCLIB_DLL.sendcommand("SIZE 100 mm, 80 mm");
            TSCLIB_DLL.sendcommand("SPEED 4");
            TSCLIB_DLL.sendcommand("DENSITY 12");
            TSCLIB_DLL.sendcommand("DIRECTION 1");
            TSCLIB_DLL.sendcommand("SET TEAR ON");
            TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");
            TSCLIB_DLL.clearbuffer();

            if (printType == PrintEnum.QRCode)//打印二维码
            {
                //文字(x边距,y边距,字体高度,旋转,字体样式,下划线,字体,文字内容)
                TSCLIB_DLL.windowsfontUnicode(Convert.ToInt32(jsonObject["lotNo"]["x"]), Convert.ToInt32(jsonObject["lotNo"]["y"]), Convert.ToInt32(jsonObject["lotNo"]["size"]), 0, 0, 0, chineseFont, lotNo);
                TSCLIB_DLL.windowsfontUnicode(Convert.ToInt32(jsonObject["productCode"]["x"]), Convert.ToInt32(jsonObject["productCode"]["y"]), Convert.ToInt32(jsonObject["productCode"]["size"]), 0, 0, 0, chineseFont, productCode);
                TSCLIB_DLL.windowsfontUnicode(Convert.ToInt32(jsonObject["productName"]["x"]), Convert.ToInt32(jsonObject["productName"]["y"]), Convert.ToInt32(jsonObject["productName"]["size"]), 0, 0, 0, chineseFont, productName);
                TSCLIB_DLL.windowsfontUnicode(Convert.ToInt32(jsonObject["quantity"]["x"]), Convert.ToInt32(jsonObject["quantity"]["y"]), Convert.ToInt32(jsonObject["quantity"]["size"]), 0, 0, 0, chineseFont, quantity);
                TSCLIB_DLL.windowsfontUnicode(Convert.ToInt32(jsonObject["workOrderNo"]["x"]), Convert.ToInt32(jsonObject["workOrderNo"]["y"]), Convert.ToInt32(jsonObject["workOrderNo"]["size"]), 0, 0, 0, chineseFont, workOrderNo);
                TSCLIB_DLL.windowsfontUnicode(Convert.ToInt32(jsonObject["date"]["x"]), Convert.ToInt32(jsonObject["date"]["y"]), Convert.ToInt32(jsonObject["date"]["size"]), 0, 0, 0, chineseFont, date);
                //二维码
                //QRCODE x,y,ECC Level,cell width(二维码大小),mode,rotation(旋转),[model,mask,]"content"
                TSCLIB_DLL.sendcommand($"QRCODE {Convert.ToInt32(jsonObject["qRCode"]["x"])},{Convert.ToInt32(jsonObject["qRCode"]["y"])},H,{Convert.ToInt32(jsonObject["qRCode"]["size"])},A,0,M2,\"{param.LotNo}\"");
            }
            else// 打印条码.
            {
                // 在 (450, 200) 的坐标上
                // 以 Code128 的条码方式
                // 条码高度 300
                // 打印条码的同时,还打印条码的文本信息.
                // 旋转的角度为 0 度
                // 条码 宽 窄 比例因子为 7:7
                // 条码内容为:barCode
                //BARCODE X,Y,”code type”,height,human readable,rotation,narrow,wide,[alignment,]”content“
                TSCLIB_DLL.barcode("30", "30", "128", "180", "1", "0", "6", "6", $"{param.LotNo}");
            }

            //TSCLIB_DLL.sendcommand(String.Format("QRCODE 740,320,H,8,A,0,M2,\"{0}\"", trayCode));
            //DMATRIX码  。DMATRIX 命令,740,320,90,90  指定 X 坐标,指定 Y 坐标,条码区域宽度
            //TSCLIB_DLL.sendcommand($"DMATRIX 740,320,90,90,x18,30,30,\"{trayCode}\"");
            int printlabel = TSCLIB_DLL.printlabel("1", "1");
            TSCLIB_DLL.closeport();
            #endregion
            await Task.CompletedTask;
        }
        #endregion 打印流程卡

        #region 获取json文件内容
        private async Task<JObject> GetJsonFileAsync(string path)
        {
            try
            {
                // 获取文件的绝对路径
                string filePath = Path.Combine(AppContext.BaseDirectory, path);
                string jsonContent = string.Empty;//json内容
                var exists = System.IO.File.Exists(filePath);
                if (!exists) throw new Exception($"配置文件[{path.Split("\\")[path.Split("\\").Length - 1]}]不存在");
                // 读取文件的内容
                using (StreamReader file = File.OpenText(filePath))
                {
                    jsonContent = await file.ReadToEndAsync();
                }
                // 解析JSON到JObject
                JObject jsonObj = JObject.Parse(jsonContent);
                // 反序列化
              //var plcModel = JsonConvert.DeserializeObject<List<PLCModel>>(jsonContent);
                return jsonObj;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString(), ex);
                throw new Exception(ex.Message);
            }
        }
        #endregion
    }
}
/// <summary>
/// 打印流程卡
/// </summary>
public class PrintLotInDto
{
    /// <summary>
    /// 批次号
    /// </summary>
    public string LotNo {  get; set; }
    /// <summary>
    /// 产品名称
    /// </summary>
    public string ProductName {  get; set; }
    /// <summary>
    /// 产品编码
    /// </summary>
    public string ProductCode { get; set; }
    /// <summary>
    /// 数量
    /// </summary>
    public int Quantity {  get; set; }
    /// <summary>
    /// 工单号
    /// </summary>
    public string WorkOrderNo {  get; set; }
    / <summary>
    / 打印日期
    / </summary>
    //public DateTime Date { get; set; }
    /// <summary>
    /// 单位名称
    /// </summary>
    public string UnitName {  get; set; }
}

/// <summary>
/// 打印枚举
/// </summary>
public enum PrintEnum
{
    QRCode = 0,//二维码
    BarCode = 1//条形码
}

PrintLot.json文件内容

{
  //批次号
  "lotNo": {
    "x": 430, //x坐标
    "y": 320, //y坐标
    "size": 50 //字体大小
  },
  //产品编码
  "productCode": {
    "x": 230,
    "y": 400,
    "size": 50
  },
  //产品名称
  "productName": {
    "x": 230,
    "y": 480,
    "size": 50
  },
  //数量
  "quantity": {
    "x": 230,
    "y": 560,
    "size": 50
  },
  //工单号
  "workOrderNo": {
    "x": 230,
    "y": 640,
    "size": 50
  },
  //打印日期
  "date": {
    "x": 230,
    "y": 720,
    "size": 50
  },
  //二维码
  "qRCode": {
    "x": 450,
    "y": 30,
    "size": 10 //二维码大小
  }
}

2.2 双列打印

using Imagine.Mes.MesBase.Application.CommonTool;
using Imagine.Mes.MesBase.Application.Dtos;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;

namespace Imagine.Mes.MesBase.Application.Services
{
    public interface IPrintService
    {
        /// <summary>
        /// 打印库位信息
        /// </summary>
        /// <param name="printType"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        Task PrintWarehouselocationsAsync(PrintTypeEnum printType, List<WarehouseLocationNoParam> body);
    }

    public class PrintService : IPrintService, ITransientDependency
    {
        private readonly ILogger<PrintService> _logger;

        public PrintService(
            ILogger<PrintService> logger
            )
        {
            _logger = logger;
        }

        public async Task PrintWarehouselocationsAsync(PrintTypeEnum printType, List<WarehouseLocationNoParam> body)
        {
            try
            {
                List<PrintWarehouseLocationParam> printQualityInspectionList = new List<PrintWarehouseLocationParam>();

                for (int i = 0; i < body.Count; i += 2)
                {
                    PrintWarehouseLocationParam printQualityInspection = new PrintWarehouseLocationParam();
                    printQualityInspection.QRCodeContent = body[i].QRCodeContent;
                    printQualityInspection.WarehouseLocationName = body[i].WarehouseLocationName;
                    printQualityInspection.WarehouseLocationNo = body[i].WarehouseLocationNo;
                    printQualityInspection.QRCodeContent2 = i + 1 < body.Count ? body[i + 1].QRCodeContent : null;
                    printQualityInspection.WarehouseLocationName2 = i + 1 < body.Count ? body[i + 1].WarehouseLocationName : null;
                    printQualityInspection.WarehouseLocationNo2 = i + 1 < body.Count ? body[i + 1].WarehouseLocationNo : null;

                    printQualityInspectionList.Add(printQualityInspection);

                    await PrintWarehouselocationAsync(printType, new PrintWarehouseLocationParam
                    {
                        QRCodeContent = printQualityInspection.QRCodeContent,
                        WarehouseLocationName = printQualityInspection.WarehouseLocationName,
                        WarehouseLocationNo = printQualityInspection.WarehouseLocationNo,
                        QRCodeContent2 = printQualityInspection.QRCodeContent2,
                        WarehouseLocationName2 = printQualityInspection.WarehouseLocationName2,
                        WarehouseLocationNo2 = printQualityInspection.WarehouseLocationNo2
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"打印质检单/入库单错误:{ex}");
            }
        }

        /// <summary>
        /// 打印出库单/入库单
        /// </summary>
        /// <param name="printType">打印类型:0-二维码;1-条形码</param>
        /// <param name="param"></param>
        /// <returns></returns>
        private async Task PrintWarehouselocationAsync(PrintTypeEnum printType, PrintWarehouseLocationParam param)
        {
            #region 模板
            string port = "999";
            string currentEncoding = "utf-16";
            string chineseFont = "宋体";

            byte[] warehouseLocationNo = null;
            byte[] warehouseLocationName = null;
            byte[] warehouseLocationNo2 = null;
            byte[] warehouseLocationName2 = null;


            warehouseLocationNo = Encoding.GetEncoding(currentEncoding).GetBytes($"{param.WarehouseLocationNo}");
            warehouseLocationName = Encoding.GetEncoding(currentEncoding).GetBytes($"{param.WarehouseLocationName}");

            warehouseLocationNo2 = Encoding.GetEncoding(currentEncoding).GetBytes($"{param.WarehouseLocationNo2}");
            warehouseLocationName2 = Encoding.GetEncoding(currentEncoding).GetBytes($"{param.WarehouseLocationName2}");

            byte status = TSCLIB_DLL.usbportqueryprinter();//0 = idle, 1 = head open, 16 = pause, following <ESC>!? command of TSPL manual
            //打印机共享名999
            int openport = TSCLIB_DLL.openport(@$"{port}");
            //M 纸张宽度  ,N 纸张高度
            TSCLIB_DLL.sendcommand("SIZE 100 mm, 30 mm");
            TSCLIB_DLL.sendcommand("SPEED 2");
            TSCLIB_DLL.sendcommand("DENSITY 15");
            TSCLIB_DLL.sendcommand("DIRECTION 1");
            TSCLIB_DLL.sendcommand("SET TEAR ON");
            TSCLIB_DLL.sendcommand("CODEPAGE UTF-8");
            TSCLIB_DLL.clearbuffer();

            if (printType == PrintTypeEnum.QRCode)//打印二维码
            {
                TSCLIB_DLL.windowsfontUnicode(150, 20, 26, 0, 0, 0, chineseFont, warehouseLocationName);
                TSCLIB_DLL.sendcommand($"QRCODE 180,55,H,5,A,0,M2,\"{param.QRCodeContent}\"");
                TSCLIB_DLL.windowsfontUnicode(150, 180, 26, 0, 0, 0, chineseFont, warehouseLocationNo);

                if (!string.IsNullOrWhiteSpace(param.QRCodeContent2))
                {
                    TSCLIB_DLL.windowsfontUnicode(550, 20, 26, 0, 0, 0, chineseFont, warehouseLocationName2);
                    TSCLIB_DLL.sendcommand($"QRCODE 580,55,H,5,A,0,M2,\"{param.QRCodeContent2}\"");
                    TSCLIB_DLL.windowsfontUnicode(550, 180, 26, 0, 0, 0, chineseFont, warehouseLocationNo2);
                }
            }
            else// 打印条码.
            {
                // 在 (450, 200) 的坐标上
                // 以 Code128 的条码方式
                // 条码高度 300
                // 打印条码的同时,还打印条码的文本信息.
                // 旋转的角度为 0 度
                // 条码 宽 窄 比例因子为 7:7
                // 条码内容为:barCode
                //BARCODE X,Y,”code type”,height,human readable,rotation,narrow,wide,[alignment,]”content“
                TSCLIB_DLL.barcode("300", "340", "128", "180", "1", "0", "6", "6", $"{param.QRCodeContent2}");
            }

            //TSCLIB_DLL.sendcommand(String.Format("QRCODE 740,320,H,8,A,0,M2,\"{0}\"", trayCode));
            //DMATRIX码  。DMATRIX 命令,740,320,90,90  指定 X 坐标,指定 Y 坐标,条码区域宽度
            //TSCLIB_DLL.sendcommand($"DMATRIX 740,320,90,90,x18,30,30,\"{trayCode}\"");
            int printlabel = TSCLIB_DLL.printlabel("1", "1");
            TSCLIB_DLL.closeport();
            #endregion
            await Task.CompletedTask;
        }
    }

    /// <summary>
    /// 打印枚举
    /// </summary>
    public enum PrintTypeEnum
    {
        QRCode = 0,//二维码
        BarCode = 1//条形码
    }
}

/// <summary>
/// 库位码打印参数
/// </summary>
public class WarehouseLocationNoParam
{
    /// <summary>
    /// 二维码内容
    /// </summary>
    public string QRCodeContent { get; set; }
    /// <summary>
    /// 库位名称
    /// </summary>
    public string WarehouseLocationName { get; set; }
    /// <summary>
    /// 库位编码
    /// </summary>
    public string WarehouseLocationNo { get; set; }
}
/// <summary>
/// 库位码打印参数
/// </summary>
public class PrintWarehouseLocationParam
{
    /// <summary>
    /// 二维码内容
    /// </summary>
    public string QRCodeContent { get; set; }
    /// <summary>
    /// 库位名称
    /// </summary>
    public string WarehouseLocationName { get; set; }
    /// <summary>
    /// 库位编码
    /// </summary>
    public string WarehouseLocationNo { get; set; }
    /// <summary>
    /// 二维码内容2
    /// </summary>
    public string QRCodeContent2 { get; set; }
    /// <summary>
    /// 库位名称2
    /// </summary>
    public string WarehouseLocationName2 { get; set; }
    /// <summary>
    /// 库位编码2
    /// </summary>
    public string WarehouseLocationNo2 { get; set; }
}

2.3 用到的公共类

using System.Runtime.InteropServices;

namespace Imagine.Mes.MesBase.Application.CommonTool
{
    public class TSCLIB_DLL
    {
        [DllImport("TSCLIB.dll", EntryPoint = "about")]
        public static extern int about();

        [DllImport("TSCLIB.dll", EntryPoint = "openport")]
        public static extern int openport(string printername);

        [DllImport("TSCLIB.dll", EntryPoint = "barcode")]
        public static extern int barcode(string x, string y, string type,
                    string height, string readable, string rotation,
                    string narrow, string wide, string code);

        [DllImport("TSCLIB.dll", EntryPoint = "clearbuffer")]
        public static extern int clearbuffer();

        [DllImport("TSCLIB.dll", EntryPoint = "closeport")]
        public static extern int closeport();

        [DllImport("TSCLIB.dll", EntryPoint = "downloadpcx")]
        public static extern int downloadpcx(string filename, string image_name);

        [DllImport("TSCLIB.dll", EntryPoint = "formfeed")]
        public static extern int formfeed();

        [DllImport("TSCLIB.dll", EntryPoint = "nobackfeed")]
        public static extern int nobackfeed();

        [DllImport("TSCLIB.dll", EntryPoint = "printerfont")]
        public static extern int printerfont(string x, string y, string fonttype,
                        string rotation, string xmul, string ymul,
                        string text);

        [DllImport("TSCLIB.dll", EntryPoint = "printlabel")]
        public static extern int printlabel(string set, string copy);

        [DllImport("TSCLIB.dll", EntryPoint = "sendcommand")]
        public static extern int sendcommand(string printercommand);

        [DllImport("TSCLIB.dll", EntryPoint = "setup")]
        public static extern int setup(string width, string height,
                  string speed, string density,
                  string sensor, string vertical,
                  string offset);

        [DllImport("TSCLIB.dll", EntryPoint = "windowsfont")]
        public static extern int windowsfont(int x, int y, int fontheight,
                        int rotation, int fontstyle, int fontunderline,
                        string szFaceName, string content);
        [DllImport("TSCLIB.dll", EntryPoint = "windowsfontUnicode")]
        public static extern int windowsfontUnicode(int x, int y, int fontheight,
                         int rotation, int fontstyle, int fontunderline,
                         string szFaceName, byte[] content);

        [DllImport("TSCLIB.dll", EntryPoint = "sendBinaryData")]
        public static extern int sendBinaryData(byte[] content, int length);

        [DllImport("TSCLIB.dll", EntryPoint = "usbportqueryprinter")]
        public static extern byte usbportqueryprinter();
    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1942952.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

谷粒商城实战笔记-跨域问题

一&#xff0c;When allowCredentials is true, allowedOrigins cannot contain the special value “*” since that cannot be set on the “Access-Control-Allow-Origin” response header. To allow credentials to a set of origins, list them explicitly or consider u…

PostgreSQL 中如何处理数据的唯一性约束?

&#x1f345;关注博主&#x1f397;️ 带你畅游技术世界&#xff0c;不错过每一次成长机会&#xff01;&#x1f4da;领书&#xff1a;PostgreSQL 入门到精通.pdf 文章目录 PostgreSQL 中如何处理数据的唯一性约束&#xff1f;一、什么是唯一性约束二、为什么要设置唯一性约束…

基于A律压缩的PCM脉冲编码调制通信系统simulink建模与仿真

目录 1.算法运行效果图预览 2.算法运行软件版本 3.部分核心程序 4.算法理论概述 4.1A律压缩的原理 4.2 PCM编码过程 4.3 量化噪声与信噪比 5.算法完整程序工程 1.算法运行效果图预览 (完整程序运行后无水印) 2.算法运行软件版本 matlab2022a 3.部分核心程序 &#…

Atom - hackmyvm

简介 靶机名称&#xff1a;Atom 难度&#xff1a;简单 靶场地址&#xff1a;https://hackmyvm.eu/machines/machine.php?vmAtom 本地环境 虚拟机&#xff1a;vitual box 靶场IP&#xff08;Atom&#xff09;&#xff1a;192.168.56.101 跳板机IP(windows 11)&#xff1…

MySQL面试篇章——MySQL索引

文章目录 MySQL 索引索引分类索引创建和删除索引的执行过程explain 查看执行计划explain 结果字段分析 索引的底层实现原理B-树B树哈希索引 聚集和非聚集索引MyISAM&#xff08;\*.MYD&#xff0c;*.MYI&#xff09;主键索引辅助索引&#xff08;二级索引&#xff09; InnoDB&a…

线程的中互斥锁和条件变量的运用

第一题&#xff1a;使用互斥锁或者信号量&#xff0c;实现一个简单的生产者消费者模型 一个线程每秒生产3个苹果&#xff0c;另一个线程每秒消费8个苹果 #include <myhead.h>pthread_mutex_t m1,m2;int apple 0; void* usrapp(void* data) {while(1){pthread_mutex_lock…

旋转差分,以及曼哈顿距离转换切比雪夫距离

拿到这个问题我们要怎么去想呢&#xff0c;如果是暴力的修改的话&#xff0c;我们的复杂度为 m * 2r*r 的复杂度&#xff0c;这也太暴力了&#xff0c;我们要怎么办呢&#xff0c;我们能不能用差分数组来实现呢&#xff1f; 我们首先要看如何实现公式的转换 很显然我们可以利用…

<数据集>pcb板缺陷检测数据集<目标检测>

数据集格式&#xff1a;VOCYOLO格式 图片数量&#xff1a;693张 标注数量(xml文件个数)&#xff1a;693 标注数量(txt文件个数)&#xff1a;693 标注类别数&#xff1a;6 标注类别名称&#xff1a;[missing_hole, mouse_bite, open_circuit, short, spurious_copper, spur…

物联网与区块链技术的跨界融合:智能城市的建设与管理

随着科技的迅猛发展&#xff0c;物联网&#xff08;IoT&#xff09;和区块链技术逐渐成为推动智能城市发展的重要技术支柱。本文将探讨物联网和区块链技术在智能城市建设与管理中的跨界融合&#xff0c;分析其应用场景和潜力。 什么是智能城市&#xff1f; 智能城市利用先进的…

(35)远程识别(又称无人机识别)(一)

文章目录 前言 1 更改 2 可用的设备 3 开放式无人机ID 4 ArduRemoteID 5 终端用户数据的设置和使用 6 测试 7 为OEMs添加远程ID到ArduPilot系统的视频教程 前言 在一些国家&#xff0c;远程 ID 正在成为一项法律要求。以下是与 ArduPilot 兼容的设备列表。这里(here)有…

深度刨析C语言中的动态内存管理

文章目录 1.为什么会存在动态内存分配2.动态内存函数介绍2.1 [malloc](https://legacy.cplusplus.com/reference/cstdlib/malloc/?kwmalloc)与[free](https://legacy.cplusplus.com/reference/cstdlib/free/?kwfree)2.2 [calloc](https://legacy.cplusplus.com/reference/cst…

Redis - SpringDataRedis - RedisTemplate

目录 概述 创建项目 引入依赖 配置文件 测试代码 测试结果 数据序列化器 自定义RedisTemplate的序列化方式 测试报错 添加依赖后测试 存入一个 String 类型的数据 测试存入一个对象 优化 -- 手动序列化 测试存入一个Hash 总结&#xff1a; 概述 SpringData 是 S…

浏览器【WebKit内核】渲染原理【QUESTION-1】

浏览器【WebKit内核】渲染原理【QUESTION】 1.浏览器输入一个网址&#xff08;域名之后&#xff09;,浏览器会呈现一个新的页面&#xff0c;中间的过程是怎么实现的&#xff1f; 输入一个网址之后&#xff0c;首先DNS服务器会解析这个域名&#xff0c;将这个域名解析成IP地址&…

SAP 贷项销售订单简介

SAP 贷项销售订单简介 1. 什么是销售贷方销售订单?2. 创建销售贷方销售订单的场景3. 销售贷方销售订单的创建流程直接创建发票---VF01将会计凭证过账到会计核算查看贷项销售订单凭证流查看客户明细---FBL5N贷项后台配置SAP销售贷方销售订单(Sales Credit Memo Request)是销售…

北醒单点激光雷达更改id和波特率以及Ubuntu20.04下CAN驱动

序言&#xff1a; 需要的硬件以及软件 1、USB-CAN分析仪使用顶配pro版本&#xff0c;带有支持ubuntu下的驱动包的&#xff0c;可以读取数据。 2、电源自备24V电源 3、单点激光雷达接线使用can线可以组网。 一、更改北醒单点激光雷达的id号和波特率 安装并运行USB-CAN分析仪自带…

pdf压缩在线免费 pdf压缩在线免费网页版 在线pdf压缩在线免费 pdf压缩工具在线免费

在数字化时代&#xff0c;pdf文件已经成为我们工作、学习和生活中的重要组成部分。然而&#xff0c;体积庞大的pdf文件往往给我们的存储空间、传输速度带来不小的压力。本文将为您揭秘几种简单有效的pdf文件压缩方法&#xff0c;让您轻松应对文件体积过大带来的困扰。 方法一、…

C++从入门到起飞之——const成员函数Date类实现 全方位剖析!

&#x1f308;个人主页&#xff1a;秋风起&#xff0c;再归来~&#x1f525;系列专栏&#xff1a;C从入门到起飞 &#x1f516;克心守己&#xff0c;律己则安 代码链接&#xff1a;这篇文章代码的所有代码都在我的gitee仓库里面啦&#xff0c;需要的小伙伴点击自取哦…

【论文解读】大模型算法发展

一、简要介绍 论文研究了自深度学习出现以来&#xff0c;预训练语言模型的算法的改进速度。使用Wikitext和Penn Treebank上超过200个语言模型评估的数据集(2012-2023年)&#xff0c;论文发现达到设定性能阈值所需的计算大约每8个月减半一次&#xff0c;95%置信区间约为5到14个月…

React中的无状态组件:简约之美

&#x1f389; 博客主页&#xff1a;【剑九 六千里-CSDN博客】 &#x1f3a8; 上一篇文章&#xff1a;【掌握浏览器版本检测&#xff1a;从代码到用户界面】 &#x1f3a0; 系列专栏&#xff1a;【面试题-八股系列】 &#x1f496; 感谢大家点赞&#x1f44d;收藏⭐评论✍ 引言…

OS:处理机进程调度

1.BackGround&#xff1a;为什么要进行进程调度&#xff1f; 在多进程环境下&#xff0c;内存中存在着多个进程&#xff0c;其数目往往多于处理机核心数目。这就要求系统可以按照某种算法&#xff0c;动态的将处理机CPU资源分配给处于就绪状态的进程。调度算法的实质其实是一种…