Commit 978cd024 LN

1

1 个父辈 2c0bdca5
...@@ -784,16 +784,20 @@ namespace OnlineStore.DeviceLibrary ...@@ -784,16 +784,20 @@ namespace OnlineStore.DeviceLibrary
return; return;
} }
string shelfRfid = ReadyShelf(); string shelfRfid = ReadyShelf();
if (String.IsNullOrEmpty(shelfRfid))
{
//无可用料架
WarnMsg = $"{LineConnect.DoorPosInfo.ToStr()}暂无可用料架";
return;
}
ClearWarnMsg("暂无可用料架");
//获取库位号 //获取库位号
string outMsg = ""; string outMsg = "";
CurrTray = HttpServer.GetDiskInfo(1, shelfRfid, out outMsg); CurrTray = HttpServer.GetLocation(1, shelfRfid, out outMsg);
//需要取放料,且料架已准备好 //需要取放料,且料架已准备好
if (String.IsNullOrEmpty(CurrTray.getP).Equals(false) && outMsg.Equals("")) if (String.IsNullOrEmpty(CurrTray.getP).Equals(false) && outMsg.Equals(""))
{ {
if (WarnMsg.Contains("getLocation")) ClearWarnMsg("getLocation");
{
WarnMsg = "";
}
string targetP = GetShelfPosId(); string targetP = GetShelfPosId();
if (!String.IsNullOrEmpty(targetP)) if (!String.IsNullOrEmpty(targetP))
{ {
...@@ -816,6 +820,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -816,6 +820,13 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(Name + "InShelfProcess:" + ex.ToString()); LogUtil.error(Name + "InShelfProcess:" + ex.ToString());
} }
} }
private void ClearWarnMsg(string str)
{
if (WarnMsg.Contains(str))
{
WarnMsg = "";
}
}
internal string GetShelfPosId() internal string GetShelfPosId()
{ {
string str = ""; string str = "";
...@@ -939,8 +950,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -939,8 +950,9 @@ namespace OnlineStore.DeviceLibrary
{ {
if (isInSuddenDown || isNoAirCheck || if (isInSuddenDown || isNoAirCheck ||
(!storeRunStatus.Equals(StoreRunStatus.Runing)) (!storeRunStatus.Equals(StoreRunStatus.Runing))
|| storeStatus.Equals(StoreStatus.InStoreExecute) || storeStatus.Equals(StoreStatus.OutStoreExecute) //|| storeStatus.Equals(StoreStatus.InStoreExecute) || storeStatus.Equals(StoreStatus.InStoreEnd)
|| storeStatus.Equals(StoreStatus.InStoreEnd) || storeStatus.Equals(StoreStatus.OutStoreBoxEnd)) || storeStatus.Equals(StoreStatus.OutStoreExecute)
|| storeStatus.Equals(StoreStatus.OutStoreBoxEnd))
{ {
return false; return false;
} }
...@@ -958,10 +970,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -958,10 +970,7 @@ namespace OnlineStore.DeviceLibrary
} }
return msg; return msg;
} }
#region 出料命令处理
public void CylinderMove(string IoLowType, string IoHighType, StoreMoveInfo moveInfo = null) public void CylinderMove(string IoLowType, string IoHighType, StoreMoveInfo moveInfo = null)
{ {
try try
...@@ -978,10 +987,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -978,10 +987,9 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.error(Name + "CylinderMove [" + IoLowType + "] [" + IoHighType + "] 出错:" + ex.ToString()); LogUtil.error(Name + "CylinderMove [" + IoLowType + "] [" + IoHighType + "] 出错:" + ex.ToString());
} }
} }
#endregion
#region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作 #region 通信定时器
private bool isInProcess = false; private bool isInProcess = false;
private DateTime lastConTime = DateTime.Now; private DateTime lastConTime = DateTime.Now;
...@@ -1053,7 +1061,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1053,7 +1061,7 @@ namespace OnlineStore.DeviceLibrary
isNeedAlarmLed = true; isNeedAlarmLed = true;
} }
if (MoveInfo.MoveType.Equals(StoreMoveType.InStore)) if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{ {
isInOut = true; isInOut = true;
} }
......
...@@ -265,8 +265,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -265,8 +265,8 @@ namespace OnlineStore.DeviceLibrary
} }
LogInfo( " 启动出料【" + posId + "】"); LogInfo( " 启动出料【" + posId + "】");
storeRunStatus = StoreRunStatus.Busy; storeRunStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute; storeStatus = StoreStatus.OutStoreExecute;
MoveInfo.NewMove(StoreMoveType.InStore, param); MoveInfo.NewMove(StoreMoveType.OutStore, param);
if (IOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.HIGH)) if (IOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.HIGH))
{ {
...@@ -276,7 +276,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -276,7 +276,7 @@ namespace OnlineStore.DeviceLibrary
{ {
doorCheckWatch.Stop(); doorCheckWatch.Stop();
} }
SI_11_InOutToP1(param.MoveP); SO_11_InOutToP1(param.MoveP);
return true; return true;
} }
...@@ -288,10 +288,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -288,10 +288,10 @@ namespace OnlineStore.DeviceLibrary
} }
private void SI_11_InOutToP1(LineMoveP moveP) private void SO_11_InOutToP1(LineMoveP moveP)
{ {
MoveInfo.NextMoveStep(MoveStep.SI_11_InOutToP1); MoveInfo.NextMoveStep(MoveStep.SO_11_InOutToP1);
InStoreLog("进出轴到P1[" + moveP.InOut_P1 + "]"); MoveLog("进出轴到P1[" + moveP.InOut_P1 + "]");
int outCount = AxisManager.instance.GetActualtPosition(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()); int outCount = AxisManager.instance.GetActualtPosition(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
int errorCount = Math.Abs(outCount - moveP.InOut_P1); int errorCount = Math.Abs(outCount - moveP.InOut_P1);
if (errorCount <= Config.InOut_Axis.CanErrorCountMin) if (errorCount <= Config.InOut_Axis.CanErrorCountMin)
...@@ -303,33 +303,42 @@ namespace OnlineStore.DeviceLibrary ...@@ -303,33 +303,42 @@ namespace OnlineStore.DeviceLibrary
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed); ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
} }
} }
private void SI_14_InoutToP2() private void SO_13_ComToP3()
{ {
ConfigMoveAxis updown = Config.UpDown_Axis; ConfigMoveAxis updown = Config.UpDown_Axis;
LineMoveP movep = MoveInfo.MoveParam.MoveP; LineMoveP movep = MoveInfo.MoveParam.MoveP;
if (!AxisManager.instance.isInPosition(updown.DeviceName, updown.GetAxisValue(), movep.UpDown_P1, updown.CanErrorCountMax, true)) if (!AxisManager.instance.isInPosition(updown.DeviceName, updown.GetAxisValue(), movep.UpDown_P1, updown.CanErrorCountMax, true))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_13_ComToP3); MoveInfo.NextMoveStep(MoveStep.SO_13_ComToP3);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InStoreLog(" 升降轴不在待机点,重新运动 升降轴到P1 [" + movep.UpDown_P1 + "] "); MoveLog(" 升降轴不在待机点,重新运动 升降轴到P1 [" + movep.UpDown_P1 + "] ");
ACAxisMove(Config.UpDown_Axis, movep.UpDown_P1, Config.UpDownAxis_P1_Speed); ACAxisMove(Config.UpDown_Axis, movep.UpDown_P1, Config.UpDownAxis_P1_Speed);
return; return;
} }
ConfigMoveAxis middle = Config.Middle_Axis; ConfigMoveAxis middle = Config.Middle_Axis;
if (!AxisManager.instance.isInPosition(middle.DeviceName, middle.GetAxisValue(), movep.Middle_P1, middle.CanErrorCountMax, true)) if (!AxisManager.instance.isInPosition(middle.DeviceName, middle.GetAxisValue(), movep.Middle_P1, middle.CanErrorCountMax, true))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_13_ComToP3); MoveInfo.NextMoveStep(MoveStep.SO_13_ComToP3);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InStoreLog(" 旋转轴不在待机点,重新运动 旋转轴到P1 [" + movep.Middle_P1 + "]"); MoveLog(" 旋转轴不在待机点,重新运动 旋转轴到P1 [" + movep.Middle_P1 + "]");
ACAxisMove(Config.Middle_Axis, movep.Middle_P1, Config.MiddleAxis_P1_Speed); ACAxisMove(Config.Middle_Axis, movep.Middle_P1, Config.MiddleAxis_P1_Speed);
return; return;
} }
//判断仓门是否打开 //判断仓门是否打开
MoveInfo.NextMoveStep(MoveStep.SI_14_InoutToP2); MoveInfo.NextMoveStep(MoveStep.SO_14_InoutToP2);
InStoreLog(" 叉子进入出料口,进出轴至P2(进料口取料点) "+ movep.InOut_P2); MoveLog(" 叉子进入出料口,进出轴至P2(进料口取料点) "+ movep.InOut_P2);
ACAxisMove(Config.InOut_Axis, movep.InOut_P2, Config.InOutAxis_P2_Speed); ACAxisMove(Config.InOut_Axis, movep.InOut_P2, Config.InOutAxis_P2_Speed);
} }
private void SO_21_MoveToBag()
{
LineMoveP moveP = MoveInfo.MoveParam.MoveP;
MoveInfo.NextMoveStep(MoveStep.SO_21_MoveToBag);
MoveLog(" 移动到库位点,旋转轴至P2(库位点)[" + moveP.Middle_P2 + "], 升降轴至P3[" + moveP.UpDown_P3 + "] ");
ACAxisMove(Config.Middle_Axis, moveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P3, Config.UpDownAxis_P3_Speed);
}
protected override void OutProcess() protected override void OutProcess()
{ {
LineMoveP moveP = MoveInfo.MoveParam.MoveP; LineMoveP moveP = MoveInfo.MoveParam.MoveP;
...@@ -343,7 +352,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -343,7 +352,7 @@ namespace OnlineStore.DeviceLibrary
} }
if (MoveInfo.IsStep(MoveStep.SI_11_InOutToP1)) if (MoveInfo.IsStep(MoveStep.SO_11_InOutToP1))
{ {
if (IOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.LOW))
{ {
...@@ -351,8 +360,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -351,8 +360,8 @@ namespace OnlineStore.DeviceLibrary
WarnMsg = "[" + posId + "]叉子去取料前,未检测到进料口有料"; WarnMsg = "[" + posId + "]叉子去取料前,未检测到进料口有料";
LogUtil.error(WarnMsg); LogUtil.error(WarnMsg);
} }
MoveInfo.NextMoveStep(MoveStep.SI_12_AxisToP1); MoveInfo.NextMoveStep(MoveStep.SO_12_AxisToP1);
InStoreLog(" 所有轴回到待机点,升降轴到P1 [" + moveP.UpDown_P1 + "],旋转轴到P1 [" + moveP.Middle_P1 + "], 压紧轴到P3 [" + moveP.ComPress_P3 + "]"); MoveLog(" 所有轴回到待机点,升降轴到P1 [" + moveP.UpDown_P1 + "],旋转轴到P1 [" + moveP.Middle_P1 + "], 压紧轴到P3 [" + moveP.ComPress_P3 + "]");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
ComMoveToPosition(moveP.ComPress_P3, Config.CompAxis_P3_Speed); ComMoveToPosition(moveP.ComPress_P3, Config.CompAxis_P3_Speed);
...@@ -363,7 +372,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -363,7 +372,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
InStoreLog("升降轴已在P1[" + moveP.UpDown_P1 + "]"); MoveLog("升降轴已在P1[" + moveP.UpDown_P1 + "]");
} }
ConfigMoveAxis middle = Config.Middle_Axis; ConfigMoveAxis middle = Config.Middle_Axis;
if (!AxisManager.instance.isInPosition(middle.DeviceName, middle.GetAxisValue(), moveP.Middle_P1, middle.GetAxisValue())) if (!AxisManager.instance.isInPosition(middle.DeviceName, middle.GetAxisValue(), moveP.Middle_P1, middle.GetAxisValue()))
...@@ -372,32 +381,32 @@ namespace OnlineStore.DeviceLibrary ...@@ -372,32 +381,32 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
InStoreLog("旋转轴已在P1 [" + moveP.Middle_P1 + "]"); MoveLog("旋转轴已在P1 [" + moveP.Middle_P1 + "]");
} }
} }
else if (MoveInfo.IsStep(MoveStep.SI_12_AxisToP1)) else if (MoveInfo.IsStep(MoveStep.SO_12_AxisToP1))
{ {
SI_14_InoutToP2(); SO_13_ComToP3();
} }
else if (MoveInfo.IsStep(MoveStep.SI_13_ComToP3)) else if (MoveInfo.IsStep(MoveStep.SO_13_ComToP3))
{ {
SI_14_InoutToP2(); SO_13_ComToP3();
} }
else if (MoveInfo.IsStep(MoveStep.SI_14_InoutToP2)) else if (MoveInfo.IsStep(MoveStep.SO_14_InoutToP2))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_15_GetReel); MoveInfo.NextMoveStep(MoveStep.SO_15_GetReel);
InStoreLog(" 拿物品,压紧轴至P2[" + moveP.ComPress_P2 + "] 升降轴至P2[" + moveP.UpDown_P2 + "]"); MoveLog(" 拿物品,压紧轴至P2[" + moveP.ComPress_P2 + "] 升降轴至P2[" + moveP.UpDown_P2 + "]");
ComMoveToPosition(moveP.ComPress_P2, Config.CompAxis_P2_Speed); ComMoveToPosition(moveP.ComPress_P2, Config.CompAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P2, Config.UpDownAxis_P2_Speed); ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P2, Config.UpDownAxis_P2_Speed);
} }
else if (MoveInfo.IsStep(MoveStep.SI_15_GetReel)) else if (MoveInfo.IsStep(MoveStep.SO_15_GetReel))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_16_InoutBack); MoveInfo.NextMoveStep(MoveStep.SO_16_InoutBack);
InStoreLog("进出轴至P1[" + moveP.InOut_P1 + "] "); MoveLog("进出轴至P1[" + moveP.InOut_P1 + "] ");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed); ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
} }
else if (MoveInfo.IsStep(MoveStep.SI_16_InoutBack)) else if (MoveInfo.IsStep(MoveStep.SO_16_InoutBack))
{ {
if (IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.LOW))
{ {
...@@ -408,70 +417,64 @@ namespace OnlineStore.DeviceLibrary ...@@ -408,70 +417,64 @@ namespace OnlineStore.DeviceLibrary
if (Config.IsUse_Tray_Check.Equals(1)) if (Config.IsUse_Tray_Check.Equals(1))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_17_TrayCheck); MoveInfo.NextMoveStep(MoveStep.SO_17_TrayCheck);
InStoreLog(" 等待检测到叉子料盘信号 "); MoveLog(" 等待检测到叉子料盘信号 ");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.HIGH)); MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.HIGH));
} }
else else
{ {
MoveInfo.NextMoveStep(MoveStep.SI_21_MoveToBag); SO_21_MoveToBag();
InStoreLog(" 移动到库位点,旋转轴至P2(库位点)[" + moveP.Middle_P2 + "], 升降轴至P3[" + moveP.UpDown_P3 + "] ");
ACAxisMove(Config.Middle_Axis, moveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P3, Config.UpDownAxis_P3_Speed);
} }
} }
else if (MoveInfo.IsStep(MoveStep.SI_17_TrayCheck)) else if (MoveInfo.IsStep(MoveStep.SO_17_TrayCheck))
{ {
if (MoveInfo.MoveParam.PosInfo.IsNg) if (MoveInfo.MoveParam.PosInfo.IsNg)
{ {
MoveInfo.NextMoveStep(MoveStep.SI_31_MoveToNG); MoveInfo.NextMoveStep(MoveStep.SO_31_MoveToNG);
InStoreLog("移动到NG箱,旋转轴至P3[" + moveP.Middle_P3 + "], 升降轴至P5[" + moveP.UpDown_P5 + "] "); MoveLog("移动到NG箱,旋转轴至P3[" + moveP.Middle_P3 + "], 升降轴至P5[" + moveP.UpDown_P5 + "] ");
ACAxisMove(Config.Middle_Axis, moveP.Middle_P3, Config.MiddleAxis_P3_Speed); ACAxisMove(Config.Middle_Axis, moveP.Middle_P3, Config.MiddleAxis_P3_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P5, Config.UpDownAxis_P5_Speed); ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P5, Config.UpDownAxis_P5_Speed);
} }
else else
{ {
MoveInfo.NextMoveStep(MoveStep.SI_21_MoveToBag); SO_21_MoveToBag();
InStoreLog("移动到库位点,旋转轴至P2(库位点)[" + moveP.Middle_P2 + "], 升降轴至P3[" + moveP.UpDown_P3 + "] ");
ACAxisMove(Config.Middle_Axis, moveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P3, Config.UpDownAxis_P3_Speed);
} }
} }
#region ->料架 #region ->料架
else if (MoveInfo.IsStep(MoveStep.SI_21_MoveToBag)) else if (MoveInfo.IsStep(MoveStep.SO_21_MoveToBag))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_22_InoutToP3); MoveInfo.NextMoveStep(MoveStep.SO_22_InoutToP3);
InStoreLog(" 进出轴至P3 [" + moveP.InOut_P3 + "]"); MoveLog(" 进出轴至P3 [" + moveP.InOut_P3 + "]");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P3, Config.InOutAxis_P3_Speed); ACAxisMove(Config.InOut_Axis, moveP.InOut_P3, Config.InOutAxis_P3_Speed);
} }
else if (MoveInfo.IsStep(MoveStep.SI_22_InoutToP3)) else if (MoveInfo.IsStep(MoveStep.SO_22_InoutToP3))
{ {
// 5= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态) // 5= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态)
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosInfo.ShelfPosId : ""; string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosInfo.ShelfPosId : "";
lastPosId = posId; lastPosId = posId;
lastPosIdStatus = StoreStatus.InStoreEnd; lastPosIdStatus = StoreStatus.OutStoreBoxEnd;
storeStatus = StoreStatus.InStoreEnd; storeStatus = StoreStatus.OutStoreBoxEnd;
MoveInfo.NextMoveStep(MoveStep.SI_23_PutReel); MoveInfo.NextMoveStep(MoveStep.SO_23_PutReel);
InStoreLog(" 放下物品,升降轴至P4 [" + moveP.UpDown_P4 + "] ,压紧轴至P3[" + moveP.ComPress_P3 + "]"); MoveLog(" 放下物品,升降轴至P4 [" + moveP.UpDown_P4 + "] ,压紧轴至P3[" + moveP.ComPress_P3 + "]");
ComMoveToPosition(moveP.ComPress_P3, Config.CompAxis_P3_Speed); ComMoveToPosition(moveP.ComPress_P3, Config.CompAxis_P3_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P4, Config.UpDownAxis_P4_Speed); ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P4, Config.UpDownAxis_P4_Speed);
} }
else if (MoveInfo.IsStep(MoveStep.SI_23_PutReel)) else if (MoveInfo.IsStep(MoveStep.SO_23_PutReel))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_24_InoutBack); MoveInfo.NextMoveStep(MoveStep.SO_24_InoutBack);
InStoreLog(" 进出轴动作至P1[" + moveP.InOut_P1 + "],调用SheflFinish "); MoveLog(" 进出轴动作至P1[" + moveP.InOut_P1 + "],调用SheflFinish ");
HttpServer.ShelfFinish(CurrTray.realRFID, CurrTray.barcode, CurrTray.shelfP.ToString() ); HttpServer.ShelfFinish(CurrTray.realRFID, CurrTray.barcode, CurrTray.shelfP.ToString() );
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed); ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
} }
else if (MoveInfo.IsStep(MoveStep.SI_24_InoutBack)) else if (MoveInfo.IsStep(MoveStep.SO_24_InoutBack))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_25_GoBack); MoveInfo.NextMoveStep(MoveStep.SO_25_GoBack);
InStoreLog(" 返回待机点,轴2/轴1/轴4动作至P1,判断料架是否需要离开"); MoveLog(" 返回待机点,轴2/轴1/轴4动作至P1,判断料架是否需要离开");
foreach(WorkStation obj in StationMap.Values) foreach(WorkStation obj in StationMap.Values)
{ {
if (obj.CurrShelf.IsBusy) if (obj.CurrShelf.IsBusy)
...@@ -485,13 +488,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -485,13 +488,13 @@ namespace OnlineStore.DeviceLibrary
ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed); ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed); ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
} }
else if (MoveInfo.IsStep(MoveStep.SI_25_GoBack)) else if (MoveInfo.IsStep(MoveStep.SO_25_GoBack))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_26_WaitNoReel); MoveInfo.NextMoveStep(MoveStep.SO_26_WaitNoReel);
InStoreLog(" 等待料叉无信号 "); MoveLog(" 等待料叉无信号 ");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.LOW)); MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.LOW));
} }
else if (MoveInfo.IsStep(MoveStep.SI_26_WaitNoReel)) else if (MoveInfo.IsStep(MoveStep.SO_26_WaitNoReel))
{ {
TimeSpan span = DateTime.Now - startMoveTime; TimeSpan span = DateTime.Now - startMoveTime;
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosInfo.ShelfPosId : ""; string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosInfo.ShelfPosId : "";
...@@ -500,46 +503,46 @@ namespace OnlineStore.DeviceLibrary ...@@ -500,46 +503,46 @@ namespace OnlineStore.DeviceLibrary
storeRunStatus = StoreRunStatus.Runing; storeRunStatus = StoreRunStatus.Runing;
//设备连接,后,BOX恢复原始状态 //设备连接,后,BOX恢复原始状态
storeStatus = StoreStatus.StoreOnline; storeStatus = StoreStatus.StoreOnline;
InOutEndProcess(StoreMoveType.InStore); InOutEndProcess(StoreMoveType.OutStore);
} }
#endregion #endregion
#region ->NG #region ->NG
else if (MoveInfo.IsStep(MoveStep.SI_31_MoveToNG)) else if (MoveInfo.IsStep(MoveStep.SO_31_MoveToNG))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_32_InoutToP4); MoveInfo.NextMoveStep(MoveStep.SO_32_InoutToP4);
InStoreLog(" 进出轴至P4 [" + moveP.InOut_P4 + "]"); MoveLog(" 进出轴至P4 [" + moveP.InOut_P4 + "]");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P4, Config.InOutAxis_P4_Speed); ACAxisMove(Config.InOut_Axis, moveP.InOut_P4, Config.InOutAxis_P4_Speed);
} }
else if (MoveInfo.IsStep(MoveStep.SI_32_InoutToP4)) else if (MoveInfo.IsStep(MoveStep.SO_32_InoutToP4))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_33_PutReel); MoveInfo.NextMoveStep(MoveStep.SO_33_PutReel);
InStoreLog(" 放下物品,升降轴至P6 [" + moveP.UpDown_P6 + "] ,压紧轴至P3 [" + moveP.ComPress_P3 + "]"); MoveLog(" 放下物品,升降轴至P6 [" + moveP.UpDown_P6 + "] ,压紧轴至P3 [" + moveP.ComPress_P3 + "]");
ComMoveToPosition(moveP.ComPress_P3, Config.CompAxis_P3_Speed); ComMoveToPosition(moveP.ComPress_P3, Config.CompAxis_P3_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P6, Config.UpDownAxis_P6_Speed); ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P6, Config.UpDownAxis_P6_Speed);
} }
else if (MoveInfo.IsStep(MoveStep.SI_33_PutReel)) else if (MoveInfo.IsStep(MoveStep.SO_33_PutReel))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_34_InoutToP1); MoveInfo.NextMoveStep(MoveStep.SO_34_InoutToP1);
InStoreLog(" 进出轴动作至P1[" + moveP.InOut_P1 + "] "); MoveLog(" 进出轴动作至P1[" + moveP.InOut_P1 + "] ");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed); ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
} }
else if (MoveInfo.IsStep(MoveStep.SI_34_InoutToP1)) else if (MoveInfo.IsStep(MoveStep.SO_34_InoutToP1))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_35_GoBack); MoveInfo.NextMoveStep(MoveStep.SO_35_GoBack);
InStoreLog(" 返回待机点,轴2/轴1/轴4动作至P1)"); MoveLog(" 返回待机点,轴2/轴1/轴4动作至P1)");
ComMoveToPosition(moveP.ComPress_P1, Config.CompAxis_P1_Speed); ComMoveToPosition(moveP.ComPress_P1, Config.CompAxis_P1_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed); ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed); ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
} }
else if (MoveInfo.IsStep(MoveStep.SI_35_GoBack)) else if (MoveInfo.IsStep(MoveStep.SO_35_GoBack))
{ {
MoveInfo.NextMoveStep(MoveStep.SI_36_WaitNoReel); MoveInfo.NextMoveStep(MoveStep.SO_36_WaitNoReel);
InStoreLog(" 等待料叉无信号 "); MoveLog(" 等待料叉无信号 ");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.LOW)); MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.LOW));
} }
else if (MoveInfo.IsStep(MoveStep.SI_36_WaitNoReel)) else if (MoveInfo.IsStep(MoveStep.SO_36_WaitNoReel))
{ {
TimeSpan span = DateTime.Now - startMoveTime; TimeSpan span = DateTime.Now - startMoveTime;
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosInfo.ShelfPosId : ""; string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosInfo.ShelfPosId : "";
...@@ -554,8 +557,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -554,8 +557,6 @@ namespace OnlineStore.DeviceLibrary
LogInfo(" ,moveStatus=" + MoveInfo.MoveStep + ",没有对应的处理!"); LogInfo(" ,moveStatus=" + MoveInfo.MoveStep + ",没有对应的处理!");
} }
} }
#endregion #endregion
...@@ -570,7 +571,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -570,7 +571,7 @@ namespace OnlineStore.DeviceLibrary
{ {
return; return;
} }
if (storeMoveType.Equals(StoreMoveType.InStore)) if (storeMoveType.Equals(StoreMoveType.OutStore))
{ {
int newIndex = autoPositionIndex; int newIndex = autoPositionIndex;
if (newIndex < 0) if (newIndex < 0)
...@@ -605,7 +606,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -605,7 +606,7 @@ namespace OnlineStore.DeviceLibrary
} }
} }
private void InStoreLog(string msg) private void MoveLog(string msg)
{ {
string moveStr = "->料架 "; string moveStr = "->料架 ";
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosInfo.ShelfPosId : ""; string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosInfo.ShelfPosId : "";
......
...@@ -175,7 +175,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -175,7 +175,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary> /// </summary>
/// <param name="robot">ABB机器人索引号</param> /// <param name="robot">ABB机器人索引号</param>
/// <param name="currRFID">当前工位的RFID</param> /// <param name="currRFID">当前工位的RFID</param>
public static TrayInfo GetDiskInfo(int robot, string currRFID, out string msg) public static TrayInfo GetLocation(int robot, string currRFID, out string msg)
{ {
TrayInfo tray = new TrayInfo(); TrayInfo tray = new TrayInfo();
string api = "getLocation"; string api = "getLocation";
......
...@@ -104,8 +104,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -104,8 +104,10 @@ namespace OnlineStore.DeviceLibrary
internal static bool IsRealRfid(string shelfRfid) internal static bool IsRealRfid(string shelfRfid)
{ {
//判断料架号是否是真实的料架号 //判断料架号是否是真实的料架号
if (shelfRfid.StartsWith("C") || shelfRfid.StartsWith("D")) //混合料架用F
{ if (shelfRfid.StartsWith("F"))
//if (shelfRfid.StartsWith("C") || shelfRfid.StartsWith("D"))
{
int num = -1; int num = -1;
try try
{ {
......
...@@ -71,7 +71,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -71,7 +71,7 @@ namespace OnlineStore.DeviceLibrary
{ {
switch (MoveInfo.MoveType) switch (MoveInfo.MoveType)
{ {
case StoreMoveType.InStore: case StoreMoveType.OutStore:
OutProcess(); OutProcess();
isInPro = false; isInPro = false;
break; break;
...@@ -98,11 +98,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -98,11 +98,11 @@ namespace OnlineStore.DeviceLibrary
{ {
alarmMsg = alarmMsg.Replace(Name, ""); alarmMsg = alarmMsg.Replace(Name, "");
int inoutStatus = 0; int inoutStatus = 0;
if (storeMoveType.Equals(StoreMoveType.InStore)) if (storeMoveType.Equals(StoreMoveType.OutStore))
{ {
inoutStatus = 1; inoutStatus = 1;
} }
else if (storeMoveType.Equals(StoreMoveType.InStore)) else if (storeMoveType.Equals(StoreMoveType.OutStore))
{ {
inoutStatus = 2; inoutStatus = 2;
} }
...@@ -306,12 +306,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -306,12 +306,12 @@ namespace OnlineStore.DeviceLibrary
case StoreStatus.Debugging: case StoreStatus.Debugging:
aa = "设备调试中"; aa = "设备调试中";
break; break;
case StoreStatus.InStoreEnd: //case StoreStatus.InStoreEnd:
aa = "料盘入仓位完成"; // aa = "料盘入仓位完成";
break; // break;
case StoreStatus.InStoreExecute: //case StoreStatus.InStoreExecute:
aa = "出料执行中"; // aa = "出料执行中";
break; // break;
case StoreStatus.InTrouble: case StoreStatus.InTrouble:
aa = "故障中"; aa = "故障中";
break; break;
...@@ -327,15 +327,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -327,15 +327,15 @@ namespace OnlineStore.DeviceLibrary
case StoreStatus.SuddenStop: case StoreStatus.SuddenStop:
aa = "急停中"; aa = "急停中";
break; break;
case StoreStatus.OutMoveExecute: //case StoreStatus.OutMoveExecute:
aa = "出库完成"; // aa = "出库完成";
break; // break;
case StoreStatus.InStoreFaild: //case StoreStatus.InStoreFaild:
aa = "出料失败(" + WarnMsg + ")"; // aa = "出料失败(" + WarnMsg + ")";
break; // break;
case StoreStatus.OutStoreFaild: //case StoreStatus.OutStoreFaild:
aa = "出库失败(" + WarnMsg + ")"; // aa = "出库失败(" + WarnMsg + ")";
break; // break;
case StoreStatus.Check_PosMove: case StoreStatus.Check_PosMove:
aa = "盘点中"; aa = "盘点中";
break; break;
...@@ -344,7 +344,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -344,7 +344,7 @@ namespace OnlineStore.DeviceLibrary
{ {
string inout = ""; string inout = "";
if (MoveInfo.MoveType.Equals(StoreMoveType.InStore)&& MoveInfo.MoveParam!=null&& MoveInfo.MoveParam.PosInfo!=null) if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore)&& MoveInfo.MoveParam!=null&& MoveInfo.MoveParam.PosInfo!=null)
{ {
inout = "_出料:"+MoveInfo.MoveParam.PosInfo.ToStr(); inout = "_出料:"+MoveInfo.MoveParam.PosInfo.ToStr();
} }
......
...@@ -317,7 +317,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -317,7 +317,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 出料 /// 出料
/// </summary> /// </summary>
InStore = 1, OutStore = 1,
/// <summary> /// <summary>
/// 原点返回 /// 原点返回
......
...@@ -74,18 +74,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -74,18 +74,18 @@ namespace OnlineStore.DeviceLibrary
/// 5=设备调试中 /// 5=设备调试中
/// </summary> /// </summary>
Debugging = 5, Debugging = 5,
/// <summary> ///// <summary>
/// 6=出料执行中 ///// 6=出料执行中
/// </summary> ///// </summary>
InStoreExecute = 6, //InStoreExecute = 6,
/// <summary> ///// <summary>
/// 7= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态) ///// 7= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态)
/// </summary> ///// </summary>
InStoreEnd = 7, //InStoreEnd = 7,
/// <summary> ///// <summary>
/// 8=出料失败 ///// 8=出料失败
/// </summary> ///// </summary>
InStoreFaild = 8, //InStoreFaild = 8,
/// <summary> /// <summary>
/// 9=出库执行中", /// 9=出库执行中",
/// </summary> /// </summary>
...@@ -94,18 +94,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -94,18 +94,18 @@ namespace OnlineStore.DeviceLibrary
///10= 出仓位完成( 料盘已经放到Box门口) ///10= 出仓位完成( 料盘已经放到Box门口)
/// </summary> /// </summary>
OutStoreBoxEnd = 10, OutStoreBoxEnd = 10,
/// <summary> ///// <summary>
/// 12=移栽出库移栽过程中(移栽完成后变成OnLine) ///// 12=移栽出库移栽过程中(移栽完成后变成OnLine)
/// </summary> ///// </summary>
OutMoveExecute = 12, //OutMoveExecute = 12,
/// <summary> ///// <summary>
///11=出库失败 /////11=出库失败
/// </summary> ///// </summary>
OutStoreFaild = 11, //OutStoreFaild = 11,
/// <summary> /// <summary>
/// 重置中(原点返回和重置都发此状态) /// 重置中(原点返回和重置都发此状态)
/// </summary> /// </summary>
ResetMove=13, ResetMove =13,
/// <summary> /// <summary>
/// 库位盘点中 /// 库位盘点中
/// </summary> /// </summary>
...@@ -161,105 +161,89 @@ namespace OnlineStore.DeviceLibrary ...@@ -161,105 +161,89 @@ namespace OnlineStore.DeviceLibrary
#region 出料 #region 出料
///// <summary>
///// 出料:等待入口检测有料
///// </summary>
//SI_01_TrayCheck = 201,
///// <summary>
/////出料:获取料架库位号
///// </summary>
//SI_02_GetPosition,
///// <summary>
/////出料:等待料架准备完成
///// </summary>
//SI_03_WaitShelf,
///// <summary>
/////出料:顶升气缸上升
///// </summary>
//SI_04_LocationUp,
/// <summary> /// <summary>
/// 出料:进出轴(叉子)先返回P1 /// 出料:进出轴(叉子)先返回P1
/// </summary> /// </summary>
SI_11_InOutToP1 = 211, SO_11_InOutToP1 = 211,
/// <summary> /// <summary>
/// 出料:所有轴先回到待机点,轴2、轴1 动作到P1,,轴4动作至P3 /// 出料:所有轴先回到待机点,轴2、轴1 动作到P1,,轴4动作至P3
/// </summary> /// </summary>
SI_12_AxisToP1, SO_12_AxisToP1,
/// <summary> /// <summary>
/// 出料:压紧物品 压紧轴到P3(压紧前点) /// 出料:压紧物品 压紧轴到P3(压紧前点)
/// </summary> /// </summary>
SI_13_ComToP3, SO_13_ComToP3,
/// <summary> /// <summary>
/// 出料:叉子进入出料口,进出轴到P2 /// 出料:叉子进入出料口,进出轴到P2
/// </summary> /// </summary>
SI_14_InoutToP2, SO_14_InoutToP2,
/// <summary> /// <summary>
/// 出料:把物品放入叉子上,升降轴到P2,压紧物品,压紧轴到P2(压紧点) /// 出料:把物品放入叉子上,升降轴到P2,压紧物品,压紧轴到P2(压紧点)
/// </summary> /// </summary>
SI_15_GetReel, SO_15_GetReel,
/// <summary> /// <summary>
/// 出料: 进出轴到P1( 待机点) /// 出料: 进出轴到P1( 待机点)
/// </summary> /// </summary>
SI_16_InoutBack, SO_16_InoutBack,
/// <summary> /// <summary>
/// 出料:等待检测到料盘 /// 出料:等待检测到料盘
/// </summary> /// </summary>
SI_17_TrayCheck, SO_17_TrayCheck,
/// <summary> /// <summary>
/// 出料到料架:移动到库位点,旋转轴到P2( 库位点)升降轴到P3 /// 出料到料架:移动到库位点,旋转轴到P2( 库位点)升降轴到P3
/// </summary> /// </summary>
SI_21_MoveToBag=221, SO_21_MoveToBag=221,
/// <summary> /// <summary>
/// 出料到料架:叉子进出料位中,进出轴到P3 /// 出料到料架:叉子进出料位中,进出轴到P3
/// </summary> /// </summary>
SI_22_InoutToP3, SO_22_InoutToP3,
/// <summary> /// <summary>
/// 出料到料架:放下物品,升降轴到P4 ,压紧轴到P3( 压紧前点) /// 出料到料架:放下物品,升降轴到P4 ,压紧轴到P3( 压紧前点)
/// </summary> /// </summary>
SI_23_PutReel, SO_23_PutReel,
/// <summary> /// <summary>
/// 出料到料架:叉子从库位中返回,轴3( 叉子) 动作至P1( 待机点) /// 出料到料架:叉子从库位中返回,轴3( 叉子) 动作至P1( 待机点)
/// </summary> /// </summary>
SI_24_InoutBack, SO_24_InoutBack,
/// <summary> /// <summary>
/// 出料到料架:返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始 /// 出料到料架:返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始
/// </summary> /// </summary>
SI_25_GoBack, SO_25_GoBack,
/// <summary> /// <summary>
///出料到料架:等待叉子无信号 ///出料到料架:等待叉子无信号
/// </summary> /// </summary>
SI_26_WaitNoReel, SO_26_WaitNoReel,
/// <summary> /// <summary>
/// NG料:移动到NG位,旋转轴到P3 升降轴到P5 /// NG料:移动到NG位,旋转轴到P3 升降轴到P5
/// </summary> /// </summary>
SI_31_MoveToNG = 231, SO_31_MoveToNG = 231,
/// <summary> /// <summary>
/// </summary> /// </summary>
/// NG料:进出轴到P4 /// NG料:进出轴到P4
SI_32_InoutToP4, SO_32_InoutToP4,
/// <summary> /// <summary>
/// NG料: 升降轴到P6, 压紧轴到P3( 压紧前点) /// NG料: 升降轴到P6, 压紧轴到P3( 压紧前点)
/// </summary> /// </summary>
SI_33_PutReel, SO_33_PutReel,
/// <summary> /// <summary>
/// NG料:进出轴返回P1 /// NG料:进出轴返回P1
/// </summary> /// </summary>
SI_34_InoutToP1, SO_34_InoutToP1,
/// <summary> /// <summary>
/// NG料:返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始 /// NG料:返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始
/// </summary> /// </summary>
SI_35_GoBack, SO_35_GoBack,
/// <summary> /// <summary>
///NG料:等待叉子无信号 ///NG料:等待叉子无信号
/// </summary> /// </summary>
SI_36_WaitNoReel, SO_36_WaitNoReel,
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.HCSingleStore
{
class Class1
{
// <Query Kind = "Program" >
// < Reference > &lt; RuntimeDirectory&gt;\System.Net.Http.dll</Reference>
// <Reference>&lt;RuntimeDirectory&gt;\System.Windows.Forms.dll</Reference>
// <NuGetReference>Newtonsoft.Json</NuGetReference>
// <NuGetReference>SharpDX</NuGetReference>
// <NuGetReference>SharpDX.Direct2D1</NuGetReference>
// <NuGetReference>SharpDX.Mathematics</NuGetReference>
// <Namespace>D2D = SharpDX.Direct2D1</Namespace>
// <Namespace>DWrite = SharpDX.DirectWrite</Namespace>
// <Namespace>Newtonsoft.Json.Linq</Namespace>
// <Namespace>SharpDX.Direct2D1</Namespace>
// <Namespace>SharpDX.IO</Namespace>
// <Namespace>SharpDX.Mathematics.Interop</Namespace>
// <Namespace>System.Net.Http</Namespace>
// <Namespace>System.Threading.Tasks</Namespace>
// <Namespace>WIC = SharpDX.WIC</Namespace>
// <Namespace>SharpDX</Namespace>
// <Namespace>System.Runtime.InteropServices</Namespace>
// <Namespace>Microsoft.Win32</Namespace>
// <Namespace>System.Windows.Forms</Namespace>
//</Query>
HttpClient http = new HttpClient();
async Task Main()
{
$"Get bing url...".Dump();
string url = await GetBingPicture();
$"Get quote...".Dump();
string english = await GetQuote();
$"Download {url}...".Dump();
string file = await DownloadUrlAsFileName(url);
$"Generating...".Dump();
string wallpaperFileName = GenerateWallpaper(file, english);
Wallpaper.Set(wallpaperFileName, UserQuery.Wallpaper.Style.Centered);
Util.Image(wallpaperFileName.Dump()).Dump();
}
string GenerateWallpaper(string pictureFileName, string english)
{
var wic = new WIC.ImagingFactory2();
var d2d = new D2D.Factory();
float dpi = d2d.DesktopDpi.Width;
Size2 size = new Size2(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
WIC.FormatConverter image = CreateWicImage(wic, pictureFileName);
using (var wicBitmap = new WIC.Bitmap(wic, size.Width, size.Height, WIC.PixelFormat.Format32bppPBGRA, WIC.BitmapCreateCacheOption.CacheOnDemand))
using (var target = new D2D.WicRenderTarget(d2d, wicBitmap, new D2D.RenderTargetProperties()))
using (var dc = target.QueryInterface<D2D.DeviceContext>())
using (var bmpPicture = D2D.Bitmap.FromWicBitmap(target, image))
using (var dwriteFactory = new SharpDX.DirectWrite.Factory())
using (var brush = new SolidColorBrush(target, SharpDX.Color.Yellow))
using (var bmpLayer = new D2D.Bitmap1(dc, target.PixelSize,
new D2D.BitmapProperties1(new D2D.PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, D2D.AlphaMode.Premultiplied), dpi, dpi, D2D.BitmapOptions.Target)))
{
var oldTarget = dc.Target;
dc.Target = bmpLayer;
target.BeginDraw();
{
var textFormat = new DWrite.TextFormat(dwriteFactory, "Tahoma", size.Height / 27);
// draw English
{
var textLayout = new DWrite.TextLayout(dwriteFactory, english, textFormat, target.Size.Width * 0.75f, float.MaxValue);
var center = new Vector2((target.Size.Width - textLayout.Metrics.Width) / 2, (target.Size.Height - textLayout.Metrics.Height) / 2);
target.DrawTextLayout(new Vector2(center.X, center.Y), textLayout, brush);
}
}
target.EndDraw();
// shadow
var shadow = new D2D.Effects.Shadow(dc);
shadow.SetInput(0, bmpLayer, new RawBool(false));
dc.Target = oldTarget;
target.BeginDraw();
{
target.DrawBitmap(bmpPicture, new RectangleF(0, 0, target.Size.Width, target.Size.Height), 1.0f, BitmapInterpolationMode.Linear);
dc.DrawImage(shadow, new Vector2(size.Height / 150.0f, size.Height / 150.0f));
dc.UnitMode = UnitMode.Pixels;
target.DrawBitmap(bmpLayer, 1.0f, BitmapInterpolationMode.Linear);
}
target.EndDraw();
string wallpaperFileName = Path.GetTempPath() + "wallpaper.png";
using (var wallpaperStream = File.OpenWrite(wallpaperFileName))
{
SaveD2DBitmap(wic, wicBitmap, wallpaperStream);
wallpaperStream.Close();
return wallpaperFileName;
}
}
}
async Task<string> GetQuote()
{
var url = @"https://favqs.com/api/qotd";
var content = await http.GetStringAsync(url);
var json = JToken.Parse(content);
return json["quote"]["body"] + "\r\n\t\t\t\t——" + json["quote"]["author"];
}
async Task<string> GetBingPicture()
{
var url = @"https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=5&mkt=zh-cn";
var content = await http.GetStringAsync(url);
var json = JToken.Parse(content);
var images = json["images"]
.Select(x => x["url"].ToString())
.Select(x => "https://cn.bing.com" + x);
return images.First();
}
async Task<string> DownloadUrlAsFileName(string url)
{
var fileName = Path.GetTempFileName();
File.WriteAllBytes(fileName, await http.GetByteArrayAsync(url));
return fileName;
}
WIC.FormatConverter CreateWicImage(WIC.ImagingFactory wicFactory, string filename)
{
using (var decoder = new WIC.JpegBitmapDecoder(wicFactory))
using (var decodeStream = new WIC.WICStream(wicFactory, filename, NativeFileAccess.Read))
{
decoder.Initialize(decodeStream, WIC.DecodeOptions.CacheOnLoad);
using (var decodeFrame = decoder.GetFrame(0))
{
var converter = new WIC.FormatConverter(wicFactory);
converter.Initialize(decodeFrame, WIC.PixelFormat.Format32bppPBGRA);
return converter;
}
}
}
void SaveD2DBitmap(WIC.ImagingFactory wicFactory, WIC.Bitmap wicBitmap, Stream outputStream)
{
using (var encoder = new WIC.BitmapEncoder(wicFactory, WIC.ContainerFormatGuids.Png))
{
encoder.Initialize(outputStream);
using (var frame = new WIC.BitmapFrameEncode(encoder))
{
frame.Initialize();
frame.SetSize(wicBitmap.Size.Width, wicBitmap.Size.Height);
var pixelFormat = wicBitmap.PixelFormat;
frame.SetPixelFormat(ref pixelFormat);
frame.WriteSource(wicBitmap);
frame.Commit();
encoder.Commit();
}
}
}
public sealed class Wallpaper
{
const int SPI_SETDESKWALLPAPER = 20;
const int SPIF_UPDATEINIFILE = 0x01;
const int SPIF_SENDWININICHANGE = 0x02;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
public enum Style : int
{
Tiled,
Centered,
Stretched
}
public static void Set(string pictureFileName, Style style)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);
if (style == Style.Stretched)
{
key.SetValue(@"WallpaperStyle", 2.ToString());
key.SetValue(@"TileWallpaper", 0.ToString());
}
if (style == Style.Centered)
{
key.SetValue(@"WallpaperStyle", 1.ToString());
key.SetValue(@"TileWallpaper", 0.ToString());
}
if (style == Style.Tiled)
{
key.SetValue(@"WallpaperStyle", 1.ToString());
key.SetValue(@"TileWallpaper", 1.ToString());
}
SystemParametersInfo(SPI_SETDESKWALLPAPER,
0,
pictureFileName,
SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
}
}
}
}
...@@ -29,5 +29,6 @@ namespace OnlineStore.ACSingleStore ...@@ -29,5 +29,6 @@ namespace OnlineStore.ACSingleStore
MessageBox.Show(ex.ToString()); MessageBox.Show(ex.ToString());
} }
} }
} }
} }
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="FrmAxisDebug.cs"> <Compile Include="FrmAxisDebug.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!