Commit c733aa7c LN

io模块更新

1 个父辈 8a531401
......@@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "source\Common\Com
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceLibrary", "source\DeviceLibrary\DeviceLibrary.csproj", "{513BC1C9-800D-43A6-9499-3700BAEC3554}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserFromControl", "source\UserFromControl\UserFromControl.csproj", "{F018462A-D9BC-4365-97F2-F6D71751641E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadCSVLibrary", "source\LoadCVSLibrary\LoadCSVLibrary.csproj", "{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DUOStore", "source\DUOStore\DUOStore.csproj", "{0D2542F5-DD62-4352-82D0-383D9A045E74}"
......@@ -27,10 +25,6 @@ Global
{513BC1C9-800D-43A6-9499-3700BAEC3554}.Debug|Any CPU.Build.0 = Debug|Any CPU
{513BC1C9-800D-43A6-9499-3700BAEC3554}.Release|Any CPU.ActiveCfg = Release|Any CPU
{513BC1C9-800D-43A6-9499-3700BAEC3554}.Release|Any CPU.Build.0 = Release|Any CPU
{F018462A-D9BC-4365-97F2-F6D71751641E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F018462A-D9BC-4365-97F2-F6D71751641E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F018462A-D9BC-4365-97F2-F6D71751641E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F018462A-D9BC-4365-97F2-F6D71751641E}.Release|Any CPU.Build.0 = Release|Any CPU
{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}.Debug|Any CPU.Build.0 = Debug|Any CPU
{064BEBF5-8FAA-4EA2-A5F3-A06E6E7D9251}.Release|Any CPU.ActiveCfg = Release|Any CPU
......
此文件类型无法预览
......@@ -83,10 +83,10 @@
<level value="Info" />
<appender-ref ref="AIOBOX" />
</logger>
<root>
<!--<root>
<level value="Info" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</root>-->
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
......
......@@ -61,6 +61,9 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="UserFromControl">
<HintPath>..\..\dll\UserFromControl.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="FormManager.cs" />
......@@ -205,16 +208,27 @@
<Project>{064bebf5-8faa-4ea2-a5f3-a06e6e7d9251}</Project>
<Name>LoadCSVLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\UserFromControl\UserFromControl.csproj">
<Project>{f018462a-d9bc-4365-97f2-f6d71751641e}</Project>
<Name>UserFromControl</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="AuToRunManager.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="box.ico" />
<Content Include="image\gray.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="image\gray1.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="image\gray2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="image\green.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="image\green1.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="记录.txt" />
</ItemGroup>
<ItemGroup>
......
......@@ -303,7 +303,7 @@ namespace OnlineStore.DUOStore
//位置配置
string appPath = Application.StartupPath;
//如果总配置文件存在,保存到总的配置文件
string positionConfigFile = appPath + ConfigAppSettings.GetValue(Setting_Init.BOX_ConfigPath);
string positionConfigFile = appPath + ConfigAppSettings.GetValue(Setting_Init.Store_Position_Config);
if (!File.Exists(positionConfigFile))
{
string nameStr = BoxBean.ID.ToString();
......
......@@ -32,6 +32,7 @@ namespace OnlineStore.DUOStore
startTimer.Interval = 1000;
startTimer.Enabled = false;
startTimer.AutoReset = false;
Control.CheckForIllegalCrossThreadCalls = false;
}
......
......@@ -53,7 +53,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("关闭Io模块【" + ioIp + "】出错:", ex);
LogUtil.error("关闭Io模块【" + ioIp + "】出错:" + ex.ToString());
}
AIOMap.Remove(ioIp);
}
......@@ -74,7 +74,7 @@ namespace OnlineStore.DeviceLibrary
aioBox = new AIOBOX("AIOBOX");
aioBox.SetType(Asa.IOModule.Box_Type.DI, DILength, Asa.IOModule.Box_Type.DO, DOLength);
aioBox.IP = ioIp;
aioBox.Upload = true;
aioBox.Upload = false;
aioBox.DI_Changed_Event += AioBox_DI_Changed_Event; ;
......@@ -98,13 +98,7 @@ namespace OnlineStore.DeviceLibrary
private DateTime lastLogTime = DateTime.Now;
private void AioBox_Log_Out_Event(AIOBOX box, string[] s)
{
foreach (string str in s)
{
LogUtil.AIOLog.Debug("[" + box.IP + "]" + str);
}
}
private void AioBox_DI_Changed_Event(AIOBOX box, Box_Sta[] sta)
{
......@@ -114,7 +108,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("AioBox_DI_Changed_Event出错:", ex);
LogUtil.error("AioBox_DI_Changed_Event出错:" + ex.ToString());
}
}
private void AioBox_DO_Changed_Event(AIOBOX box, Box_Sta[] sta)
......@@ -126,7 +120,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("AioBox_DO_Changed_Event出错:", ex);
LogUtil.error("AioBox_DO_Changed_Event出错:" + ex.ToString());
}
}
private void UpdateAllDI(string ip, Box_Sta[] sta)
......@@ -232,7 +226,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("aio.Close出错:", ex);
LogUtil.error("aio.Close出错:" + ex.ToString());
}
}
AIOMap.Clear();
......@@ -258,7 +252,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错啦:", ex);
LogUtil.error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错啦:" + ex.ToString());
}
}
public override void WriteSingleDO(string ioIp, byte slaveId, ushort StartAddress, IO_VALUE onOff, int mSeconds)
......@@ -282,7 +276,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("**********定时回写入 出错:", ex);
LogUtil.error("**********定时回写入 出错:" + ex.ToString());
}
};
mytimer.AutoReset = false;//设置是否自动重启,即自动执行多次;
......@@ -359,7 +353,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("GetDOValue [" + ioIP + "] [" + StartAddress + "] 出错:", ex);
LogUtil.error("GetDOValue [" + ioIP + "] [" + StartAddress + "] 出错:" + ex.ToString());
}
return value;
}
......@@ -398,7 +392,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error(" 第【" + i + "】次 GetDIValue [" + ioIP + "] [" + StartAddress + "] 出错:", ex);
LogUtil.error(" 第【" + i + "】次 GetDIValue [" + ioIP + "] [" + StartAddress + "] 出错:" + ex.ToString());
}
}
return value;
......@@ -446,17 +440,5 @@ namespace OnlineStore.DeviceLibrary
return aioBox;
}
public override bool IsConnect(string ip)
{
if (AIOMap.ContainsKey(ip))
{
if (AIOMap[ip].IsConn)
{
return true;
}
return false;
}
return false;
}
}
}
......@@ -16,7 +16,6 @@ namespace OnlineStore.DeviceLibrary
#region KNDIO
public static void IOMove(string ioType, IO_VALUE ioValue, int subType = 0)
{
ConfigIO configIo = GetDO(ioType, subType);
......@@ -147,8 +146,8 @@ namespace OnlineStore.DeviceLibrary
}
#endregion
public static void Init()
{
instance = new AIOBOXManager();
{
instance = new AIOBOXManager();
}
public abstract void ReadAllDI(string deviceName, byte slaveId);
......@@ -158,15 +157,19 @@ namespace OnlineStore.DeviceLibrary
public abstract void WriteSingleDO(string deviceName, byte slaveId, ushort index, IO_VALUE value);
public abstract IO_VALUE GetDIValue(string deviceName, byte slaveID, ushort v);
public abstract IO_VALUE GetDOValue(string deviceName, byte slaveID, ushort v);
public abstract IO_VALUE GetIOValue(ConfigIO configIO);
public abstract void CloseAllDO();
public abstract void CloseAllConnection();
public abstract bool IsConnect(string ip);
}
}
......@@ -172,53 +172,60 @@ namespace OnlineStore.LoadCSVLibrary
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)
{
LogUtil.error(typeof(T).ToString() + "只读取到" + proTitleMap.Count + "个属性");
}
List<string> cvsTitleList = new List<string>(proTitleMap.Values);
List<string> propertyList = new List<string>(proTitleMap.Keys);
int positionNumIndex = propertyList.IndexOf("PositionNum");
int csvIndex = -1;
string[] lines = ReadCSVFile(filePath);
int index = 0;
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
foreach (var line in lines)
try
{
var array = line.Split(',');
if (index == 0)
Type type = typeof(T);
string tName = GetTName();
Dictionary<string, string> proTitleMap = getProAttributeMap(typeof(T));
if (proTitleMap.Count <= 4)
{
titleIndex = GetTitleIndex(filePath, line, cvsTitleList);
LogUtil.error(typeof(T).ToString() + "只读取到" + proTitleMap.Count + "个属性");
}
else
List<string> cvsTitleList = new List<string>(proTitleMap.Values);
List<string> propertyList = new List<string>(proTitleMap.Keys);
int positionNumIndex = propertyList.IndexOf("PositionNum");
int csvIndex = -1;
string[] lines = ReadCSVFile(filePath);
int index = 0;
Dictionary<string, int> titleIndex = new Dictionary<string, int>();
foreach (var line in lines)
{
if (array.Length == titleIndex.Count)
var array = line.Split(',');
if (index == 0)
{
if (csvIndex < 0)
{
csvIndex = titleIndex[cvsTitleList[positionNumIndex]];
}
string value = array[csvIndex];
if (value.Equals(position.PositionNum))
titleIndex = GetTitleIndex(filePath, line, cvsTitleList);
}
else
{
if (array.Length == titleIndex.Count)
{
if (AllPositionMap.ContainsKey(tName))
if (csvIndex < 0)
{
//更新缓存
AllPositionMap[tName].Remove(position.PositionNum);
AllPositionMap[tName].Add(position.PositionNum, position);
string newValue = PostionToString(position, titleIndex, proTitleMap);
lines[index] = newValue;
return WriteCSVFile(filePath, lines);
csvIndex = titleIndex[cvsTitleList[positionNumIndex]];
}
string value = array[csvIndex];
if (value.Equals(position.PositionNum))
{
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);
}
}
}
}
index++;
}
index++;
}catch(Exception ex)
{
LogUtil.error("SavePostion [" + filePath + "] 失败");
return false;
}
return true;
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!