Commit 3955aa55 张东亮

添加包装仓入库agv搬运逻辑

1 个父辈 1cc1b3e0
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- Backup*.rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
\ No newline at end of file \ No newline at end of file
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
"ExpandedNodes": [ "ExpandedNodes": [
"" ""
], ],
"SelectedNode": "\\AGVControl.sln",
"PreviewInSolutionExplorer": false "PreviewInSolutionExplorer": false
} }
\ No newline at end of file \ No newline at end of file
此文件类型无法预览
...@@ -41,6 +41,10 @@ ...@@ -41,6 +41,10 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>C:\DLL\File\Asa.File.Log.dll</HintPath> <HintPath>C:\DLL\File\Asa.File.Log.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>dll\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=106.0.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL"> <Reference Include="RestSharp, Version=106.0.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.10.1\lib\net452\RestSharp.dll</HintPath> <HintPath>..\packages\RestSharp.106.10.1\lib\net452\RestSharp.dll</HintPath>
</Reference> </Reference>
...@@ -60,6 +64,14 @@ ...@@ -60,6 +64,14 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BLL\AGVManager.cs" />
<Compile Include="BLL\ConfigAppSettings.cs" />
<Compile Include="BLL\HttpHelper.cs" />
<Compile Include="BLL\JsonHelper.cs" />
<Compile Include="BLL\MyWebClient.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="BLL\Setting_Init.cs" />
<Compile Include="BLL\Shortcut.cs" /> <Compile Include="BLL\Shortcut.cs" />
<Compile Include="Common.cs" /> <Compile Include="Common.cs" />
<Compile Include="BLL\Control.cs" /> <Compile Include="BLL\Control.cs" />
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup> </startup>
<appSettings> <appSettings>
<!--Server address-->
<add key="http.server" value="http://10.85.160.25/myproject/" />
<add key="LocalIP" value="192.168.103.12"/> <add key="LocalIP" value="192.168.103.12"/>
<add key="FLEET" value="10.85.199.3"/> <add key="FLEET" value="10.85.199.3"/>
<add key="AutoCharge" value="false"/> <add key="AutoCharge" value="false"/>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AGVControl;
using System.Web.Script.Serialization;
namespace BLL
{
public class AGVManager
{
private static string Addr_getShelfLockInfo = "/rest/api/qisda/device/getShelfLockInfo"; //包装仓获取料架锁定状态地址
public static bool GetShelfLockInfo(string rfid, out List<string> shelfLockNodeNames)
{
string msg = "";
shelfLockNodeNames = null;
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("rfid", rfid);
string server = GetAddr(Addr_getShelfLockInfo, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
Common.log.OutInfo( "料架锁定状态 " + " 【" + server + "】【" + resultStr + "】");
ShelfLockInfo serverResult = JsonHelper.DeserializeJsonToObject<ShelfLockInfo>(resultStr);
if (serverResult == null)
{
msg = " 没有收到服务器反馈";
Common.log.OutInfo(msg);
return false;
}
if (serverResult.data.Count == 0) //该料架未锁定
{
msg = " 料架【" + rfid + "】 没有锁定库位的料";
Common.log.OutInfo(msg);
return false;
}
else //该料架存在锁定库位的料
{
shelfLockNodeNames = new List<string>();
foreach (ShelfLockData item in serverResult.data)
{
if(!shelfLockNodeNames.Contains(Common.webService[item.cid]))
{
shelfLockNodeNames.Add(Common.webService[item.cid]);
Common.log.OutInfo("锁定的CID=" + item.cid + ";节点名称=" + Common.webService[item.cid]);
}
}
Common.log.OutInfo("获取料架上的料仓信息完成");
return true;
}
}
catch (Exception ex)
{
Common.log.OutInfo( ex.Message);
}
return false;
}
private static string GetAddr(string addr, Dictionary<string, string> paramsMap)
{
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
if (server.EndsWith("/"))
{
server = server.Substring(0, server.Length - 1);
}
string path = server + addr.Trim() + "?";
foreach (string paramName in paramsMap.Keys)
{
string par = System.Web.HttpUtility.UrlEncode(paramsMap[paramName], System.Text.Encoding.UTF8);
path += paramName + "=" + par + "&";
}
path = path.Substring(0, path.Length - 1);
return path;
}
}
public class ShelfLockInfo
{
//返回: {"code":0,"msg":"ok","data":
//[{"barcode":"S20052301213","cid":"packing-20","rfid":"A12","rfidLoc":"3","lockPos":"4D2001AA0006","lockPosId":"1231"}]}
/// <summary>
/// 返回码,0为正常,其他为异常
/// </summary>
public int code { get; set; }
/// <summary>
/// 消息
/// </summary>
public string msg { get; set; }
public List<ShelfLockData> data { get; set; }
}
public class ShelfLockData
{
/// <summary>
/// 库位中料盘的条码
/// </summary>
public string barcode { get; set; }
/// <summary>
/// 库位中料盘的锁定库位对应的料仓编
/// </summary>
public string cid { get; set; }
/// <summary>
/// 料架RFID
/// </summary>
public string rfid { get; set; }
/// <summary>
/// 料架的库位
/// </summary>
public int rfidLoc { get; set; }
/// <summary>
/// 库位中料盘的锁定库位
/// </summary>
public string lockPos { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Threading;
using System.Xml;
using System.Windows.Forms;
using AGVControl;
namespace BLL
{
public class ConfigAppSettings
{
public static string GetValue(string key)
{
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
Common.log.OutInfo("未找到配置:" + key + ",请检查配置是否完整!");
return "";
}
else
{
return config.AppSettings.Settings[key].Value;
}
}
public static decimal GetNumValue(string key)
{
decimal a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
Common.log.OutWarn("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
Decimal.TryParse(config.AppSettings.Settings[key].Value, out a);
}
}
return a;
}
public static int GetIntValue(string key)
{
int a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
Common.log.OutWarn("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
} return a;
}
public static void SaveValue(string key, int value)
{
SaveValue(key, value.ToString());
}
public static void SaveValue(string key, string value)
{
try
{
if (key.Equals("") || value.Equals(""))
{
return;
}
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
SetValue(key, value);
}
else
{
UpdateConfig(key, value);
}
}
catch (Exception ex)
{
Common.log.OutWarn( "SaveValue保存配置出错:AppKey=" + key + ",AppValue=" + value + "," + ex.StackTrace);
}
}
/// <summary>
/// 更新配置文件信息
/// </summary>
/// <param name="name">配置文件字段名称</param>
/// <param name="Xvalue">值</param>
private static void UpdateConfig(string name, string Xvalue)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(Application.ExecutablePath + ".config");
XmlNode node = doc.SelectSingleNode(@"//add[@key='" + name + "']");
XmlElement ele = (XmlElement)node;
ele.SetAttribute("value", Xvalue);
doc.Save(Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
Common.log.OutWarn( "UpdateConfig保存配置出错:name=" + name + ",Xvalue=" + Xvalue + "," + ex.StackTrace);
}
}
///<summary>
///向.config文件的appKey结写入信息AppValue 保存设置
///</summary>
///<param name="AppKey">节点名</param>
///<param name="AppValue">值</param>
private static void SetValue(String AppKey, String AppValue)
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
if (xElem1 != null)
xElem1.SetAttribute("value", AppValue);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key", AppKey);
xElem2.SetAttribute("value", AppValue);
xNode.AppendChild(xElem2);
}
xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
Common.log.OutWarn( "SetValue保存配置出错:AppKey=" + AppKey + ",AppValue=" + AppValue + "," + ex.StackTrace);
}
}
}
}
...@@ -4,6 +4,7 @@ using System.Linq; ...@@ -4,6 +4,7 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Web.Script.Serialization; using System.Web.Script.Serialization;
using AGVControl; using AGVControl;
using BLL;
using RestSharp; using RestSharp;
namespace BLL namespace BLL
...@@ -16,7 +17,7 @@ namespace BLL ...@@ -16,7 +17,7 @@ namespace BLL
private Thread tAgvState; private Thread tAgvState;
private List<string> _mark; private List<string> _mark;
private const int REG_STATUS = 20; private const int REG_STATUS = 20;
private List<string> shelfLockedNodeNames;
public delegate void AgvChangedEvent(int agvIndex); public delegate void AgvChangedEvent(int agvIndex);
public event AgvChangedEvent AgvChanged; public event AgvChangedEvent AgvChanged;
public event AgvChangedEvent AgvOnline; public event AgvChangedEvent AgvOnline;
...@@ -494,6 +495,8 @@ namespace BLL ...@@ -494,6 +495,8 @@ namespace BLL
{ {
if (Common.nodeInfo[node[i]].Mark == "0") if (Common.nodeInfo[node[i]].Mark == "0")
{ {
//获取料架锁定信息
AGVManager.GetShelfLockInfo(Common.nodeInfo[node[i]].RFID, out shelfLockedNodeNames);
nodeIdx = node[i]; nodeIdx = node[i];
break; break;
} }
...@@ -1103,8 +1106,12 @@ namespace BLL ...@@ -1103,8 +1106,12 @@ namespace BLL
} }
else else
{ {
if (!agv.StandbyTemp)
{
agv.NextMission = "A2"; agv.NextMission = "A2";
Common.mir.Add_Mission_Fleet(agv, "MoveStandbyTemp"); agv.StandbyTemp = true;
Common.mir.Add_Mission_Fleet(agv, Common.agvMission["MoveStandbyTemp"]);
}
} }
} }
else if (agv.RFID[0] == 'A') //包装料架 else if (agv.RFID[0] == 'A') //包装料架
...@@ -1122,17 +1129,22 @@ namespace BLL ...@@ -1122,17 +1129,22 @@ namespace BLL
else else
{ {
agv.NextMission = "B区"; agv.NextMission = "B区";
//Common.mir.Add_Mission_Fleet(agv, "MoveStandbyTemp"); //Common.mir.Add_Mission_Fleet(agv, "Common.agvMission["MoveStandbyTemp"]");
} }
} }
else else
{ {
if (!agv.StandbyTemp)
{
agv.StandbyTemp = true;
log = agv.Name + " B区暂时没有位置"; log = agv.Name + " B区暂时没有位置";
agv.NextMission = "B区"; agv.NextMission = "B区";
Common.mir.Add_Mission_Fleet(agv, "MoveStandbyTemp"); Common.mir.Add_Mission_Fleet(agv, Common.agvMission["MoveStandbyTemp"]);
Common.log.OutInfo(log); Common.log.OutInfo(log);
Common.log.OutTextBox(log); Common.log.OutTextBox(log);
} }
}
} }
else if (agv.RFID[0] == 'B') //料串 else if (agv.RFID[0] == 'B') //料串
{ {
...@@ -1148,17 +1160,22 @@ namespace BLL ...@@ -1148,17 +1160,22 @@ namespace BLL
else else
{ {
agv.NextMission = "C区"; agv.NextMission = "C区";
//Common.mir.Add_Mission_Fleet(agv, "MoveStandbyTemp"); //Common.mir.Add_Mission_Fleet(agv, "Common.agvMission["MoveStandbyTemp"]");
} }
} }
else else
{ {
if (!agv.StandbyTemp)
{
agv.StandbyTemp = true;
log = agv.Name + " C区暂时没有位置"; log = agv.Name + " C区暂时没有位置";
agv.NextMission = "C区"; agv.NextMission = "C区";
Common.mir.Add_Mission_Fleet(agv, "MoveStandbyTemp"); Common.mir.Add_Mission_Fleet(agv, Common.agvMission["MoveStandbyTemp"]);
Common.log.OutInfo(log); Common.log.OutInfo(log);
Common.log.OutTextBox(log); Common.log.OutTextBox(log);
} }
}
} }
else else
{ {
...@@ -1172,8 +1189,13 @@ namespace BLL ...@@ -1172,8 +1189,13 @@ namespace BLL
} }
else else
{ {
if (!agv.StandbyTemp)
{
agv.StandbyTemp = true;
agv.NextMission = "A2"; agv.NextMission = "A2";
Common.mir.Add_Mission_Fleet(agv, "MoveStandbyTemp"); Common.mir.Add_Mission_Fleet(agv, Common.agvMission["MoveStandbyTemp"]);
}
} }
} }
...@@ -1261,14 +1283,37 @@ namespace BLL ...@@ -1261,14 +1283,37 @@ namespace BLL
} }
else else
{ {
if (!agv.StandbyTemp)
{
agv.StandbyTemp = true;
agv.NextMission = name; agv.NextMission = name;
Common.mir.Add_Mission_Fleet(agv, "MoveStandbyTemp"); Common.mir.Add_Mission_Fleet(agv, Common.agvMission["MoveStandbyTemp"]);
}
} }
} }
return rtn; return rtn;
} }
else else
{ {
if(shelfLockedNodeNames !=null)
{
foreach (string item in shelfLockedNodeNames)
{
nodeIdx = Common.nodeInfo.FindIndex(s => s.Name == item && s.Action == ClientAction.NeedEnter && s.AgvName == "" && s.IsUse);
if (nodeIdx > -1)
{
return MoveNode(agv, nodeIdx);
}
else
{
log = item+ " 不等于NeedEnter 或Use为False,不能搬运锁定的料架";
Common.log.OutInfo(log);
//Common.log.OutTextBox(log);
//return false;
}
}
}
rtn = FindNeedEnter(agv, "A2"); rtn = FindNeedEnter(agv, "A2");
if (rtn) if (rtn)
{ {
...@@ -1276,8 +1321,13 @@ namespace BLL ...@@ -1276,8 +1321,13 @@ namespace BLL
} }
else else
{ {
if (!agv.StandbyTemp)
{
agv.StandbyTemp = true;
agv.NextMission = "A2"; agv.NextMission = "A2";
Common.mir.Add_Mission_Fleet(agv, "MoveStandbyTemp"); Common.mir.Add_Mission_Fleet(agv, Common.agvMission["MoveStandbyTemp"]);
}
} }
return rtn; return rtn;
} }
...@@ -1512,8 +1562,13 @@ namespace BLL ...@@ -1512,8 +1562,13 @@ namespace BLL
return true; return true;
} }
if (!agv.StandbyTemp)
{
agv.StandbyTemp = true;
agv.NextMission = "A2"; agv.NextMission = "A2";
Common.mir.Add_Mission_Fleet(agv, "MoveStandbyTemp"); Common.mir.Add_Mission_Fleet(agv, Common.agvMission["MoveStandbyTemp"]);
return false;
}
return false; return false;
} }
...@@ -1534,8 +1589,13 @@ namespace BLL ...@@ -1534,8 +1589,13 @@ namespace BLL
} }
else else
{ {
if (!agv.StandbyTemp)
{
agv.StandbyTemp = true;
agv.NextMission = name; agv.NextMission = name;
Common.mir.Add_Mission_Fleet(agv, "MoveStandbyTemp"); Common.mir.Add_Mission_Fleet(agv, Common.agvMission["MoveStandbyTemp"]);
}
} }
return rtn; return rtn;
...@@ -1587,17 +1647,22 @@ namespace BLL ...@@ -1587,17 +1647,22 @@ namespace BLL
else else
{ {
agv.NextMission = "C区"; agv.NextMission = "C区";
//Common.mir.Add_Mission_Fleet(agv, "MoveStandbyTemp"); //Common.mir.Add_Mission_Fleet(agv, "Common.agvMission["MoveStandbyTemp"]");
} }
} }
else else
{ {
if (!agv.StandbyTemp)
{
agv.StandbyTemp = true;
log = agv.Name + " C区暂时没有位置"; log = agv.Name + " C区暂时没有位置";
agv.NextMission = "C区"; agv.NextMission = "C区";
Common.mir.Add_Mission_Fleet(agv, "MoveStandbyTemp"); Common.mir.Add_Mission_Fleet(agv, Common.agvMission["MoveStandbyTemp"]);
Common.log.OutInfo(log); Common.log.OutInfo(log);
Common.log.OutTextBox(log); Common.log.OutTextBox(log);
} }
}
return rtn; return rtn;
} }
...@@ -2003,7 +2068,7 @@ namespace BLL ...@@ -2003,7 +2068,7 @@ namespace BLL
//执行下一个任务 //执行下一个任务
agv.Place = Common.nodeInfo[nodeIdx].Name; agv.Place = Common.nodeInfo[nodeIdx].Name;
agv.Mark = Common.nodeInfo[nodeIdx].Mark; agv.Mark = Common.nodeInfo[nodeIdx].Mark;
//agv.CloseDoor = false; agv.StandbyTemp = false;
bool rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Move" + agv.Place]); bool rtn = Common.mir.Add_Mission_Fleet(agv, Common.agvMission["Move" + agv.Place]);
if (rtn) if (rtn)
......
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Collections;
using System.Net;
using System.Net.Security;
using System.Security;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Reflection;
using System.Net.NetworkInformation;
using BLL;
using AGVControl;
namespace BLL
{
public class HttpHelper
{
// public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static string Post(string url, string paramData)
{
return Post(url, paramData, Encoding.UTF8);
}
//public static bool PingURLIP(string url, int ms=100)
//{
// string[] urlArray = url.Split('/');
// if (urlArray.Length > 3)
// {
// string ip = urlArray[2];
// Ping pingSender = new Ping();
// PingReply reply = pingSender.Send(ip, ms);//第一个参数为ip地址,第二个参数为ping的时间
// if (reply.Status == IPStatus.Success)
// {
// //通
// return true;
// }
// else
// {
// //不通
// return false;
// }
// }
// return true;
//}
/// <summary>
///
/// </summary>
/// <param name="url"></param>
/// <param name="operation"></param>
/// <param name="simulate">是否模拟服务器返回结果</param>
/// <returns></returns>
//public static Operation Post(string url, Operation operation, bool simulate)
//{
// try
// {
// ////如果Op=0或者Op=5,先拼Ip,不通不发送
// //if (operation.op < 0 || operation.op.Equals(5))
// //{
// // if (PingURLIP(url, 100).Equals(false))
// // {
// // return null;
// // }
// //}
// if (simulate)
// {//模拟服务器返回
// operation.status = 200;
// operation.data.Clear();
// operation.data.Add("posId", "A001");
// string pos = "D100-111#D102-222#D104-333";
// operation.data.Add("pos", pos);
// if (operation.op == 1 || operation.op == 2)
// {//入库或出库
// string json = JsonHelper.SerializeObject(operation);
// LogUtil.error("模拟HTTP服务器返回出库入库信息:" + json);
// return operation;
// }
// }
// else
// {
// string json = "";
// try
// {
// json = JsonHelper.SerializeObject(operation);
// }
// catch (Exception ex)
// {
// LogUtil.error("JsonHelper.SerializeObject(operation) 出错【operation.op=" + operation.op + "】" + ex);
// }
// string result = Post(url, json);
// if (!string.IsNullOrEmpty(result))
// {
// try
// {
// return JsonHelper.DeserializeJsonToObject<Operation>(result);
// }
// catch (Exception ex)
// {
// LogUtil.error("JsonHelper.DeserializeJsonToObject 出错【result=" + result + "】" + ex);
// }
// }
// }
// }
// catch (Exception ex)
// {
// LogUtil.error("Post 出错【operation.op=" + operation.op + "】:" + ex);
// }
// return null;
//}
private static int isLog = ConfigAppSettings.GetIntValue(Setting_Init.Server_Log_Open);
public static string LastServerMsg = "";
public static string Post(string url, string paramData, Encoding encoding)
{
//if (PingURLIP(url, 100).Equals(false))
//{
// return null;
//}
if (isLog == 1)
{
Common.log.OutInfo("给服务器发送数据【" + paramData + "】 ");
}
if (paramData != "null" && paramData != null)
{
// LogUtil.debug(LOGGER, "HTTP POST to " + url + " \n\t >> " + paramData);
}
string result = "";
if (url.ToLower().IndexOf("https", System.StringComparison.Ordinal) > -1)
{
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback((sender, certificate, chain, errors) => { return true; });
}
try
{
var wc = new MyWebClient(5000);
if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
wc.Encoding = encoding;
result = wc.UploadString(url, "POST", paramData);
//LogUtil.info(result);
}
catch (Exception e)
{
Common.log.OutWarn("POST ERROR:" + e.ToString());
}
if (!result.Contains("null") && result.Length != 0)
{
//LogUtil.debug(LOGGER,"receive << " + result);
}
if (isLog == 1)
{
Common.log.OutInfo("收到服务器数据【" + result + "】");
}
LastServerMsg = DateTime.Now.ToLongTimeString() + " URL:" + url + "\r\n"
+ "发送:" + paramData + "\r\n"
+ "接收:" + result + "\r\n"
;
return result;
}
//public static string Get(string url)
//{
// return Get(url, Encoding.UTF8);
//}
//public static string Get(string url, Encoding encoding)
//{
// try
// {
// LogUtil.info("HTTP GET FROM: " + url);
// var wc = new WebClient { Encoding = encoding };
// var readStream = wc.OpenRead(url);
// using (var sr = new StreamReader(readStream, encoding))
// {
// var result = sr.ReadToEnd();
// LogUtil.info("receive << " + result);
// return result;
// }
// }
// catch (Exception e)
// {
// LogUtil.error("HTTP GET ERROR:" + e.Message, 2);
// }
// return "";
//}
}
}
\ No newline at end of file \ No newline at end of file
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
namespace BLL
{
/// <summary>
/// Json帮助类
/// </summary>
public class JsonHelper
{
/// <summary>
/// 将对象序列化为JSON格式
/// </summary>
/// <param name="o">对象</param>
/// <returns>json字符串</returns>
public static string SerializeObject(object o)
{
string json = JsonConvert.SerializeObject(o);
return json;
}
/// <summary>
/// 解析JSON字符串生成对象实体
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json字符串(eg.{"ID":"112","Name":"石子儿"})</param>
/// <returns>对象实体</returns>
public static T DeserializeJsonToObject<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(T));
T t = o as T;
return t;
}
/// <summary>
/// 解析JSON数组生成对象实体集合
/// </summary>
/// <typeparam name="T">对象类型</typeparam>
/// <param name="json">json数组字符串(eg.[{"ID":"112","Name":"石子儿"}])</param>
/// <returns>对象实体集合</returns>
public static List<T> DeserializeJsonToList<T>(string json) where T : class
{
JsonSerializer serializer = new JsonSerializer();
StringReader sr = new StringReader(json);
object o = serializer.Deserialize(new JsonTextReader(sr), typeof(List<T>));
List<T> list = o as List<T>;
return list;
}
/// <summary>
/// 反序列化JSON到给定的匿名对象.
/// </summary>
/// <typeparam name="T">匿名对象类型</typeparam>
/// <param name="json">json字符串</param>
/// <param name="anonymousTypeObject">匿名对象</param>
/// <returns>匿名对象</returns>
public static T DeserializeAnonymousType<T>(string json, T anonymousTypeObject)
{
T t = JsonConvert.DeserializeAnonymousType(json, anonymousTypeObject);
return t;
}
}
///// <summary>
///// 与服务器通信用对象
///// </summary>
//public class Operation
//{
// private string _cid = "";
// public string cid
// {
// get { return _cid; }
// set { _cid = value; }
// }
// public int seq { get; set; }
// public int op { get; set; }
// public int status { get; set; }
// private string _error = "";
// public string error
// {
// get { return _error; }
// set { _error = value; }
// }
// private Dictionary<string, string> _data = new Dictionary<string,string>();
// public Dictionary<string, string> data {
// get { return _data; }
// set { _data = value; }
// }
//}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
namespace BLL
{
public class MyWebClient:WebClient
{
private int _timeout;
/// <summary>
/// 超时时间(毫秒)
/// </summary>
public int Timeout
{
get
{
return _timeout;
}
set
{
_timeout = value;
}
}
public MyWebClient()
{
this._timeout = 60000;
}
public MyWebClient(int timeout)
{
this._timeout = timeout;
}
protected override WebRequest GetWebRequest(Uri address)
{
var result = base.GetWebRequest(address);
result.Timeout = this._timeout;
return result;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
/// <summary>
/// 记录配置的key
/// </summary>
public class Setting_Init
{
public static string Agv_Log_Open = "Agv_Log_Open";
public static string Server_Log_Open = "Server_Log_Open";
/// <summary>
/// 系统启动时自动启动料仓,=1时自动启动,并隐藏窗口,=0时不需要
/// </summary>
public static string App_AutoRun = "App_AutoRun";
/// <summary>
/// 系统主界面标题
/// </summary>
public static string App_Title = "App_Title";
public static string http_server = "http.server";
public static string Store_CID = "Store_CID";
/// <summary>
/// 料仓数量
/// </summary>
public static string store_count = "store_count";
/// <summary>
/// 料仓类型,1=在线料仓
/// </summary>
public static string Store_Type = "Store_Type";
public static string BOX_ConfigPath = "BOX_ConfigPath";
public static string Store_Position_Config = "Store_Position_Config";
/// <summary>
/// 摄像机名称,多个中间使用#分割
/// </summary>
public static string CameraName = "CameraName";
/// <summary>
/// 需要识别的二维码类型,多个中间使用#分割
/// </summary>
public static string CodeType = "CodeType";
/// <summary>
/// 开始吹气的判断值(配置值=服务器发送的湿度值-开始吹气值)
/// </summary>
public static string StartBlowValue = "StartBlowValue";
/// <summary>
/// 停止吹气的判断值(配置值=服务器发送的湿度值-停止吹气值)
/// </summary>
public static string StopBlowValue = "StopBlowValue";
/// <summary>
/// 配置文件路径 Data Matrix ECC 200.dcm
/// </summary>
public static string CodeParamPath = "CodeParamPath";
/// <summary>
/// 进出轴最大待机点,需要小于3000
/// </summary>
public static string InOutDefaultPosition = "InOutDefaultPosition";
public static string Config_Pwd = "Config_Pwd";
/// <summary>
/// 出库等待料盘拿走的时间,秒
/// </summary>
public static string OutStoreWaitSeconds = "OutStoreWaitSeconds";
/// <summary>
/// 温控器类型,0=壁挂王字壳温湿度变送器,1=妙昕温湿度记录仪
/// </summary>
public static string HumitureControllerType = "HumitureControllerType";
public static string UseAIOBOX = "UseAIOBOX";
public static string LineServerIp = "LineServerIp";
public static string LineServerPort = "LineServerPort";
public static string ACBaudRate = "ACBaudRate";
public static string Store_ConfigPath = "Store_ConfigPath";
public static string UseBuzzer = "UseBuzzer";
public static string Shelf_Position_Config = "Shelf_Position_Config";
public static string Tool_P3_Offset = "Tool_P3_Offset";
public static string Tool_P4_Offset = "Tool_P4_Offset";
public static string Tool_P5_Offset = "Tool_P5_Offset";
public static string Tool_P6_Offset = "Tool_P6_Offset";
public static string Tool_TargetSpeed = "Tool_TargetSpeed";
public static string Tool_TargetPosition = "Tool_TargetPosition";
public static string AgvServerIp = "AgvServerIp";
public static string CodeCount = "CodeCount";
public static string AutoShelfInstore = "AutoShelfInstore";
public static string UseDoor = "UseDoor";
}
}
...@@ -336,6 +336,10 @@ namespace AGVControl ...@@ -336,6 +336,10 @@ namespace AGVControl
/// 闲置等待时间,用于充电 /// 闲置等待时间,用于充电
/// </summary> /// </summary>
public int WaitTime { set; get; } public int WaitTime { set; get; }
/// <summary>
/// 临时待机位,用于执行一次
/// </summary>
public bool StandbyTemp { set; get; }
public Agv_Info(string id, string name, string ip, string authorization, string ioId, bool isUse) public Agv_Info(string id, string name, string ip, string authorization, string ioId, bool isUse)
{ {
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup> </startup>
<appSettings> <appSettings>
<!--Server address-->
<add key="http.server" value="http://10.85.160.25/myproject/" />
<add key="LocalIP" value="192.168.103.12"/> <add key="LocalIP" value="192.168.103.12"/>
<add key="FLEET" value="10.85.199.3"/> <add key="FLEET" value="10.85.199.3"/>
<add key="AutoCharge" value="false"/> <add key="AutoCharge" value="false"/>
......
此文件类型无法预览
...@@ -47,3 +47,32 @@ D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl\AGVControl\obj\Debug ...@@ -47,3 +47,32 @@ D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl\AGVControl\obj\Debug
D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl\AGVControl\obj\Debug\AGVControl.exe D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl\AGVControl\obj\Debug\AGVControl.exe
D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl\AGVControl\obj\Debug\AGVControl.pdb D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl\AGVControl\obj\Debug\AGVControl.pdb
D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl\AGVControl\obj\Debug\AGVControl.csprojAssemblyReference.cache D:\OneDrive - 上海挚锦科技有限公司\SMD\AGVControl\AGVControl\obj\Debug\AGVControl.csprojAssemblyReference.cache
C:\myproject\Gitee\AGVControl\AGVControl\bin\Debug\AGVControl.exe.config
C:\myproject\Gitee\AGVControl\AGVControl\bin\Debug\AGVControl.exe
C:\myproject\Gitee\AGVControl\AGVControl\bin\Debug\AGVControl.pdb
C:\myproject\Gitee\AGVControl\AGVControl\bin\Debug\RestSharp.dll
C:\myproject\Gitee\AGVControl\AGVControl\bin\Debug\RestSharp.xml
C:\myproject\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.csprojAssemblyReference.cache
C:\myproject\Gitee\AGVControl\AGVControl\obj\Debug\Interop.IWshRuntimeLibrary.dll
C:\myproject\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.csproj.ResolveComReference.cache
C:\myproject\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.FrmMain.resources
C:\myproject\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.Properties.Resources.resources
C:\myproject\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.csproj.GenerateResource.cache
C:\myproject\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.csproj.CopyComplete
C:\myproject\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.exe
C:\myproject\Gitee\AGVControl\AGVControl\obj\Debug\AGVControl.pdb
C:\myproject\Gitee\AGVControl\AGVControl\bin\Debug\Newtonsoft.Json.dll
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\bin\Debug\AGVControl.exe.config
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\bin\Debug\AGVControl.exe
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\bin\Debug\AGVControl.pdb
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\bin\Debug\Newtonsoft.Json.dll
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\bin\Debug\RestSharp.dll
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\bin\Debug\RestSharp.xml
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\obj\Debug\Interop.IWshRuntimeLibrary.dll
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\obj\Debug\AGVControl.csproj.ResolveComReference.cache
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\obj\Debug\AGVControl.FrmMain.resources
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\obj\Debug\AGVControl.Properties.Resources.resources
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\obj\Debug\AGVControl.csproj.GenerateResource.cache
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\obj\Debug\AGVControl.csproj.CopyComplete
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\obj\Debug\AGVControl.exe
C:\Users\ASA\Desktop\张东亮\AGVControl-包装仓入库-未测试\AGVControl\AGVControl\obj\Debug\AGVControl.pdb
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!