/**
*
*	<B>Subscribe</B>
*
*	Description = subscribe item to opc server 
*	<p>
*	Specification = 
*	<p>
*	@param sItem  item path, e.g. [w-machinename].ResourceX.VariableN
*	<p>
*
*	@return
*	<p>
*
*/
STDMETHODIMP CSyncAccess::Subscribe(BSTR sItem)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState())

    TRACE(_T("Subscribe %s\n"), (LPCTSTR) CString(sItem));
    // separate config name from pure variable name
    CString strItem=sItem;
	return DoSubscribe(strItem);
}
/**
*
*	<B>SubscribeStringList</B>
*
*	Description = subscribe item list to opc server 
*	<p>
*	Specification = 
*	<p>
*	@param sItems  item paths (without common path) seperated by '|'
*	<p>
*	@param sCommonPath path that is common to all items, e.g. "[w-xx].Resource1.". sCommonPath may be empty 
*	<p>
*	@return
*	<p>
*
*/
STDMETHODIMP CAsyncAccess::SubscribeStringList(BSTR sItems, BSTR sCommonPath)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())

    //TRACE(_T("Subscribe List %s\n"), (LPCTSTR) CString(sItems));

    HRESULT hr = S_OK;
	CString strCommonPath=sCommonPath;
	CString strItems=sItems;
	CItemStringList itemList(strCommonPath,strItems);

	for (int ii=0; ii<itemList.GetSize(); ii++)
	{
		HRESULT hr2=DoSubscribe(itemList.GetAt(ii));
		if (hr2 != S_OK)
			hr = S_FALSE;
	}
	return hr;
}
Beispiel #3
0
Datei: main.c Projekt: VVer/opal
int main(int argc, char * argv[])
{
  Operations operation;

  
  if (argc < 2 || (operation = GetOperation(argv[1])) == NumOperations || argc < RequiredArgsForOperation[operation]) {
    Operations op;
    fputs("usage: c_api { ", stderr);
    for (op = OpListen; op < NumOperations; op++) {
      if (op > OpListen)
        fputs(" | ", stderr);
      fputs(OperationNames[op], stderr);
    }
    fputs(" } [ A-party [ B-party | file ] ]\n", stderr);
    return 1;
  }

  puts("Initialising.\n");

  if (!InitialiseOPAL())
    return 1;

  switch (operation) {
    case OpListen :
      puts("Listening.\n");
      HandleMessages(60000);
      break;

    case OpCall :
      if (argc > 3) {
        if (!DoCall(argv[2], argv[3]))
          break;
      } else {
        if (!DoCall(NULL, argv[2]))
          break;
      }
      HandleMessages(15000);
      break;

    case OpMute :
      if (!DoCall(NULL, argv[2]))
        break;
      HandleMessages(15000);
      if (!DoMute(1))
        break;
      HandleMessages(15000);
      if (!DoMute(0))
        break;
      HandleMessages(15000);
      break;

    case OpHold :
      if (!DoCall(NULL, argv[2]))
        break;
      HandleMessages(15000);
      if (!DoHold())
        break;
      HandleMessages(15000);
      break;

    case OpTransfer :
      if (!DoCall(NULL, argv[2]))
        break;
      HandleMessages(15000);
      if (!DoTransfer(argv[3]))
        break;
      HandleMessages(15000);
      break;

    case OpConsult :
      if (!DoCall(NULL, argv[2]))
        break;
      HandleMessages(15000);
      if (!DoHold())
        break;
      HandleMessages(15000);
      if (!DoCall(NULL, argv[3]))
        break;
      HandleMessages(15000);
      if (!DoTransfer(HeldCallToken))
        break;
      HandleMessages(15000);
      break;

    case OpRegister :
      if (!DoRegister(argv[2], argv[3]))
        break;
      HandleMessages(15000);
      break;

    case OpSubscribe :
      if (!DoSubscribe(argv[2], argv[3], argv[4]))
        break;
      HandleMessages(INT_MAX); // More or less forever
      break;

    case OpRecord :
      if (!DoRecord(argv[2], argv[3]))
        break;
      HandleMessages(INT_MAX); // More or less forever
      break;

    case OpPlay :
      if (!DoPlay(argv[2], argv[3]))
        break;
      HandleMessages(INT_MAX); // More or less forever
      break;

    default :
      break;
  }

  puts("Exiting.\n");

  ShutDownFunction(hOPAL);
  return 0;
}