Hi Govert,
[ExcelFunction(Description = "Get the latest coordinate value for a point in the Chief Database",
Name = "ChiefLatestCoord", Category = "Chief", IsVolatile =true)]
public static object ChiefLatestCoord(
[ExcelArgument(Name = "Name", Description = "is the Chief Point Pathname or Alias (for example '/This/Point/Here' or 'ALIAS-1')")]
string name)
{
lock (Lock.syncRoot)
{
Cell me = new Cell((ExcelReference)XlCall.Excel(XlCall.xlfCaller));
string logit = "ChiefLatestCoord(" + name + ") " + me.ToString() + " ";
#if DEBUG
Log.Debug(logit + "started");
#endif
try
{
if (name == null || name.Length <= 0)
throw new Exception("Missing Alias or Pathname");
PointObservable po;
if(CH.FindAdd(logit, me, new[] { (Object)name }, out po) ) {
// new required
Point point = Point(name);
#if DEBUG
Log.Debug(logit + "watching for latest coord");
#endif
point.Watch(po.Observable);
}
Debug.Assert(po.Observable != null);
#if DEBUG
Log.Debug(logit + "finished " + po.Observable.ToString() + " ");
#endif
StaticThread.Instance.Wake();
return ExcelAsyncUtil.Observe("ChiefLatestCoord", XlCall.Excel(XlCall.xlfCaller),
new ExcelObservableSource(() => po.Observable));
}
catch (Exception ex)
{
Log.Error(logit + ex.ToString());
throw ex;
}
}
}
To post to this group, send email to exc...@googlegroups.com.