Commit d4450cba LN

增加料架位置配置

1 个父辈 c4b93ce1
......@@ -17,6 +17,7 @@
<add key="store_count" value="2"/>
<add key="Store_ConfigPath" value="\StoreConfig\StoreConfig.csv"/>
<!--start one store config-->
<add key="Shelf_Position_Config" value="\StoreConfig\shelfPosition.csv"/>
<add key="Store_Position_Config" value="\StoreConfig\linePositions.csv"/>
<add key="BOX_ConfigPath" value="\StoreConfig\BoxConfig.csv"/>
<add key="Store_Type" value="RC_AC_PA"/>
......
......@@ -41,6 +41,7 @@ namespace OnlineStore.ACPackingStore
if (store == null)
{
this.Close();
return;
}
else
{
......
......@@ -87,5 +87,6 @@ namespace OnlineStore.Common
public static string Store_ConfigPath = "Store_ConfigPath";
public static string UseBuzzer = "UseBuzzer";
public static string Shelf_Position_Config = "Shelf_Position_Config";
}
}
......@@ -17,9 +17,7 @@ namespace OnlineStore.DeviceLibrary
public partial class AC_BOX_Bean : KTK_Store
{
private static bool IsIntSlvBlock = false;
/// <summary>
/// 开始运行
/// </summary>
public static bool IsRun = false;
public string CID = "";
public AC_BOX_Config Config;
......@@ -36,8 +34,13 @@ namespace OnlineStore.DeviceLibrary
/// 轴报警信息
/// </summary>
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 IoCheckTimer = new System.Timers.Timer();
public AC_BOX_Bean(AC_BOX_Config config)
......@@ -73,6 +76,15 @@ namespace OnlineStore.DeviceLibrary
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;
int isAuto = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun);
if (isAuto == 1)
......
......@@ -12,10 +12,8 @@ namespace OnlineStore.DeviceLibrary
{
#region 自动出入库参数
/// <summary>
/// 料仓内所有的位置列表
/// </summary>
public List<string> PositionNumList = new List<string>();
/// <summary>
/// 入库完成后自动出库,出库完成后自动入库
/// </summary>
......
......@@ -108,6 +108,13 @@ namespace OnlineStore.DeviceLibrary
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);
}
}
......
......@@ -117,6 +117,9 @@
<None Include="StoreConfig\linePositions_1.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="StoreConfig\shelfPosition.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="StoreConfig\StoreConfig.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</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 @@
<ItemGroup>
<Compile Include="CSVExection.cs" />
<Compile Include="position\ACBoxPosition.cs" />
<Compile Include="position\ShelfPosition.cs" />
<Compile Include="storeConfig\ConfigItemBase.cs" />
<Compile Include="storeConfig\ConfigProAttribute.cs" />
<Compile Include="storeConfig\config\Store_Config.cs" />
......@@ -60,7 +61,7 @@
<Compile Include="CSVReaderBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="storeConfig\config\BaseConfig.cs" />
<Compile Include="position\StorePostionBase.cs" />
<Compile Include="position\PostionBase.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
......
......@@ -10,7 +10,7 @@ namespace OnlineStore.LoadCSVLibrary
/// <summary>
/// 松下伺服485控制,单台料仓
/// </summary>
public class ACBoxPosition : StorePostionBase
public class ACBoxPosition : PostionBase
{ /// <summary>
/// 对应的料仓ID(流水线料仓需要用此字段区分哪个BOX)
/// </summary>
......
......@@ -11,14 +11,16 @@ using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class CSVPositionReader<T> : CSVReaderBase where T : StorePostionBase
{
public class CSVPositionReader<T> : CSVReaderBase where T : PostionBase
{
/// <summary>
/// 所有的位置集合,key=位置
/// </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>
/// 重新加载配置,会删除之前的所有信息,重新读取
......@@ -27,19 +29,25 @@ namespace OnlineStore.LoadCSVLibrary
/// <returns></returns>
public static Dictionary<String, T> ReloadCSVFile(string filePath)
{
allPositionMap = new Dictionary<string, T>();
AllPositionMap = new Dictionary<string, Dictionary<string, T>>();
hasReadFileList = new List<string>();
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()
{
List<T> list = new List<T>(allPositionMap.Values);
return list;
{
string name = GetTName();
if (AllPositionMap.ContainsKey(name))
{
List<T> list = new List<T>(AllPositionMap[name].Values);
return list;
}
return new List<T>();
}
/// <summary>
/// 添加一个csv文件的数据到位置集合中
......@@ -54,7 +62,7 @@ namespace OnlineStore.LoadCSVLibrary
return null;
}
Type type = typeof(T);
string tname = GetTName();
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T));
if (proTitleMap.Count <= 4)
{
......@@ -94,7 +102,7 @@ namespace OnlineStore.LoadCSVLibrary
foreach (string key in cvsTitleList)
{
int titIndex = titleIndex[key];
string value = array[titIndex];
string value = array[titIndex].Trim();
string proName = propertyList[listIndex];
PropertyInfo prop = props.First(c => c.Name == proName);//获取同名属性
if (prop != null)
......@@ -108,11 +116,16 @@ namespace OnlineStore.LoadCSVLibrary
listIndex++;
}
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 + "已存在!");
}
allPositionMap.Add(PositionNum, (T)bllIns);
AllPositionMap[tname].Add(PositionNum, (T)bllIns);
}
else
{
......@@ -137,22 +150,25 @@ namespace OnlineStore.LoadCSVLibrary
{
return null;
}
StorePostionBase result = null;
if (allPositionMap.ContainsKey(positionNum))
PostionBase result = null;
string tname = GetTName();
if (AllPositionMap.ContainsKey(tname))
{
result = allPositionMap[positionNum];
return (T)result;
}
else
{
return null;
if (AllPositionMap[tname].ContainsKey(positionNum))
{
result = AllPositionMap[tname][positionNum];
return (T)result;
}
}
return null;
}
public static bool SavePostion(string filePath, T position)
{
Type type = typeof(T);
string tName = GetTName();
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T));
if (proTitleMap.Count <= 4)
{
......@@ -184,12 +200,16 @@ namespace OnlineStore.LoadCSVLibrary
string value = array[csvIndex];
if (value.Equals(position.PositionNum))
{
//更新缓存
allPositionMap.Remove(position.PositionNum);
allPositionMap.Add(position.PositionNum, position);
string newValue = PostionToString(position, titleIndex, proTitleMap);
lines[index] = newValue;
return WriteCSVFile(filePath, lines);
if (AllPositionMap.ContainsKey(tName))
{
//更新缓存
AllPositionMap[tName].Remove(position.PositionNum);
AllPositionMap[tName].Add(position.PositionNum, position);
string newValue = PostionToString(position, titleIndex, proTitleMap);
lines[index] = newValue;
return WriteCSVFile(filePath, lines);
}
}
}
}
......@@ -198,7 +218,7 @@ namespace OnlineStore.LoadCSVLibrary
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();
......@@ -230,28 +250,7 @@ namespace OnlineStore.LoadCSVLibrary
}
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;
namespace OnlineStore.LoadCSVLibrary
{
public class StorePostionBase
public class PostionBase
{
/// <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!