using System;
|
|
using System.IO;
|
|
using System.Windows.Forms;
|
|
using Forks.Utils.IO;
|
|
|
|
namespace BWPClientForTianRou {
|
|
public class ConfigUtil {
|
|
public static string ConfigFilePath = Application.StartupPath + "\\Config.txt";
|
|
public static string LivestockFilePath = Application.StartupPath + "\\Livestock.txt";
|
|
|
|
public static void Init() {
|
|
using (TextReader reader = FS.OpenReader(ConfigFilePath, true)) {
|
|
var nutFile = NutFile.Parse(reader);
|
|
|
|
LogFilePath = Application.StartupPath + "\\log\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
|
|
|
mStartTime = nutFile.AsInt32( StartTime, 12);
|
|
|
|
if (string.IsNullOrEmpty(nutFile.AsString( Seconds, "1"))) {
|
|
mSeconds = 1;
|
|
} else {
|
|
mSeconds = (short)nutFile.AsInt32( Seconds, 1);
|
|
}
|
|
|
|
mComName = nutFile.AsString( ComName, "COM1");
|
|
mBaundRate = nutFile.AsString( BaundRate, "9600");
|
|
mDataBits = nutFile.AsString( DataBits, "8");
|
|
mReadType = nutFile.AsString( ReadType, "0");
|
|
mCType = nutFile.AsString( CType, "");
|
|
mMinWeight = nutFile.AsDecimal( MinWeight, 25m);
|
|
mMaxWeight = nutFile.AsDecimal( MaxWeight, 300m);
|
|
|
|
}
|
|
}
|
|
public const string StartTime = "StartTime";
|
|
public const string Seconds = "Seconds";
|
|
public const string CType = "CType";
|
|
public const string ComName = "ComName";
|
|
public const string BaundRate = "BaundRate";
|
|
public const string DataBits = "DataBits";
|
|
public const string Assignment = "Assignment";
|
|
public const string MinWeight = "MinWeight";
|
|
public const string MaxWeight = "MaxWeight";
|
|
public const string ReadType = "ReadType";
|
|
public const string LastUser = "LastUser";
|
|
|
|
public static string LogFilePath;
|
|
|
|
public static short mSeconds;
|
|
public static short BaseCount;
|
|
|
|
public static string mComName;
|
|
public static string mBaundRate;
|
|
public static string mDataBits;
|
|
public static string mReadType;
|
|
public static string mAssignment;
|
|
public static decimal mMinWeight;
|
|
public static decimal mMaxWeight;
|
|
public static int mStartTime;
|
|
public static string mCType;
|
|
}
|
|
}
|