liteon/Model/VehicleModel.cs
2025-07-12 14:05:35 +08:00

349 lines
9.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Community;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
/// <summary>
/// 载具对象
/// </summary>
public class VehicleModel : NotificationObject
{
#region 穴位1
private ShowInfo acupoint1;
/// <summary>
/// 穴位1
/// </summary>
public ShowInfo Acupoint1
{
get { return acupoint1; }
set
{
acupoint1 = value;
this.RaisePropertyChanged("Acupoint1");
}
}
#endregion
#region 穴位2
private ShowInfo acupoint2;
/// <summary>
/// 穴位2
/// </summary>
public ShowInfo Acupoint2
{
get { return acupoint2; }
set
{
acupoint2 = value;
this.RaisePropertyChanged("Acupoint2");
}
}
#endregion
#region 本载具对应的字符串含义
private string vehicleStr;
/// <summary>
/// 本载具对应的字符串含义
/// </summary>
public string VehicleStr
{
get { return vehicleStr; }
set
{
vehicleStr = value;
if (!string.IsNullOrEmpty(value))
{
ReductionStatu(value);
}
}
}
#endregion
public VehicleModel()
{
Acupoint1 = new ShowInfo();
Acupoint2 = new ShowInfo();
}
#region 获取当前载具穴位指定状态相同的个数
/// <summary>
/// 获取当前载具穴位指定状态相同的个数
/// </summary>
/// <param name="clostrStr"></param>
/// <returns></returns>
public int GetColorNumber(string clostrStr)
{
int a = 0;
if (Acupoint1.StatusBackground == clostrStr)
{
a++;
}
if (Acupoint2.StatusBackground == clostrStr)
{
a++;
}
return a;
}
#endregion
#region 获取当前载具二维码为空的个数
/// <summary>
/// 获取当前载具二维码为空的个数
/// </summary>
/// <returns></returns>
public int GetCodeIsNullNumber()
{
int a = 0;
if (string.IsNullOrEmpty(Acupoint1.StatuInfo))
{
a++;
}
if (string.IsNullOrEmpty(Acupoint2.StatuInfo))
{
a++;
}
return a;
}
#endregion
#region 还原载具状态
List<string> NewsList { get; set; }
/// <summary>
/// 还原载具状态
/// </summary>
/// <param name="statuStr"></param>
public void ReductionStatu(string statuStr)
{
try
{
NewsList = statuStr.Split(':').ToList();
if (NewsList[0] == "V")
{
Acupoint1.StatusBackground = StrToColor(NewsList[1]);
Acupoint2.StatusBackground = StrToColor(NewsList[2]);
Acupoint1.StatuInfo = NewsList[3];
Acupoint2.StatuInfo = NewsList[4];
Acupoint1.StatuValue = NewsList[5];
Acupoint2.StatuValue = NewsList[6];
}
}
catch (Exception)
{
}
}
#endregion
#region 获取载具字符
/// <summary>
/// 获取载具字符
/// </summary>
/// <returns></returns>
public string GetVechicleStr()
{
string str = "V:";
str = str + ColorToStr(Acupoint1.StatusBackground) + ":";
str = str + ColorToStr(Acupoint2.StatusBackground) + ":";
if (string.IsNullOrEmpty(Acupoint1.StatuInfo))
{
Acupoint1.StatuInfo = " ";
}
str = str + Acupoint1.StatuInfo + ":";
if (string.IsNullOrEmpty(Acupoint2.StatuInfo))
{
Acupoint2.StatuInfo = " ";
}
str = str + Acupoint2.StatuInfo + ":";
if (string.IsNullOrEmpty(Acupoint1.StatuValue))
{
Acupoint1.StatuValue = " ";
}
str = str + Acupoint1.StatuValue + ":";
if (string.IsNullOrEmpty(Acupoint2.StatuValue))
{
Acupoint2.StatuValue = " ";
}
str = str + Acupoint2.StatuValue + ":";
return str;
}
#endregion
#region 字符转颜色 0:灰色(无料) 1:蓝色(有料) 2:绿色(良品) 3:黄色(不良或未知)4:白色(无载具) 5:红色(清理载具)
/// <summary>
/// 字符转颜色 0:灰色(无料) 1:蓝色(有料) 2:绿色(良品) 3:黄色(不良或未知)4:白色(无载具) 5:红色(清理载具)
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
private string StrToColor(string str)
{
string colorstr = "";
switch (str)
{
case "0":
colorstr = ColorStr.Gray;
break;
case "1":
colorstr = ColorStr.Blue;
break;
case "2":
colorstr = ColorStr.Green;
break;
case "3":
colorstr = ColorStr.Yellow;
break;
case "4":
colorstr = ColorStr.White;
break;
case "5":
colorstr = ColorStr.Red;
break;
default:
colorstr = ColorStr.Gray;
break;
}
return colorstr;
}
#endregion
#region 颜色转字符 0:灰色(无料) 1:蓝色(有料) 2:绿色(良品) 3:黄色(不良或未知)4:白色(无载具)5:红色(清理载具)
/// <summary>
/// 颜色转字符 0:灰色(无料) 1:蓝色(有料) 2:绿色(良品) 3:黄色(不良或未知)4:白色(无载具) 5:红色(清理载具)
/// </summary>
/// <param name="colorStr"></param>
/// <returns></returns>
private string ColorToStr(string colorStr)
{
string str = 0.ToString();
if (colorStr == ColorStr.Gray)
{
str = 0.ToString();
}
else if (colorStr == ColorStr.Blue)
{
str = 1.ToString();
}
else if (colorStr == ColorStr.Green)
{
str = 2.ToString();
}
else if (colorStr == ColorStr.Yellow)
{
str = 3.ToString();
}
else if (colorStr == ColorStr.White)
{
str = 4.ToString();
}
else if (colorStr == ColorStr.Red)
{
str = 5.ToString();
}
else
{
str = 0.ToString();
}
return str;
}
#endregion
}
}
/// <summary>
/// 产品数据上传模型
/// </summary>
public class ProductValueModel
{
//lineno string 是 线体 V28
//procno string 是 工序号 10940
//thickness string 是 厚度
//inductor string 是 电感值
//speed string 是 点胶速度
//pressure string 是 点胶气压
//path string 是 CDC 检测图片路径
//result string 是 判定结果 OK/NG
//ngreason string 否 不良原因
//ngcode string 否 不良代码
//电感值不良:WK2801
//厚度不良:WK2802
//点胶不良:WK2803
/// <summary>
/// 线体 V28
/// </summary>
public string lineno { get; set; }
/// <summary>
/// 工序号
/// </summary>
public string procno { get; set; }
/// <summary>
/// 厚度
/// </summary>
public string thickness { get; set; }
/// <summary>
/// 电感值
/// </summary>
public string inductor { get; set; }
/// <summary>
/// 点胶速度
/// </summary>
public string speed { get; set; }
/// <summary>
/// 点胶气压
/// </summary>
public string pressure { get; set; }
/// <summary>
/// 检测图片路径
/// </summary>
public string path { get; set; }
/// <summary>
/// 判定结果 OK/NG
/// </summary>
public string result { get; set; }
/// <summary>
/// 不良原因
/// </summary>
public string ngreason { get; set; }
/// <summary>
/// 不良代码 电感值不良:WK2801 厚度不良:WK2802 点胶不良:WK2803
/// </summary>
public string ngcode { get; set; }
public ProductValueModel()
{
lineno = "V27";
procno = "10940";
thickness = "";
inductor = "";
speed = "";
pressure = "";
path = "";
result = "OK";
ngreason = "";
ngcode = "";
}
}