using DataEntity;
using DataEntity.Share;
using DataRWDAL;
using DataRWDalDrive.DB;
using HxEnum;
using MySqlX.XDevAPI.Common;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Media.Media3D;
using XCommon.Log;
using XImagingXhandler.XDAL;
namespace XHandler.Class.DataEx
{
public enum PickMode
{
Choice,
Puncture,
Aspirate
}
public enum CoatingMode
{
HuiMode,
ZMode
}
public enum PickPosition
{
///
/// 皿底部
///
DishBottom,
///
/// 菌表面
///
BacterialSurface,
}
public class DataModule
{
private static DataModule _instance;
public static DataModule getInstance()
{
if (_instance == null)
{
_instance = new DataModule();
return _instance;
}
return _instance;
}
///
/// 获取机械臂信息
///
private List deviceArms;
public List GetDeviceArm(bool bRefresh = false, bool insert = true)
{
if (bRefresh)
{
deviceArms = DeviceArmDB.GetDeviceArmFromdb(Shared.SoftwareInformation.software_information_id);
if (insert)
{
DeviceArm da = new DeviceArm();
da.head_type = Properties.Resources.strPlsSelect;
da.device_arm_name = Properties.Resources.strPlsSelect;
da.arm_type = -1;
deviceArms.Insert(0, da);
}
}
else
{
if (deviceArms == null)
{
deviceArms = DeviceArmDB.GetDeviceArmFromdb(Shared.SoftwareInformation.software_information_id);
if (insert)
{
DeviceArm da = new DeviceArm();
da.head_type = Properties.Resources.strPlsSelect;
da.device_arm_name = Properties.Resources.strPlsSelect;
da.arm_type = -1;
deviceArms.Insert(0, da);
}
}
}
return deviceArms;
}
public List GetDeviceArmWithAll()
{
List result = null;
//if (deviceArms == null)
//{
deviceArms = DeviceArmDB.GetDeviceArmFromdb(Shared.SoftwareInformation.software_information_id);
result = deviceArms.Where(x => x.arm_type.Equals(1)).ToList();
DeviceArm da = new DeviceArm();
da.head_type = Properties.Resources.strAllArm;
da.device_arm_name = Properties.Resources.strAllArm;
da.arm_type = -1;
result.Insert(0, da);
//}
return result;
}
private ObservableCollection liquidTypes;
public ObservableCollection GetLiquidTypes(bool bRefresh = false, bool insert = true)
{
if (bRefresh)
{
liquidTypes = LiquidTypeDB.GetLiquidTypeFromdb(2);
if (insert)
{
LiquidType lt = new LiquidType();
lt.liquid_type_id = string.Empty;
lt.liquid_type_name = Properties.Resources.strLiquidType;
liquidTypes.Insert(0, lt);
}
}
else
{
if (liquidTypes == null)
{
liquidTypes = LiquidTypeDB.GetLiquidTypeFromdb(2);
if (insert)
{
LiquidType lt = new LiquidType();
lt.liquid_type_id = string.Empty;
lt.liquid_type_name = Properties.Resources.strPlsSelectType;
liquidTypes.Insert(0, lt);
}
}
}
return liquidTypes;
}
#region 获取液体范围类型
private ObservableCollection liquidRanges;
public ObservableCollection GetLiquidRanges(bool bRefresh = false, bool insert = true)
{
if (bRefresh)
{
liquidRanges = LiquidRangeDB.GetLiquidRangeFromdb();
if (insert)
{
LiquidRange lr = new LiquidRange();
lr.liquid_range_id = "-1";
lr.liquid_range_name = Properties.Resources.strPlsSelectRage;
liquidRanges.Insert(0, lr);
}
}
else
{
if (liquidRanges == null)
{
liquidRanges = LiquidRangeDB.GetLiquidRangeFromdb();
if (insert)
{
LiquidRange lr = new LiquidRange();
lr.liquid_range_id = "-1";
lr.liquid_range_name = Properties.Resources.strPlsSelectRage;
liquidRanges.Insert(0, lr);
}
}
}
return liquidRanges;
}
#endregion
private ObservableCollection labwareTypes;
public ObservableCollection GetLabwareTypes(bool bRefresh = false, bool insert = true)
{
if (bRefresh)
{
labwareTypes = LabwareTypeDB.GetLabwareTypeFromdb(1);
//if (insert)
//{
// LabwareType type = new LabwareType();
// type.labwaretype_name = Properties.Resources.strAllType;
// labwareTypes.Insert(0, type);
//}
}
else
{
if (labwareTypes == null)
{
labwareTypes = LabwareTypeDB.GetLabwareTypeFromdb(1);
//if (insert)
//{
// LabwareType type = new LabwareType();
// type.labwaretype_name = Properties.Resources.strAllType;
// labwareTypes.Insert(0, type);
//}
}
}
return labwareTypes;
}
private ObservableCollection labwares;
public ObservableCollection GetLabwares(bool bRefresh = false)
{
if (bRefresh)
labwares = DataRWDAL.LabwareDB.GetLabware(2);
else
{
if (labwares == null)
{
labwares = DataRWDAL.LabwareDB.GetLabware(2);
}
}
if(labwares!=null)
{
foreach(Labware l in labwares)
{
if(l.labware_type_id.Equals("4"))
{
l.labwareWellInfoList = DataRWDAL.LabwareDB.GetSpecialLabwareWellInfo(l.labware_id);
}
}
}
return labwares;
}
private ObservableCollection tipsLabwares;
public ObservableCollection GetTipsLabwares(bool bRefresh = false, bool insert = true)
{
if (bRefresh)
{
tipsLabwares = DataRWDAL.LabwareDB.GetTipLabwareFromdb();
if (insert)
{
Labware lb = new Labware();
lb.labware_name = Properties.Resources.strPleaseSelect;
tipsLabwares.Insert(0, lb);
}
}
else
{
if (tipsLabwares == null)
{
tipsLabwares = DataRWDAL.LabwareDB.GetTipLabwareFromdb();
if (insert)
{
Labware lb = new Labware();
lb.labware_name = Properties.Resources.strPleaseSelect;
tipsLabwares.Insert(0, lb);
}
}
}
return tipsLabwares;
}
///
/// 获取台面点位
///
private List lattices;
public List GetLattices(bool bExcludeTrash = false, bool bRefresh = false)
{
TabletopTemplate tabletopTemplate = TabletopTemplateDB.GetCurrentAppTabletopTemplateCollectionFromdb(); //增加台面模板判断
if (tabletopTemplate == null)
{
if (bRefresh)
lattices = DataRWDAL.LatticeDB.GetLatticeDataFromdb(Shared.SoftwareInformation.software_device_number);
else
{
if (lattices == null)
{
lattices = DataRWDAL.LatticeDB.GetLatticeDataFromdb(Shared.SoftwareInformation.software_device_number);
}
}
}
else
{
if (bRefresh)
lattices = DataRWDAL.LatticeDB.GetLatticeDataByTabletopTemplateFromdb(tabletopTemplate.tabletopid);
else
{
if (lattices == null)
{
lattices = DataRWDAL.LatticeDB.GetLatticeDataByTabletopTemplateFromdb(tabletopTemplate.tabletopid);
}
}
}
if (bExcludeTrash)
{
var selLattices = lattices.Where(it => it.is_trash == EnumManagement.GetEnumValue(IsTrashEnum.No));
if (selLattices.Any())
{
lattices = selLattices.ToList();
}
}
return lattices;
}
private ObservableCollection methods;
public ObservableCollection GetMethod()
{
if (methods == null)
{
methods = new ObservableCollection();
ObservableCollection list = MethodDB.GetMethodFromdb();
foreach (var item in list)
{
if (item.method_group_id != EnumManagement.GetEnumValue(MethodGroupEnum.None))
methods.Add(item);
}
}
return methods;
}
///
/// 获取菌的信息
///
private ObservableCollection bacterias;
public ObservableCollection GetBacterias(bool bRefresh = false)
{
if (bRefresh)
bacterias = BacteriaDB.GetBacteriaListFromdb(2);
else
{
if (bacterias == null)
{
bacterias = BacteriaDB.GetBacteriaListFromdb(2);
}
}
return bacterias;
}
///
/// 获取挑菌方式
///
private ObservableCollection choiceModeList;
public ObservableCollection GetChoiceMode(string softwareDeviceNumber)
{
if (choiceModeList == null)
{
choiceModeList = new ObservableCollection();
choiceModeList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(ChoiceModeEnum.SigleSelectMode).ToString(),
dropdown_name = Properties.Resources.strSingleSelect
});
}
return choiceModeList;
}
#region 获取加液、取液位置类型
public ObservableCollection GetDispensePositionType()
{
ObservableCollection positionTypeList = new ObservableCollection();
positionTypeList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(MixPositionEnum.Liquid).ToString(),
dropdown_name = EnumManagement.GetEnumDescription(MixPositionEnum.Liquid)
});
positionTypeList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(MixPositionEnum.Top).ToString(),
dropdown_name = EnumManagement.GetEnumDescription(MixPositionEnum.Top)
});
positionTypeList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(MixPositionEnum.Bottom).ToString(),
dropdown_name = EnumManagement.GetEnumDescription(MixPositionEnum.Bottom)
});
return positionTypeList;
}
#endregion
///
/// 获取涂布方式
///
private ObservableCollection coatingModeList;
public ObservableCollection GetCoatingMode()
{
if (coatingModeList == null)
{
coatingModeList = new ObservableCollection();
#region 回字型
coatingModeList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(CoatingModeEnum.HuiziMode).ToString(),
dropdown_name = Properties.Resources.strHuiziMode
});
#endregion
#region Z字型
coatingModeList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(CoatingModeEnum.ZMode).ToString(),
dropdown_name = Properties.Resources.strZMode
});
#endregion
#region 上下移动
coatingModeList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(CoatingModeEnum.UpDownMode).ToString(),
dropdown_name = Properties.Resources.strUpDownMode
});
#endregion
#region 吸放液
coatingModeList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(CoatingModeEnum.AspirateDispenseMode).ToString(),
dropdown_name = Properties.Resources.strAspirateDispense
});
#endregion
#region 放液
coatingModeList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(CoatingModeEnum.DispenseMode).ToString(),
dropdown_name = Properties.Resources.strDispense
});
#endregion
}
return coatingModeList;
}
private ObservableCollection pickPositionList;
public ObservableCollection GetPickPosition()
{
if (pickPositionList == null)
{
pickPositionList = new ObservableCollection();
pickPositionList.Add(Properties.Resources.strDishBottom);
pickPositionList.Add(Properties.Resources.strBacteriaSurface);
}
return pickPositionList;
}
private ObservableCollection coatingPositionList;
public ObservableCollection GetCoatingPosition()
{
if (coatingPositionList == null)
{
coatingPositionList = new ObservableCollection();
coatingPositionList.Add(Properties.Resources.strDishBottom);
}
return coatingPositionList;
}
private ObservableCollection divisionList;
public ObservableCollection GetDivisionList()
{
if (divisionList == null)
{
divisionList = new ObservableCollection();
divisionList.Add("1" + Properties.Resources.strDivision);
divisionList.Add("2" + Properties.Resources.strDivision);
divisionList.Add("3" + Properties.Resources.strDivision);
divisionList.Add("4" + Properties.Resources.strDivision);
}
return divisionList;
}
private ObservableCollection specsDiameterList;
public ObservableCollection GetSpecsDiameterList()
{
if (specsDiameterList == null)
{
specsDiameterList = new ObservableCollection();
specsDiameterList.Add("35 mm");
specsDiameterList.Add("55 mm");
specsDiameterList.Add("60 mm");
specsDiameterList.Add("65 mm");
specsDiameterList.Add("70 mm");
specsDiameterList.Add("90 mm");
specsDiameterList.Add("100 mm");
specsDiameterList.Add("120 mm");
specsDiameterList.Add("150 mm");
specsDiameterList.Add("180 mm");
specsDiameterList.Add("200 mm");
}
return specsDiameterList;
}
private ObservableCollection specsHeightList;
public ObservableCollection GetSpecsHeightList()
{
if (specsHeightList == null)
{
specsHeightList = new ObservableCollection();
specsHeightList.Add("9 mm");
specsHeightList.Add("10 mm");
specsHeightList.Add("15 mm");
specsHeightList.Add("20 mm");
}
return specsHeightList;
}
private ObservableCollection pickBacteriaCoordinationList = new ObservableCollection();
///
/// 获取拍照json文件里的数据
///
///
///
public ObservableCollection GetBacteriaCoordinateList(string jsonFile = "")
{
if (string.IsNullOrEmpty(jsonFile))
return pickBacteriaCoordinationList;
if (!File.Exists(jsonFile))
{
return pickBacteriaCoordinationList;
}
try
{
pickBacteriaCoordinationList.Clear();
string jsonData = File.ReadAllText(jsonFile);
jsonData = jsonData.Replace("#!HxSEP!#", "");
JObject job = JObject.Parse(jsonData);
JArray jArray = (JArray)job["germlist"];
foreach (JToken jt in jArray)
{
BacteriaCoordinate bacteriaCoordinate = new BacteriaCoordinate();
bacteriaCoordinate.bacteriacoordinate_id = jt["index"].ToString();
string coordinate3D = string.Empty;
string coordinate3Dx = jt["coordinate3D"]["x"].ToString();
string coordinate3Dy = jt["coordinate3D"]["y"].ToString();
string coordinate3Dz = jt["coordinate3D"]["z"].ToString();
coordinate3D = jt["coordinate3D"]["x"].ToString() + "," + jt["coordinate3D"]["y"].ToString() + "," + jt["coordinate3D"]["z"].ToString();
bacteriaCoordinate.coordinate_machine = coordinate3D;
string coordinatePixel = string.Empty;
string pixelx = jt["coordinatePixel"]["x"].ToString();
string pixely = jt["coordinatePixel"]["y"].ToString();
coordinatePixel = jt["coordinatePixel"]["x"].ToString() + "," + jt["coordinatePixel"]["y"].ToString();
bacteriaCoordinate.coordinate_pixel = coordinatePixel;
BacteriaCoordinateEx ex = new BacteriaCoordinateEx(bacteriaCoordinate);
ex.diameter = jt["diameterSize"].ToString();
double pixelX = double.Parse(pixelx);
double pixelY = double.Parse(pixely);
ex.pixelPoint = new Point(pixelX, pixelY);
double p3DX = double.Parse(coordinate3Dx);
double p3DY = double.Parse(coordinate3Dy);
double p3DZ = double.Parse(coordinate3Dz);
ex.machinePoint = new Point3D(p3DX, p3DY, p3DZ);
pickBacteriaCoordinationList.Add(ex);
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
return pickBacteriaCoordinationList;
}
///
/// 未检测到时的处理方法
///
private ObservableCollection undetectProcessList;
public ObservableCollection GetUndetectProcessList()
{
if (undetectProcessList == null)
{
undetectProcessList = new ObservableCollection();
undetectProcessList.Add(Properties.Resources.strFailedContinue);
undetectProcessList.Add(Properties.Resources.strContinueFromBottom);
undetectProcessList.Add(Properties.Resources.strContinueFromTop);
//undetectProcessList.Add(Properties.Resources.strAuto);
undetectProcessList.Add(Properties.Resources.strShowWindows);
undetectProcessList.Add(Properties.Resources.strCurrentPos);
}
return undetectProcessList;
}
///
/// 液面跟随方式
///
private ObservableCollection liquidFollowTypeList;
public ObservableCollection GetLiquidFollowTypeList()
{
if (liquidFollowTypeList == null)
{
liquidFollowTypeList = new ObservableCollection();
liquidFollowTypeList.Add(Properties.Resources.strPleaseSelect);
liquidFollowTypeList.Add(Properties.Resources.strSpeedAndPointDis);
liquidFollowTypeList.Add(Properties.Resources.strLiquidFaceArea);
}
return liquidFollowTypeList;
}
///
/// 吸液堵塞处理方式
///
private ObservableCollection AspirateBlockDealTypeList;
public ObservableCollection GetAspirateBlockDealTypeList()
{
if (AspirateBlockDealTypeList == null)
{
AspirateBlockDealTypeList = new ObservableCollection();
AspirateBlockDealTypeList.Add(Properties.Resources.strAspirateBlockDeal0);
AspirateBlockDealTypeList.Add(Properties.Resources.strAspirateBlockDeal1);
AspirateBlockDealTypeList.Add(Properties.Resources.strAspirateBlockDeal2);
AspirateBlockDealTypeList.Add(Properties.Resources.strAspirateBlockDeal3);
AspirateBlockDealTypeList.Add(Properties.Resources.strAspirateBlockDeal4);
AspirateBlockDealTypeList.Add(Properties.Resources.strShowWindows);
}
return AspirateBlockDealTypeList;
}
///
/// 排液堵塞处理方式
///
private ObservableCollection DispenseBlockDealTypeList;
public ObservableCollection GetDispenseBlockDealTypeList()
{
if (DispenseBlockDealTypeList == null)
{
DispenseBlockDealTypeList = new ObservableCollection();
DispenseBlockDealTypeList.Add(Properties.Resources.strDispenseBlockDeal0);
DispenseBlockDealTypeList.Add(Properties.Resources.strAspirateBlockDeal3);
DispenseBlockDealTypeList.Add(Properties.Resources.strAspirateBlockDeal4);
DispenseBlockDealTypeList.Add(Properties.Resources.strShowWindows);
}
return DispenseBlockDealTypeList;
}
///
/// 吸空处理方式
///
private ObservableCollection AspirateAirDealTypeList;
public ObservableCollection GetAspirateAirDealTypeList()
{
if (AspirateAirDealTypeList == null)
{
AspirateAirDealTypeList = new ObservableCollection();
AspirateAirDealTypeList.Add(Properties.Resources.strAspirateAirDeal0);
AspirateAirDealTypeList.Add(Properties.Resources.strAspirateAirDeal1);
AspirateAirDealTypeList.Add(Properties.Resources.strAspirateBlockDeal3);
AspirateAirDealTypeList.Add(Properties.Resources.strAspirateBlockDeal4);
}
return AspirateAirDealTypeList;
}
#region 稀释方向
///
/// 稀释方向
///
private ObservableCollection dilutionDirectionList;
public ObservableCollection GetDilutionDirectionList()
{
if (dilutionDirectionList == null)
{
dilutionDirectionList = new ObservableCollection();
#region 从左到右
dilutionDirectionList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(DilutionDirectionEnum.LeftToRight).ToString(),
dropdown_name = Properties.Resources.strLeftToRight
});
#endregion
#region 从上到下
dilutionDirectionList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(DilutionDirectionEnum.UpToDown).ToString(),
dropdown_name = Properties.Resources.strUpToDown
});
#endregion
#region 从下到上
dilutionDirectionList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(DilutionDirectionEnum.DownToUp).ToString(),
dropdown_name = Properties.Resources.strDownToUp
});
#endregion
}
return dilutionDirectionList;
}
#endregion
#region 更换Tip
///
/// 更换Tip
///
private ObservableCollection changeTipList;
public ObservableCollection GetChangeTipList()
{
if (changeTipList == null)
{
changeTipList = new ObservableCollection();
#region 不更换
changeTipList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(ChangeTipEnum.NoChange).ToString(),
dropdown_name = Properties.Resources.strNoChangeTip
});
#endregion
#region 更换
changeTipList.Add(new DropdownName()
{
dropdown_id = EnumManagement.GetEnumValue(ChangeTipEnum.Change).ToString(),
dropdown_name = Properties.Resources.strChangeTip
});
#endregion
}
return changeTipList;
}
#endregion
}
}