Commit 978cd024 LN

1

1 个父辈 2c0bdca5
......@@ -784,16 +784,20 @@ namespace OnlineStore.DeviceLibrary
return;
}
string shelfRfid = ReadyShelf();
if (String.IsNullOrEmpty(shelfRfid))
{
//无可用料架
WarnMsg = $"{LineConnect.DoorPosInfo.ToStr()}暂无可用料架";
return;
}
ClearWarnMsg("暂无可用料架");
//获取库位号
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 (WarnMsg.Contains("getLocation"))
{
WarnMsg = "";
}
{
ClearWarnMsg("getLocation");
string targetP = GetShelfPosId();
if (!String.IsNullOrEmpty(targetP))
{
......@@ -816,6 +820,13 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(Name + "InShelfProcess:" + ex.ToString());
}
}
private void ClearWarnMsg(string str)
{
if (WarnMsg.Contains(str))
{
WarnMsg = "";
}
}
internal string GetShelfPosId()
{
string str = "";
......@@ -939,8 +950,9 @@ namespace OnlineStore.DeviceLibrary
{
if (isInSuddenDown || isNoAirCheck ||
(!storeRunStatus.Equals(StoreRunStatus.Runing))
|| storeStatus.Equals(StoreStatus.InStoreExecute) || storeStatus.Equals(StoreStatus.OutStoreExecute)
|| storeStatus.Equals(StoreStatus.InStoreEnd) || storeStatus.Equals(StoreStatus.OutStoreBoxEnd))
//|| storeStatus.Equals(StoreStatus.InStoreExecute) || storeStatus.Equals(StoreStatus.InStoreEnd)
|| storeStatus.Equals(StoreStatus.OutStoreExecute)
|| storeStatus.Equals(StoreStatus.OutStoreBoxEnd))
{
return false;
}
......@@ -958,10 +970,7 @@ namespace OnlineStore.DeviceLibrary
}
return msg;
}
#region 出料命令处理
public void CylinderMove(string IoLowType, string IoHighType, StoreMoveInfo moveInfo = null)
{
try
......@@ -978,10 +987,9 @@ namespace OnlineStore.DeviceLibrary
{
LogUtil.error(Name + "CylinderMove [" + IoLowType + "] [" + IoHighType + "] 出错:" + ex.ToString());
}
}
#endregion
}
#region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作
#region 通信定时器
private bool isInProcess = false;
private DateTime lastConTime = DateTime.Now;
......@@ -1053,7 +1061,7 @@ namespace OnlineStore.DeviceLibrary
isNeedAlarmLed = true;
}
if (MoveInfo.MoveType.Equals(StoreMoveType.InStore))
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
isInOut = true;
}
......
......@@ -175,7 +175,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
/// <param name="robot">ABB机器人索引号</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();
string api = "getLocation";
......
......@@ -104,8 +104,10 @@ namespace OnlineStore.DeviceLibrary
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;
try
{
......
......@@ -71,7 +71,7 @@ namespace OnlineStore.DeviceLibrary
{
switch (MoveInfo.MoveType)
{
case StoreMoveType.InStore:
case StoreMoveType.OutStore:
OutProcess();
isInPro = false;
break;
......@@ -98,11 +98,11 @@ namespace OnlineStore.DeviceLibrary
{
alarmMsg = alarmMsg.Replace(Name, "");
int inoutStatus = 0;
if (storeMoveType.Equals(StoreMoveType.InStore))
if (storeMoveType.Equals(StoreMoveType.OutStore))
{
inoutStatus = 1;
}
else if (storeMoveType.Equals(StoreMoveType.InStore))
else if (storeMoveType.Equals(StoreMoveType.OutStore))
{
inoutStatus = 2;
}
......@@ -306,12 +306,12 @@ namespace OnlineStore.DeviceLibrary
case StoreStatus.Debugging:
aa = "设备调试中";
break;
case StoreStatus.InStoreEnd:
aa = "料盘入仓位完成";
break;
case StoreStatus.InStoreExecute:
aa = "出料执行中";
break;
//case StoreStatus.InStoreEnd:
// aa = "料盘入仓位完成";
// break;
//case StoreStatus.InStoreExecute:
// aa = "出料执行中";
// break;
case StoreStatus.InTrouble:
aa = "故障中";
break;
......@@ -327,15 +327,15 @@ namespace OnlineStore.DeviceLibrary
case StoreStatus.SuddenStop:
aa = "急停中";
break;
case StoreStatus.OutMoveExecute:
aa = "出库完成";
break;
case StoreStatus.InStoreFaild:
aa = "出料失败(" + WarnMsg + ")";
break;
case StoreStatus.OutStoreFaild:
aa = "出库失败(" + WarnMsg + ")";
break;
//case StoreStatus.OutMoveExecute:
// aa = "出库完成";
// break;
//case StoreStatus.InStoreFaild:
// aa = "出料失败(" + WarnMsg + ")";
// break;
//case StoreStatus.OutStoreFaild:
// aa = "出库失败(" + WarnMsg + ")";
// break;
case StoreStatus.Check_PosMove:
aa = "盘点中";
break;
......@@ -344,7 +344,7 @@ namespace OnlineStore.DeviceLibrary
{
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();
}
......
......@@ -317,7 +317,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 出料
/// </summary>
InStore = 1,
OutStore = 1,
/// <summary>
/// 原点返回
......
......@@ -74,18 +74,18 @@ namespace OnlineStore.DeviceLibrary
/// 5=设备调试中
/// </summary>
Debugging = 5,
/// <summary>
/// 6=出料执行中
/// </summary>
InStoreExecute = 6,
/// <summary>
/// 7= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态)
/// </summary>
InStoreEnd = 7,
/// <summary>
/// 8=出料失败
/// </summary>
InStoreFaild = 8,
///// <summary>
///// 6=出料执行中
///// </summary>
//InStoreExecute = 6,
///// <summary>
///// 7= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态)
///// </summary>
//InStoreEnd = 7,
///// <summary>
///// 8=出料失败
///// </summary>
//InStoreFaild = 8,
/// <summary>
/// 9=出库执行中",
/// </summary>
......@@ -94,18 +94,18 @@ namespace OnlineStore.DeviceLibrary
///10= 出仓位完成( 料盘已经放到Box门口)
/// </summary>
OutStoreBoxEnd = 10,
/// <summary>
/// 12=移栽出库移栽过程中(移栽完成后变成OnLine)
/// </summary>
OutMoveExecute = 12,
/// <summary>
///11=出库失败
/// </summary>
OutStoreFaild = 11,
///// <summary>
///// 12=移栽出库移栽过程中(移栽完成后变成OnLine)
///// </summary>
//OutMoveExecute = 12,
///// <summary>
/////11=出库失败
///// </summary>
//OutStoreFaild = 11,
/// <summary>
/// 重置中(原点返回和重置都发此状态)
/// </summary>
ResetMove=13,
ResetMove =13,
/// <summary>
/// 库位盘点中
/// </summary>
......@@ -161,105 +161,89 @@ namespace OnlineStore.DeviceLibrary
#region 出料
///// <summary>
///// 出料:等待入口检测有料
///// </summary>
//SI_01_TrayCheck = 201,
///// <summary>
/////出料:获取料架库位号
///// </summary>
//SI_02_GetPosition,
///// <summary>
/////出料:等待料架准备完成
///// </summary>
//SI_03_WaitShelf,
///// <summary>
/////出料:顶升气缸上升
///// </summary>
//SI_04_LocationUp,
/// <summary>
/// 出料:进出轴(叉子)先返回P1
/// </summary>
SI_11_InOutToP1 = 211,
SO_11_InOutToP1 = 211,
/// <summary>
/// 出料:所有轴先回到待机点,轴2、轴1 动作到P1,,轴4动作至P3
/// </summary>
SI_12_AxisToP1,
SO_12_AxisToP1,
/// <summary>
/// 出料:压紧物品 压紧轴到P3(压紧前点)
/// </summary>
SI_13_ComToP3,
SO_13_ComToP3,
/// <summary>
/// 出料:叉子进入出料口,进出轴到P2
/// </summary>
SI_14_InoutToP2,
SO_14_InoutToP2,
/// <summary>
/// 出料:把物品放入叉子上,升降轴到P2,压紧物品,压紧轴到P2(压紧点)
/// </summary>
SI_15_GetReel,
SO_15_GetReel,
/// <summary>
/// 出料: 进出轴到P1( 待机点)
/// </summary>
SI_16_InoutBack,
SO_16_InoutBack,
/// <summary>
/// 出料:等待检测到料盘
/// </summary>
SI_17_TrayCheck,
SO_17_TrayCheck,
/// <summary>
/// 出料到料架:移动到库位点,旋转轴到P2( 库位点)升降轴到P3
/// </summary>
SI_21_MoveToBag=221,
SO_21_MoveToBag=221,
/// <summary>
/// 出料到料架:叉子进出料位中,进出轴到P3
/// </summary>
SI_22_InoutToP3,
SO_22_InoutToP3,
/// <summary>
/// 出料到料架:放下物品,升降轴到P4 ,压紧轴到P3( 压紧前点)
/// </summary>
SI_23_PutReel,
SO_23_PutReel,
/// <summary>
/// 出料到料架:叉子从库位中返回,轴3( 叉子) 动作至P1( 待机点)
/// </summary>
SI_24_InoutBack,
SO_24_InoutBack,
/// <summary>
/// 出料到料架:返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始
/// </summary>
SI_25_GoBack,
SO_25_GoBack,
/// <summary>
///出料到料架:等待叉子无信号
/// </summary>
SI_26_WaitNoReel,
SO_26_WaitNoReel,
/// <summary>
/// NG料:移动到NG位,旋转轴到P3 升降轴到P5
/// </summary>
SI_31_MoveToNG = 231,
SO_31_MoveToNG = 231,
/// <summary>
/// </summary>
/// NG料:进出轴到P4
SI_32_InoutToP4,
SO_32_InoutToP4,
/// <summary>
/// NG料: 升降轴到P6, 压紧轴到P3( 压紧前点)
/// </summary>
SI_33_PutReel,
SO_33_PutReel,
/// <summary>
/// NG料:进出轴返回P1
/// </summary>
SI_34_InoutToP1,
SO_34_InoutToP1,
/// <summary>
/// NG料:返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始
/// </summary>
SI_35_GoBack,
SO_35_GoBack,
/// <summary>
///NG料:等待叉子无信号
/// </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
MessageBox.Show(ex.ToString());
}
}
}
}
......@@ -79,6 +79,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="FrmAxisDebug.cs">
<SubType>Form</SubType>
</Compile>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!