Commit d4450cba LN

增加料架位置配置

1 个父辈 c4b93ce1
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<add key="store_count" value="2"/> <add key="store_count" value="2"/>
<add key="Store_ConfigPath" value="\StoreConfig\StoreConfig.csv"/> <add key="Store_ConfigPath" value="\StoreConfig\StoreConfig.csv"/>
<!--start one store config--> <!--start one store config-->
<add key="Shelf_Position_Config" value="\StoreConfig\shelfPosition.csv"/>
<add key="Store_Position_Config" value="\StoreConfig\linePositions.csv"/> <add key="Store_Position_Config" value="\StoreConfig\linePositions.csv"/>
<add key="BOX_ConfigPath" value="\StoreConfig\BoxConfig.csv"/> <add key="BOX_ConfigPath" value="\StoreConfig\BoxConfig.csv"/>
<add key="Store_Type" value="RC_AC_PA"/> <add key="Store_Type" value="RC_AC_PA"/>
......
...@@ -41,6 +41,7 @@ namespace OnlineStore.ACPackingStore ...@@ -41,6 +41,7 @@ namespace OnlineStore.ACPackingStore
if (store == null) if (store == null)
{ {
this.Close(); this.Close();
return;
} }
else else
{ {
......
...@@ -87,5 +87,6 @@ namespace OnlineStore.Common ...@@ -87,5 +87,6 @@ namespace OnlineStore.Common
public static string Store_ConfigPath = "Store_ConfigPath"; public static string Store_ConfigPath = "Store_ConfigPath";
public static string UseBuzzer = "UseBuzzer"; public static string UseBuzzer = "UseBuzzer";
public static string Shelf_Position_Config = "Shelf_Position_Config";
} }
} }
...@@ -17,9 +17,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -17,9 +17,7 @@ namespace OnlineStore.DeviceLibrary
public partial class AC_BOX_Bean : KTK_Store public partial class AC_BOX_Bean : KTK_Store
{ {
private static bool IsIntSlvBlock = false; private static bool IsIntSlvBlock = false;
/// <summary>
/// 开始运行
/// </summary>
public static bool IsRun = false; public static bool IsRun = false;
public string CID = ""; public string CID = "";
public AC_BOX_Config Config; public AC_BOX_Config Config;
...@@ -36,7 +34,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -36,7 +34,12 @@ namespace OnlineStore.DeviceLibrary
/// 轴报警信息 /// 轴报警信息
/// </summary> /// </summary>
private Dictionary<string, AxisAlarmInfo> AxisAlarmCodeMap = new Dictionary<string, AxisAlarmInfo>(); private Dictionary<string, AxisAlarmInfo> AxisAlarmCodeMap = new Dictionary<string, AxisAlarmInfo>();
/// <summary>
/// 料仓内所有的位置列表
/// </summary>
public List<string> PositionNumList = new List<string>();
public List<string> ShelfPosList = new List<string>();
private System.Timers.Timer serverConnectTimer = new System.Timers.Timer(); private System.Timers.Timer serverConnectTimer = new System.Timers.Timer();
private System.Timers.Timer IoCheckTimer = new System.Timers.Timer(); private System.Timers.Timer IoCheckTimer = new System.Timers.Timer();
...@@ -73,6 +76,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -73,6 +76,15 @@ namespace OnlineStore.DeviceLibrary
PositionNumList.Add(position.PositionNum); PositionNumList.Add(position.PositionNum);
} }
} }
List<ShelfPosition> sPlist = CSVPositionReader<ShelfPosition>.getPositionList();
ShelfPosList = new List<string>();
foreach(ShelfPosition p in sPlist)
{
if (p.StoreId.Equals(DeviceID))
{
ShelfPosList.Add(p.PositionNum);
}
}
mainTimer.Enabled = false; mainTimer.Enabled = false;
int isAuto = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun); int isAuto = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun);
if (isAuto == 1) if (isAuto == 1)
......
...@@ -12,10 +12,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -12,10 +12,8 @@ namespace OnlineStore.DeviceLibrary
{ {
#region 自动出入库参数 #region 自动出入库参数
/// <summary>
/// 料仓内所有的位置列表
/// </summary>
public List<string> PositionNumList = new List<string>();
/// <summary> /// <summary>
/// 入库完成后自动出库,出库完成后自动入库 /// 入库完成后自动出库,出库完成后自动入库
/// </summary> /// </summary>
......
...@@ -108,6 +108,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -108,6 +108,13 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, "加载料仓完成!"); LogUtil.info(LOGGER, "加载料仓完成!");
} }
string shelfConfig = appPath + ConfigAppSettings.GetValue(Setting_Init.Shelf_Position_Config);
if (File.Exists(shelfConfig))
{
CSVPositionReader<ShelfPosition>.AddCSVFile(shelfConfig);
}
Store = new PackingStoreBean(Config, storeConfig); Store = new PackingStoreBean(Config, storeConfig);
} }
} }
......
...@@ -117,6 +117,9 @@ ...@@ -117,6 +117,9 @@
<None Include="StoreConfig\linePositions_1.csv"> <None Include="StoreConfig\linePositions_1.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="StoreConfig\shelfPosition.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="StoreConfig\StoreConfig.csv"> <None Include="StoreConfig\StoreConfig.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
......
位置,优先级,高度,宽度,料仓ID,旋转轴位置,升降轴低点,升降轴高点,进出轴位置
1#AC1_1_1_4,1,8,7,1,211783,51884,55245,81000
1#AC1_1_1_5,2,8,7,1,211783,67807,71168,81000
1#AC1_1_1_6,3,8,7,1,211783,83730,87091,81000
1#AC1_1_1_7,4,8,7,1,211783,99653,103014,81000
1#AC1_1_1_8,5,8,7,1,211783,115576,118937,81000
1#AC1_1_1_9,6,8,7,1,211783,131499,134860,81000
1#AC1_1_1_10,7,8,7,1,211783,147422,150783,81000
1#AC1_1_1_11,8,8,7,1,211783,163345,166706,81000
1#AC1_1_1_12,9,8,7,1,211783,179268,182629,81000
1#AC1_1_1_13,10,8,7,1,211783,195191,198552,81000
1#AC1_1_1_14,11,8,7,1,211783,211114,214475,81000
1#AC1_1_1_15,12,8,7,1,211783,227037,230398,81000
1#AC1_1_1_16,13,8,7,1,211783,242960,246321,81000
1#AC1_1_1_17,14,8,7,1,211783,258883,262244,81000
1#AC1_1_1_18,15,8,7,1,211783,274806,278167,81000
1#AC1_1_1_19,16,8,7,1,211783,289000,294090,81000
1#AC1_1_1_20,17,8,7,1,211783,304652,310013,81000
1#AC1_1_1_21,18,8,7,1,211783,320575,325936,81000
1#AC1_1_1_22,19,8,7,1,211783,336498,341859,81000
1#AC1_1_2_3,20,8,7,1,211783,385700,389433,81000
1#AC1_1_2_4,21,8,7,1,211783,403000,405356,81000
1#AC1_1_2_5,22,8,7,1,211783,418345,421279,81000
1#AC1_1_2_6,23,8,7,1,211783,434000,437202,81000
1#AC1_1_2_7,24,8,7,1,211783,450000,453125,81000
1#AC1_1_2_8,25,8,7,1,211783,465900,469048,81000
1#AC1_1_2_9,26,8,7,1,211783,481800,484971,81000
1#AC1_1_2_10,27,8,7,1,211783,497660,500894,81000
1#AC1_1_2_11,28,8,7,1,211783,513600,516817,81000
1#AC1_1_2_12,29,8,7,1,211783,529200,532740,81000
1#AC1_1_2_13,30,8,7,1,211783,545100,548663,81000
1#AC1_1_2_14,31,8,7,1,211783,560500,564586,81000
1#AC1_1_2_15,32,8,7,1,211783,575500,580509,81000
1#AC1_1_2_16,33,8,7,1,211783,591500,596432,81000
1#AC1_1_2_17,34,8,7,1,211783,606000,612355,81000
1#AC1_1_2_18,35,8,7,1,211783,621000,628278,81000
,,,,,,,,
2#AC1_1_1_4,1,8,7,2,211783,51884,55245,81000
2#AC1_1_1_5,2,8,7,2,211783,67807,71168,81000
2#AC1_1_1_6,3,8,7,2,211783,83730,87091,81000
2#AC1_1_1_7,4,8,7,2,211783,99653,103014,81000
2#AC1_1_1_8,5,8,7,2,211783,115576,118937,81000
2#AC1_1_1_9,6,8,7,2,211783,131499,134860,81000
2#AC1_1_1_10,7,8,7,2,211783,147422,150783,81000
2#AC1_1_1_11,8,8,7,2,211783,163345,166706,81000
2#AC1_1_1_12,9,8,7,2,211783,179268,182629,81000
2#AC1_1_1_13,10,8,7,2,211783,195191,198552,81000
2#AC1_1_1_14,11,8,7,2,211783,211114,214475,81000
2#AC1_1_1_15,12,8,7,2,211783,227037,230398,81000
2#AC1_1_1_16,13,8,7,2,211783,242960,246321,81000
2#AC1_1_1_17,14,8,7,2,211783,258883,262244,81000
2#AC1_1_1_18,15,8,7,2,211783,274806,278167,81000
2#AC1_1_1_19,16,8,7,2,211783,289000,294090,81000
2#AC1_1_1_20,17,8,7,2,211783,304652,310013,81000
2#AC1_1_1_21,18,8,7,2,211783,320575,325936,81000
2#AC1_1_1_22,19,8,7,2,211783,336498,341859,81000
2#AC1_1_2_3,20,8,7,2,211783,385700,389433,81000
2#AC1_1_2_4,21,8,7,2,211783,403000,405356,81000
2#AC1_1_2_5,22,8,7,2,211783,418345,421279,81000
2#AC1_1_2_6,23,8,7,2,211783,434000,437202,81000
2#AC1_1_2_7,24,8,7,2,211783,450000,453125,81000
2#AC1_1_2_8,25,8,7,2,211783,465900,469048,81000
2#AC1_1_2_9,26,8,7,2,211783,481800,484971,81000
2#AC1_1_2_10,27,8,7,2,211783,497660,500894,81000
2#AC1_1_2_11,28,8,7,2,211783,513600,516817,81000
2#AC1_1_2_12,29,8,7,2,211783,529200,532740,81000
2#AC1_1_2_13,30,8,7,2,211783,545100,548663,81000
2#AC1_1_2_14,31,8,7,2,211783,560500,564586,81000
2#AC1_1_2_15,32,8,7,2,211783,575500,580509,81000
2#AC1_1_2_16,33,8,7,2,211783,591500,596432,81000
2#AC1_1_2_17,34,8,7,2,211783,606000,612355,81000
2#AC1_1_2_18,35,8,7,2,211783,621000,628278,81000
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="CSVExection.cs" /> <Compile Include="CSVExection.cs" />
<Compile Include="position\ACBoxPosition.cs" /> <Compile Include="position\ACBoxPosition.cs" />
<Compile Include="position\ShelfPosition.cs" />
<Compile Include="storeConfig\ConfigItemBase.cs" /> <Compile Include="storeConfig\ConfigItemBase.cs" />
<Compile Include="storeConfig\ConfigProAttribute.cs" /> <Compile Include="storeConfig\ConfigProAttribute.cs" />
<Compile Include="storeConfig\config\Store_Config.cs" /> <Compile Include="storeConfig\config\Store_Config.cs" />
...@@ -60,7 +61,7 @@ ...@@ -60,7 +61,7 @@
<Compile Include="CSVReaderBase.cs" /> <Compile Include="CSVReaderBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="storeConfig\config\BaseConfig.cs" /> <Compile Include="storeConfig\config\BaseConfig.cs" />
<Compile Include="position\StorePostionBase.cs" /> <Compile Include="position\PostionBase.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Common\Common.csproj"> <ProjectReference Include="..\Common\Common.csproj">
......
...@@ -10,7 +10,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -10,7 +10,7 @@ namespace OnlineStore.LoadCSVLibrary
/// <summary> /// <summary>
/// 松下伺服485控制,单台料仓 /// 松下伺服485控制,单台料仓
/// </summary> /// </summary>
public class ACBoxPosition : StorePostionBase public class ACBoxPosition : PostionBase
{ /// <summary> { /// <summary>
/// 对应的料仓ID(流水线料仓需要用此字段区分哪个BOX) /// 对应的料仓ID(流水线料仓需要用此字段区分哪个BOX)
/// </summary> /// </summary>
......
...@@ -11,14 +11,16 @@ using System.Text; ...@@ -11,14 +11,16 @@ using System.Text;
namespace OnlineStore.LoadCSVLibrary namespace OnlineStore.LoadCSVLibrary
{ {
public class CSVPositionReader<T> : CSVReaderBase where T : StorePostionBase public class CSVPositionReader<T> : CSVReaderBase where T : PostionBase
{ {
/// <summary> /// <summary>
/// 所有的位置集合,key=位置 /// 所有的位置集合,key=位置
/// </summary> /// </summary>
public static Dictionary<string, T> allPositionMap = new Dictionary<string, T>(); public static Dictionary<string, Dictionary<string, T>> AllPositionMap = new Dictionary<string, Dictionary<string, T>>();
public static List<string> hasReadFileList = new List<string>();
private static List<string> hasReadFileList = new List<string>();
/// <summary> /// <summary>
/// 重新加载配置,会删除之前的所有信息,重新读取 /// 重新加载配置,会删除之前的所有信息,重新读取
...@@ -27,20 +29,26 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -27,20 +29,26 @@ namespace OnlineStore.LoadCSVLibrary
/// <returns></returns> /// <returns></returns>
public static Dictionary<String, T> ReloadCSVFile(string filePath) public static Dictionary<String, T> ReloadCSVFile(string filePath)
{ {
allPositionMap = new Dictionary<string, T>(); AllPositionMap = new Dictionary<string, Dictionary<string, T>>();
hasReadFileList = new List<string>(); hasReadFileList = new List<string>();
return AddCSVFile(filePath); return AddCSVFile(filePath);
} }
public static List<string> getPositionKeyList() private static string GetTName()
{ {
return new List<string>(allPositionMap.Keys); Type type = typeof(T);
return type.Name;
} }
public static List<T> getPositionList() public static List<T> getPositionList()
{ {
List<T> list = new List<T>(allPositionMap.Values); string name = GetTName();
if (AllPositionMap.ContainsKey(name))
{
List<T> list = new List<T>(AllPositionMap[name].Values);
return list; return list;
} }
return new List<T>();
}
/// <summary> /// <summary>
/// 添加一个csv文件的数据到位置集合中 /// 添加一个csv文件的数据到位置集合中
/// </summary> /// </summary>
...@@ -54,7 +62,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -54,7 +62,7 @@ namespace OnlineStore.LoadCSVLibrary
return null; return null;
} }
Type type = typeof(T); Type type = typeof(T);
string tname = GetTName();
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T)); Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T));
if (proTitleMap.Count <= 4) if (proTitleMap.Count <= 4)
{ {
...@@ -94,7 +102,7 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -94,7 +102,7 @@ namespace OnlineStore.LoadCSVLibrary
foreach (string key in cvsTitleList) foreach (string key in cvsTitleList)
{ {
int titIndex = titleIndex[key]; int titIndex = titleIndex[key];
string value = array[titIndex]; string value = array[titIndex].Trim();
string proName = propertyList[listIndex]; string proName = propertyList[listIndex];
PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性 PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性
if (prop != null) if (prop != null)
...@@ -108,11 +116,16 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -108,11 +116,16 @@ namespace OnlineStore.LoadCSVLibrary
listIndex++; listIndex++;
} }
result.Add(PositionNum, (T)bllIns); result.Add(PositionNum, (T)bllIns);
if (allPositionMap.ContainsKey(PositionNum))
if (!AllPositionMap.ContainsKey(tname))
{
AllPositionMap.Add(tname, new Dictionary<string, T>());
}
if (AllPositionMap[tname].ContainsKey(PositionNum))
{ {
throw new PositionAlreadyExistingExection("仓位:" + PositionNum + "已存在!"); throw new PositionAlreadyExistingExection("仓位:" + PositionNum + "已存在!");
} }
allPositionMap.Add(PositionNum, (T)bllIns); AllPositionMap[tname].Add(PositionNum, (T)bllIns);
} }
else else
{ {
...@@ -137,22 +150,25 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -137,22 +150,25 @@ namespace OnlineStore.LoadCSVLibrary
{ {
return null; return null;
} }
StorePostionBase result = null; PostionBase result = null;
if (allPositionMap.ContainsKey(positionNum)) string tname = GetTName();
if (AllPositionMap.ContainsKey(tname))
{ {
result = allPositionMap[positionNum]; if (AllPositionMap[tname].ContainsKey(positionNum))
{
result = AllPositionMap[tname][positionNum];
return (T)result; return (T)result;
} }
else
{
return null;
} }
return null;
} }
public static bool SavePostion(string filePath, T position) public static bool SavePostion(string filePath, T position)
{ {
Type type = typeof(T); Type type = typeof(T);
string tName = GetTName();
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T)); Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T));
if (proTitleMap.Count <= 4) if (proTitleMap.Count <= 4)
{ {
...@@ -184,21 +200,25 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -184,21 +200,25 @@ namespace OnlineStore.LoadCSVLibrary
string value = array[csvIndex]; string value = array[csvIndex];
if (value.Equals(position.PositionNum)) if (value.Equals(position.PositionNum))
{ {
if (AllPositionMap.ContainsKey(tName))
{
//更新缓存 //更新缓存
allPositionMap.Remove(position.PositionNum); AllPositionMap[tName].Remove(position.PositionNum);
allPositionMap.Add(position.PositionNum, position); AllPositionMap[tName].Add(position.PositionNum, position);
string newValue = PostionToString(position, titleIndex, proTitleMap); string newValue = PostionToString(position, titleIndex, proTitleMap);
lines[index] = newValue; lines[index] = newValue;
return WriteCSVFile(filePath, lines); return WriteCSVFile(filePath, lines);
} }
} }
} }
}
index++; index++;
} }
return true; return true;
} }
private static string PostionToString(StorePostionBase position, Dictionary<string, int> titleIndex, Dictionary<string, string> proTitleMap) private static string PostionToString(PostionBase position, Dictionary<string, int> titleIndex, Dictionary<string, string> proTitleMap)
{ {
//取得属性集合 //取得属性集合
PropertyInfo[] props = typeof(T).GetProperties(); PropertyInfo[] props = typeof(T).GetProperties();
...@@ -231,27 +251,6 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -231,27 +251,6 @@ namespace OnlineStore.LoadCSVLibrary
return newStr; return newStr;
} }
//private void ReadTest( )
//{
// Dictionary<string, string> dic = new Dictionary<string, string>();
// string path = Application.StartupPath + @"\Test.csv";
// dic.Add("AxisPosition", "中轴位置");
// dic.Add("ModbusHighPosition", "电钢高位");
// dic.Add("ModbusLowPosition", "电钢低位");
// Dictionary<string, KTKStorePostion> ddd = LoadCVSLibrary.CSVReaderHelper<KTKStorePostion>.ReadCVS(path, dic, typeof(KTKStorePostion));
// if (ddd != null)
// {
// MessageBox.Show("读取成功!");
// }
// else
// {
// MessageBox.Show("读取失败,请检查数据格式!");
// }
//}
} }
......
...@@ -6,7 +6,7 @@ using System.Text; ...@@ -6,7 +6,7 @@ using System.Text;
namespace OnlineStore.LoadCSVLibrary namespace OnlineStore.LoadCSVLibrary
{ {
public class StorePostionBase public class PostionBase
{ {
/// <summary> /// <summary>
/// 位置 /// 位置
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class ShelfPosition:PostionBase
{
/// <summary>
/// 对应的料仓ID(流水线料仓需要用此字段区分哪个BOX)
/// </summary>
[CSVAttribute("料仓ID")]
public int StoreId { get; set; }
/// <summary>
/// 旋转轴位置
/// </summary>
[CSVAttribute("旋转轴位置")]
public int MiddleAxis_P100 { get; set; }
/// <summary>
/// 升降轴高点
/// </summary>
[CSVAttribute("升降轴低点")]
public int UpDownAxis_HP100 { get; set; }
/// <summary>
/// 升降轴高点
/// /// </summary>
[CSVAttribute("升降轴高点")]
public int UpDownAxis_LP100 { get; set; }
/// <summary>
/// 进出轴位置
/// </summary>
[CSVAttribute("进出轴位置")]
public int UpDownAxis_P100 { get; set; }
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!