Commit 4bf74a6e by Pascal Bigot

--no commit message

parent f424f655
......@@ -19,7 +19,6 @@ namespace CommonLib
{
public delegate void NeedRefreshHMI(MessNeedUpdate Mess);
public delegate void DocumentModifiedEvent();
public delegate void RunStateChangeEvent(BTDoc doc);
public delegate void DocComStateChange(BTDoc doc);
public delegate void MessageTreat(BTDoc sender, MESSAGE Mess, object Param, TYPE_APP TypeApp);
/// <summary>
......@@ -68,7 +67,6 @@ namespace CommonLib
#region Events
public event NeedRefreshHMI UpdateDocumentFrame;
public event DocComStateChange OnCommStateChange;
public event RunStateChangeEvent OnRunStateChange;
public event MessageTreat BeforeMessageTreat;
public event MessageTreat EndMessageTreat;
#endregion
......@@ -96,8 +94,7 @@ namespace CommonLib
if (value != prevValue)
{
UpdateRunState();
if (OnRunStateChange != null)
OnRunStateChange(this);
NotifyRunStateChange();
}
}
}
......
......@@ -4,6 +4,8 @@ using System.Text;
namespace CommonLib
{
public delegate void RunStateChangeEvent(BaseDoc doc);
public class BaseDoc
{
protected string m_strfileFullName;
......@@ -15,6 +17,7 @@ namespace CommonLib
public event AddLogEventDelegate EventAddLogEvent;
public event DocumentModifiedEvent OnDocumentModified;
public event RunStateChangeEvent OnRunStateChange;
public BaseDoc(TYPE_APP typeApp)
{
......@@ -37,6 +40,12 @@ namespace CommonLib
get { return m_bModeRun; }
}
public void NotifyRunStateChange()
{
if (OnRunStateChange != null)
OnRunStateChange(this);
}
/// <summary>
/// ajout un message à la fenêtre de log de l'application
/// </summary>
......
......@@ -102,12 +102,14 @@ namespace CommonLib
/// <summary>
///
/// </summary>
public void FinalizeRead()
public bool FinalizeRead()
{
bool bRet = true;
foreach (DataBridgeInfo bridgeInfo in m_ListDataBridge)
{
bridgeInfo.FinalizeRead(m_solution);
bRet &= bridgeInfo.FinalizeRead(m_solution);
}
return bRet;
}
/// <summary>
......@@ -120,6 +122,10 @@ namespace CommonLib
{
foreach (DataBridgeInfo bridgeInfo in m_ListDataBridge)
{
if (Mess == MESSAGE.MESS_CMD_RUN)
{
bridgeInfo.TraiteMessage(sender, MESSAGE.MESS_PRE_PARSE, Param, TypeApp);
}
bridgeInfo.TraiteMessage(sender, Mess, Param, TypeApp);
}
switch (Mess)
......
......@@ -218,16 +218,9 @@ namespace CommonLib
//WaitForm.Parent = Program.CurrentMainForm;
WaitForm.Show();
Application.DoEvents();
if (m_Comm.OpenComm())
{
WaitForm.Close();
return true;
}
else
{
WaitForm.Close();
return false;
}
bool bRet = m_Comm.OpenComm();
WaitForm.Close();
return bRet;
}
/// <summary>
......
......@@ -248,19 +248,7 @@ namespace CommonLib
public override bool OpenComm()
{
m_TcpClient.Start();
if (m_TcpClient.IsOpen)
{
/*
string str = "Connection open";
DialogResult dlgRes = MessageBox.Show(str,
"", MessageBoxButtons.OK,
MessageBoxIcon.None,
MessageBoxDefaultButton.Button1);
* */
return true;
}
else
return false;
return m_TcpClient.IsOpen;
}
/// <summary>
......@@ -286,10 +274,7 @@ namespace CommonLib
/// <returns>true si elle est ouverte</returns>
public override bool IsOpen()
{
if (m_TcpClient.IsOpen)
return true;
else
return false;
return m_TcpClient.IsOpen;
}
#endregion
......@@ -358,6 +343,7 @@ namespace CommonLib
//private Thread th = null;
private Thread m_readThread = null;
private Socket ClientSocket = null;
IAsyncResult m_AsyncResult = null;
#endregion
......@@ -430,26 +416,17 @@ namespace CommonLib
#endregion
#region méthodes publiques
//*****************************************************************************************************
// Description:
// Return: /
//*****************************************************************************************************
/// <summary>
///
/// </summary>
public void Start()
{
// pour lancer l'ouverture de la connexion en tant que thread
/*
th = new Thread(new ThreadStart(StartClient));
th.Name = "StartClient " + m_UniqueID;
th.Priority = ThreadPriority.Normal;
th.Start();
*/
StartClient();
}
//*****************************************************************************************************
// Description:
// Return: /
//*****************************************************************************************************
/// <summary>
///
/// </summary>
public void Stop()
{
try
......@@ -473,10 +450,10 @@ namespace CommonLib
Thread.Sleep(100);
}
//*****************************************************************************************************
// Description:
// Return: /
//*****************************************************************************************************
/// <summary>
///
/// </summary>
/// <param name="datas"></param>
public void SendData(byte[] datas)
{
try
......@@ -491,21 +468,21 @@ namespace CommonLib
#endregion
#region LES METHODES LIEES AUX THREADS
//*****************************************************************************************************
// Description:
// Return: /
//*****************************************************************************************************
/// <summary>
///
/// </summary>
private void StartClient()
{
IPAddress ipa = IPAddress.Parse(m_Ip);
IPEndPoint ipEnd = new IPEndPoint(ipa, m_Port);
ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
this.ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try
{
ClientSocket.Connect(ipEnd);
if (ClientSocket.Connected == true)
m_AsyncResult = this.ClientSocket.BeginConnect(ipEnd, null, null);
bool success = m_AsyncResult.AsyncWaitHandle.WaitOne(5000, true);
if (success && this.ClientSocket.Connected == true)
{
m_AsyncResult = null;
m_bBouclage = true;
m_readThread = new Thread(new ThreadStart(ReceiveData));
m_readThread.Priority = ThreadPriority.BelowNormal;
......
......@@ -21,7 +21,7 @@ namespace CommonLib
#region donnée spécifiques aux fonctionement en mode Command
// objet Timer utilisé en mode Command
Timer m_Timer = new Timer();
System.Timers.Timer m_Timer = new System.Timers.Timer();
bool m_bTimerEnabled = false;
// executer de script du document
protected QuickExecuter m_Executer = null;
......@@ -178,7 +178,7 @@ namespace CommonLib
// initialisation de l'objet Timer
this.m_Executer = Doc.Executer;
m_Timer.Interval = this.m_iPeriod;
m_Timer.Tick += new EventHandler(OnTimerTick);
m_Timer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimerTick);
return true;
}
......@@ -247,7 +247,7 @@ namespace CommonLib
/// </summary>
/// <param name="sender">timer ayant levé l'évènement</param>
/// <param name="e">argument de l'event</param>
private void OnTimerTick(object sender, EventArgs e)
private void OnTimerTick(object sender, System.Timers.ElapsedEventArgs e)
{
if (m_bTimerEnabled)
{
......
......@@ -269,7 +269,6 @@ namespace CommonLib
{
foreach (string ScriptType in Scripts.ScriptKeys)
{
switch (Mess)
{
case MESSAGE.MESS_ASK_ITEM_DELETE:
......@@ -282,14 +281,18 @@ namespace CommonLib
|| ((MessAskDelete)obj).TypeOfItem == typeof(BTScreen)
)
{
MessAskDelete MessParam = (MessAskDelete)obj;
MessAskDelete MessParam = obj as MessAskDelete;
for (int i = 0; i < Scripts[ScriptType].Length; i++)
{
if (string.IsNullOrEmpty(Scripts[ScriptType][i]))
continue;
string stritem = "";
stritem = ScriptParser.GetLineToken(Scripts[ScriptType][i], ScriptParser.INDEX_TOKEN_SYMBOL);
if (stritem == MessParam.WantDeletetItemSymbol
|| (((MessAskDelete)obj).TypeOfItem == typeof(Data) && !string.IsNullOrEmpty(Scripts[ScriptType][i])
||
(MessParam.TypeOfItem == typeof(Data)
&& Scripts[ScriptType][i].Contains(MessParam.WantDeletetItemSymbol))
)
{
......
......@@ -47,7 +47,7 @@ namespace CommonLib
#region donnée spécifiques aux fonctionement en mode Command
// timer executant périodiquement les logs
Timer m_Timer = new Timer();
System.Timers.Timer m_Timer = new System.Timers.Timer();
// indique si le timer est actif
bool m_bTimerActive = false;
// chemin ou crée le fichier
......@@ -361,7 +361,7 @@ namespace CommonLib
}
m_UsedFileName = m_strFileName;
m_Timer.Interval = this.m_iPeriod;
m_Timer.Tick += new EventHandler(OnTimerTick);
m_Timer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimerTick);
m_strLogFilePath = Doc.LogFilePath;
return true;
}
......@@ -701,7 +701,7 @@ namespace CommonLib
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnTimerTick(object sender, EventArgs e)
private void OnTimerTick(object sender, System.Timers.ElapsedEventArgs e)
{
m_Timer.Stop();
LogData();
......
......@@ -4,6 +4,7 @@ using System.Collections.Specialized;
using System.Text;
using System.Xml;
using System.Windows.Forms;
using System.IO;
namespace CommonLib
{
......@@ -188,10 +189,14 @@ namespace CommonLib
public bool FinalizeRead(SolutionGest solGest)
{
// on récupère d'abord les documents
if (solGest.ContainsKey(m_SrcDoc))
m_SrcDocObj = solGest[m_SrcDoc] as BTDoc;
if (solGest.ContainsKey(m_DstDoc))
m_DstDocObj = solGest[m_DstDoc] as BTDoc;
foreach (string key in solGest.Keys)
{
string projName = Path.GetFileNameWithoutExtension(key);
if (projName == m_SrcDoc)
m_SrcDocObj = solGest[key] as BTDoc;
if (projName == m_DstDoc)
m_DstDocObj = solGest[key] as BTDoc;
}
if (m_DstDocObj == null || m_SrcDocObj == null)
return false;
......@@ -234,7 +239,7 @@ namespace CommonLib
}
if (!string.IsNullOrEmpty(m_sPostExecFunction))
{
BaseObject objFunction = m_SrcDocObj.GestFunction.GetFromSymbol(m_sPostExecFunction);
BaseObject objFunction = m_DstDocObj.GestFunction.GetFromSymbol(m_sPostExecFunction);
m_postExecFunction = objFunction as Function;
}
return true;
......@@ -268,11 +273,11 @@ namespace CommonLib
break;
case MESSAGE.MESS_PRE_PARSE:
// à ce stade le pré parse est normamement déjà fait dans les projet classiques
if (m_TriggerScriptObject.QuickScriptID != -1)
if (m_TriggerScriptObject != null && m_TriggerScriptObject.QuickScriptID != -1)
{
m_TriggerQuickId = m_TriggerScriptObject.QuickScriptID;
}
if (m_postExecFunction.QuickScriptID != -1)
if (m_postExecFunction != null && m_postExecFunction.QuickScriptID != -1)
{
m_PostExecQuickId = m_postExecFunction.QuickScriptID;
}
......@@ -313,7 +318,8 @@ namespace CommonLib
m_DstObjDataList[i].Value = m_SrcObjDataList[i].Value;
}
}
m_DstDocObj.Executer.ExecuteScript(m_PostExecQuickId);
if (m_PostExecQuickId != 0)
m_DstDocObj.Executer.ExecuteScript(m_PostExecQuickId);
}
#endregion
......
......@@ -205,6 +205,9 @@ namespace CommonLib
/// <return>Liste des chaines correspondantes au type de token</return>
public StringCollection GetAutoCompletStringListAtPos(string Line, int Pos, out bool IsParameter)
{
IsParameter = false;
if (Line.Trim(' ').StartsWith("//"))
return null;
TOKEN_TYPE CurTokenType = GetTokenTypeAtPos(Line, Pos, out IsParameter);
StringCollection AutoCompleteStrings = new StringCollection();
switch (CurTokenType)
......@@ -292,9 +295,9 @@ namespace CommonLib
for (int i = 0 ; i< Lines.Length; i++)
{
m_iCurLine = i;
if (!string.IsNullOrEmpty(Lines[i]) && Lines[i].Length > 0)
string Line = Lines[i].Trim(' ');
if (!string.IsNullOrEmpty(Line) && Line.Length > 0 && !Line.StartsWith("//"))
{
string Line = Lines[i];
string[] strTab = Line.Split(ParseExecGlobals.TOKEN_SEPARATOR);
if (strTab.Length > 0)
{
......
......@@ -55,11 +55,14 @@ namespace CommonLib
{
if (!string.IsNullOrEmpty(script[i]))
retPreParsedScript.Add(PreParseLine(script[i]));
string line = script[i].Trim(' ');
if (!string.IsNullOrEmpty(line) && !line.StartsWith("//"))
retPreParsedScript.Add(PreParseLine(line));
}
return retPreParsedScript.Count != 0 ? retPreParsedScript : null;
}
public PreParsedLine PreParseLine(string Line)
private PreParsedLine PreParseLine(string Line)
{
PreParsedLine retPreParsedLine = new PreParsedLine();
string[] strTab = Line.Split(ParseExecGlobals.TOKEN_SEPARATOR);
......@@ -502,9 +505,6 @@ namespace CommonLib
string strTempParam = Params[i].Trim();
if (!ScriptParser.IsNumericValue(strTempParam))
{
Data dt = m_Document.GestData.QuickGetFromSymbol(strTempParam) as Data;
if (dt == null)
Traces.LogAddCritical(TraceCat.Parser, string.Format("Error while searching for parameter data {0}, not found", strTempParam));
retDatas[i] = (Data)m_Document.GestData.QuickGetFromSymbol(strTempParam);
}
else
......
......@@ -603,43 +603,51 @@ namespace CommonLib
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnListViewFrameDataDragEnter(object sender, DragEventArgs e)
{
TreeNode DropedItem = (TreeNode)e.Data.GetData(typeof(TreeNode));
if (DropedItem != null)
TreeNode DropItem = e.Data.GetData(typeof(TreeNode)) as TreeNode;
Data DropItemDt = e.Data.GetData(typeof(Data)) as Data;
if ((DropItem != null && DropItem.Tag is Data) || DropItemDt != null)
{
if (DropedItem.Tag is Data)
Data dt = DropItem == null ? DropItemDt : DropItem.Tag as Data;
if (m_Trame != null && dt != null)
{
Data dt = DropedItem.Tag as Data;
if (m_Trame != null && dt != null)
bool bFind = false;
for (int i = 0; i < m_ListViewFrameData.Items.Count; i++)
{
bool bFind = false;
for (int i = 0; i < m_ListViewFrameData.Items.Count; i++)
if (m_ListViewFrameData.Items[i].Text == dt.Symbol)
{
if (m_ListViewFrameData.Items[i].Text == dt.Symbol)
{
bFind = true;
break;
}
bFind = true;
break;
}
}
if (bFind)
{
e.Effect = DragDropEffects.Move;
}
else
{
e.Effect = DragDropEffects.Copy;
}
if (bFind)
{
e.Effect = DragDropEffects.Move;
}
else
{
e.Effect = DragDropEffects.None;
e.Effect = DragDropEffects.Copy;
}
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnListViewFrameDataItemDrag(object sender, ItemDragEventArgs e)
{
try
......@@ -653,67 +661,71 @@ namespace CommonLib
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnListViewFrameDataDragDrop(object sender, DragEventArgs e)
{
TreeNode DropedItem = (TreeNode)e.Data.GetData(typeof(TreeNode));
if (DropedItem != null)
TreeNode DropItem = e.Data.GetData(typeof(TreeNode)) as TreeNode;
Data DropItemDt = e.Data.GetData(typeof(Data)) as Data;
if ((DropItem != null && DropItem.Tag is Data) || DropItemDt != null)
{
if (DropedItem.Tag is Data)
Data dt = DropItem == null ? DropItemDt : DropItem.Tag as Data;
bool bFind = false;
ListViewItem LvFoundItem = null;
for (int i = 0; i < m_ListViewFrameData.Items.Count; i++)
{
Data dt = DropedItem.Tag as Data;
bool bFind = false;
ListViewItem LvFoundItem = null;
for (int i = 0; i < m_ListViewFrameData.Items.Count; i++)
if (m_ListViewFrameData.Items[i].Text == dt.Symbol)
{
if (m_ListViewFrameData.Items[i].Text == dt.Symbol)
{
bFind = true;
LvFoundItem = m_ListViewFrameData.Items[i];
break;
}
bFind = true;
LvFoundItem = m_ListViewFrameData.Items[i];
break;
}
}
if (bFind)
{
Point prCurInListView = m_ListViewFrameData.PointToClient(new Point(e.X, e.Y));
ListViewItem lviAtCursor = m_ListViewFrameData.GetItemAt(prCurInListView.X, prCurInListView.Y);
if (lviAtCursor != LvFoundItem)
{
m_ListViewFrameData.Items.Remove(LvFoundItem);
if (lviAtCursor != null)
m_ListViewFrameData.Items.Insert(lviAtCursor.Index, LvFoundItem);
else
m_ListViewFrameData.Items.Add(LvFoundItem);
m_bCurFrameDataListChanged = true;
}
}
else
if (bFind)
{
Point prCurInListView = m_ListViewFrameData.PointToClient(new Point(e.X, e.Y));
ListViewItem lviAtCursor = m_ListViewFrameData.GetItemAt(prCurInListView.X, prCurInListView.Y);
if (lviAtCursor != LvFoundItem)
{
Point prCurInListView = m_ListViewFrameData.PointToClient(new Point(e.X, e.Y));
ListViewItem lviAtCursor = m_ListViewFrameData.GetItemAt(prCurInListView.X, prCurInListView.Y);
ListViewItem lviData = new ListViewItem(dt.Symbol);
lviData.Tag = DropedItem;
lviData.SubItems.Add(dt.SizeInBits.ToString());
lviData.SubItems.Add(dt.IsConstant.ToString());
lviData.SubItems.Add(dt.DefaultValue.ToString());
m_ListViewFrameData.Items.Remove(LvFoundItem);
if (lviAtCursor != null)
m_ListViewFrameData.Items.Insert(lviAtCursor.Index, lviData);
m_ListViewFrameData.Items.Insert(lviAtCursor.Index, LvFoundItem);
else
m_ListViewFrameData.Items.Add(lviData);
m_ListViewFrameData.Items.Add(LvFoundItem);
m_bCurFrameDataListChanged = true;
}
}
else
{
Point prCurInListView = m_ListViewFrameData.PointToClient(new Point(e.X, e.Y));
ListViewItem lviAtCursor = m_ListViewFrameData.GetItemAt(prCurInListView.X, prCurInListView.Y);
ListViewItem lviData = new ListViewItem(dt.Symbol);
lviData.Tag = dt;
lviData.SubItems.Add(dt.SizeInBits.ToString());
lviData.SubItems.Add(dt.IsConstant.ToString());
lviData.SubItems.Add(dt.DefaultValue.ToString());
if (lviAtCursor != null)
m_ListViewFrameData.Items.Insert(lviAtCursor.Index, lviData);
else
m_ListViewFrameData.Items.Add(lviData);
m_bCurFrameDataListChanged = true;
}
}
}
private void OnListViewFrameDataDragOver(object sender, DragEventArgs e)
{
Data DropItem = (Data)e.Data.GetData(typeof(Data));
if (DropItem != null)
TreeNode DropItem = e.Data.GetData(typeof(TreeNode)) as TreeNode;
Data DropItemDt = e.Data.GetData(typeof(Data)) as Data;
if ((DropItem != null && DropItem.Tag is Data) || DropItemDt != null)
{
Point prCurInListView = m_ListViewFrameData.PointToClient(new Point(e.X, e.Y));
ListViewItem lviAtCursor = m_ListViewFrameData.GetItemAt(prCurInListView.X, prCurInListView.Y);
......
......@@ -33,12 +33,14 @@ namespace CommonLib
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(47, 24);
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(73, 13);
this.label1.Size = new System.Drawing.Size(173, 73);
this.label1.TabIndex = 0;
this.label1.Text = "Please Wait...";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label1.UseWaitCursor = true;
//
// WaitOpenCommForm
......@@ -47,7 +49,7 @@ namespace CommonLib
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Control;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.ClientSize = new System.Drawing.Size(160, 59);
this.ClientSize = new System.Drawing.Size(173, 73);
this.ControlBox = false;
this.Controls.Add(this.label1);
this.DoubleBuffered = true;
......@@ -62,7 +64,6 @@ namespace CommonLib
this.TopMost = true;
this.UseWaitCursor = true;
this.ResumeLayout(false);
this.PerformLayout();
}
......
......@@ -11,6 +11,7 @@ namespace CommonLib
TextBox _output = null;
StringBuilder m_Builder = new StringBuilder(2000);
delegate void WriteText(string value);
public TextBoxStreamWriter(TextBox output)
{
_output = output;
......@@ -22,10 +23,24 @@ namespace CommonLib
m_Builder = m_Builder.Append(value);
if (value == '\n')
{
_output.AppendText(m_Builder.ToString()); // When character data is written, append it to the text box.
m_Builder = new StringBuilder(2000);
if (_output.InvokeRequired)
{
WriteText d = new WriteText(InvokedWriteString);
_output.Invoke(d, m_Builder.ToString());
m_Builder = new StringBuilder(2000);
}
else
{
_output.AppendText(m_Builder.ToString()); // When character data is written, append it to the text box.
m_Builder = new StringBuilder(2000);
}
}
}
private void InvokedWriteString(string value)
{
_output.AppendText(value); // When character data is written, append it to the text box.
}
public override Encoding Encoding
{
......
......@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{46A6DEB4-8699-49D5-B9F0-08F41AAFFCF1}</ProjectGuid>
<OutputType>Library</OutputType>
......
......@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5A8BD31D-5E4E-4891-9351-DD3119CB6BC9}</ProjectGuid>
<OutputType>WinExe</OutputType>
......@@ -162,11 +162,6 @@
<Compile Include="SmartCommand\Ihm\VariableForm.Designer.cs">
<DependentUpon>VariableForm.cs</DependentUpon>
</Compile>