DllExport  bool __cdecl RunTask(IAgent* agent,
			DWORD hxGridSessionId,
			IGenericStream* inStream,
			IGenericStream* outStream)
		{

			bool bRep = true;

			bUseHxGrid = true;
			__int32 sessionId = 0;
			inStream->Read(&sessionId, sizeof(sessionId));
			__int8 bDirectAccess = false;
			inStream->Read(&bDirectAccess, sizeof(bDirectAccess));

			istringstream iStream(string((char*)inStream->GetCurPointer(), inStream->GetLength()));
			ostringstream oStream;

			//RunModel(iStream, oStream);
			RunModel(agent, hxGridSessionId, iStream, oStream);

			const string& str = oStream.str();
			outStream->Write(&sessionId, sizeof(sessionId));
			outStream->Write(str.c_str(), (DWORD)str.length());

			if (agent && agent->TestConnection(hxGridSessionId) != S_OK)
				bRep = false;

			return bRep;
		}
Beispiel #2
0
double TSirSR2Model::RunCalcErr(const TFltV& ParamV) {
  SetParam(ParamV);
  const int EndT = BlogV.Len() - T0 + 2;
  RunModel(TFltV::GetV(N0M-I0M, N0B-I0B, I0M, I0B), 0, EndT, EndT, OutValV);
  //RunModel10(TFltV::GetV(N0M-I0M, N0B-I0B, I0M, I0B), 0, EndT, EndT, OutValV);
  return GetErr();
}
Beispiel #3
0
double TSirModel::RunCalcErr(const TFltV& ParamV) {
  SetParam(ParamV);
  const int EndT = TrueInfectV.Len() - T0 + 2;
  RunModel(TFltV::GetV(N0-I0, I0), 0, EndT, EndT, OutValV);
  //RunModel10(TFltV::GetV(N0-I0, I0), 0, EndT, EndT, OutValV);
  return GetErr();
}
Beispiel #4
0
//Called with 4 parameters.
// inModel   ,string containing the crc model name: 'CRC-8'
// inHexStr  ,string containing the hex representation of the data that will be used for CRC calculations.
// reverse   ,int 0/1  (bool) if 1, calculate the reverse CRC
// endian    ,char,  'B','b','L','l','t','r' describing if Big-Endian or Little-Endian should be used in different combinations.
//
// outputs:  string with hex representation of the CRC result
static int l_reveng_RunModel(lua_State *L) {
    //-c || -v
    //inModel = valid model name string - CRC-8
    //inHexStr = input hex string to calculate crc on
    //reverse = reverse calc option if true
    //endian = {0 = calc default endian input and output, b = big endian input and output, B = big endian output, r = right justified
    //          l = little endian input and output, L = little endian output only, t = left justified}
    //result = calculated crc hex string
    char result[50];

    const char *inModel = luaL_checkstring(L, 1);
    const char *inHexStr = luaL_checkstring(L, 2);
    bool reverse =  lua_toboolean(L, 3);
    const char endian = luaL_checkstring(L, 4)[0];

    //PrintAndLog("mod: %s, hex: %s, rev %d", inModel, inHexStr, reverse);
    //    int RunModel(char *inModel, char *inHexStr, bool reverse, char endian, char *result)
    int ans = RunModel( (char *)inModel, (char *)inHexStr, reverse, endian, result);
    if (!ans)
        return returnToLuaWithError(L,"Reveng failed");

    lua_pushstring(L, (const char*)result);
    return 1;
}
		DllExport bool RunModelStream(istream& inStream, ostream& outStream)
		{
			return RunModel(NULL, 0, inStream, outStream);
		}