Page 1 of 1

Publish to Web

Posted: Tue Dec 01, 2020 3:56 pm
by IvanMJ
I have downloaded the Coronavirus model example from the Vensim website and it runs OK on my Vensim 8.1 update.

I then published the model to the web and uploaded all files to my website. The model displays OK from my website, but the charts are blank (see attachment). I have also run the web version on my desktop with the same result.

Changing the sliders change values and Reset All Sliders changes values back to the original values (see attachments)

I have exported a CSV file (see attachment) which might help in diagnosis of why the charts are blank.

Please advise me how to get the dynamic charts working OK.

Many thanks, Ivan

Re: Publish to Web

Posted: Tue Dec 01, 2020 4:03 pm
by Administrator
Can you please update your licence details (or email us your serial number), your profile is as a PLE user (and this functionality is not in PLE).

Re: Publish to Web

Posted: Wed Dec 02, 2020 3:32 am
by IvanMJ
My DSS License details have now been supplied.

Kind regards, Ivan

Re: Publish to Web

Posted: Wed Dec 02, 2020 8:51 am
by Administrator
Thank you.

Before you published from Vensim, did the model have graphs displaying on the screen?

Re: Publish to Web

Posted: Wed Dec 02, 2020 2:29 pm
by tomfid
I think this is due to an emscripten version conflict - the emsdk api for memory allocation changed. I'll have to look up the correct pairing, but it should be a quick fix.

Image

Re: Publish to Web

Posted: Thu Dec 03, 2020 3:59 am
by IvanMJ
In reply to the Administrator's query, the charts of the Coronavirus model are fully dynamic within Vensim DSS.

Re: Publish to Web

Posted: Thu Dec 03, 2020 8:12 am
by Administrator
ok, it looks like you've got the latest emscripten SDK which has changed the arguments to the allocate function.

You can either vensim_wasm.js, it should be in c:\users\public\vensim\wasm and update the calls to allocate (instructions follow) or I've pasted in an updated vensim_wasm.js below (forum attachment settings prevent me from uploading the actual file).

Find the instances of "allocate", an example is
var ptr = allocate(intArrayFromString(strParameter), 'i8', ALLOC_NORMAL);

Delete the 'i8' part to give
var ptr = allocate(intArrayFromString(strParameter), ALLOC_NORMAL);

Here is the updated vensim_wasm.js, you can paste the contents of the window below into your file, save and try publishing again. It should also work if you just upload the updated vensim_wasm.js to https://www.insearchofsteadystate.org/web/

Code: Select all

var VensimLoadingFilesCount = 0;	//Count of files currently being loaded to the WASM file system


function SetConstant(strParameter, fValue)
{
	var ptr  = allocate(intArrayFromString(strParameter), ALLOC_NORMAL);
	return _SetConstant(-1, ptr, fValue);
}

function GetConstant(strParameter, fValue)
{
	var ptr  = allocate(intArrayFromString(strParameter), ALLOC_NORMAL);
	return _GetConstant(ptr);
}


function LoadFileToWASMFileSystem(strFileToLoad)
{
	VensimLoadingFilesCount++;
	
	var oReq = new XMLHttpRequest();
	oReq.open("GET", strFileToLoad, true);
	oReq.responseType = "arraybuffer";

	oReq.onload = function (oEvent)
	{
		var arrayBuffer = oReq.response;
		if (arrayBuffer)
		{
			var byteArray = new Uint8Array(arrayBuffer);
			var bFileCreated = FS.writeFile(strFileToLoad, byteArray);
			
			var ptr  = allocate(intArrayFromString(strFileToLoad), ALLOC_NORMAL);
			_LoadRun(ptr);
		}
		VensimLoadingFilesCount--;
	};

	oReq.send();
}




function LoadFileToWASMFileSystem(strFileToLoad)
{
	VensimLoadingFilesCount++;
	
	var oReq = new XMLHttpRequest();
	oReq.open("GET", strFileToLoad, true);
	oReq.responseType = "arraybuffer";

	oReq.onload = function (oEvent)
	{
		var arrayBuffer = oReq.response;
		if (arrayBuffer)
		{
			var byteArray = new Uint8Array(arrayBuffer);
			var bFileCreated = FS.writeFile(strFileToLoad, byteArray);
			
			var ptr  = allocate(intArrayFromString(strFileToLoad), ALLOC_NORMAL);
			_LoadRun(ptr);
		}
		VensimLoadingFilesCount--;
	};

	oReq.send();
}

function CloseRun(strRun)
{
	var ptr  = allocate(intArrayFromString(strRun), ALLOC_NORMAL);
	return _CloseRun(ptr);
}

function GetVariableIndex(strParameter)
{
	var ptr  = allocate(intArrayFromString(strParameter), ALLOC_NORMAL);
	return _GetVariableIndex(ptr);
}

/*
function LoadFileFromServer(filePath)
{
	var result = null;
	var xmlhttp = new XMLHttpRequest();
	
	xmlhttp.open("GET", filePath, false);
	xmlhttp.send();

	if (xmlhttp.status==200)
	{
		var responseType = xmlhttp.responseType;
		result = xmlhttp.responseText;
	}
	
	return result;
}
*/

function ExportCSV()
{
	_DumpResultsToDisk();
	DownloadFile("export.csv");
}

function DownloadFile(strFileName)
{
    var stream = FS.open(strFileName, 'r');
	
	if ( stream)
	{
		var fileStats = FS.stat(strFileName);
		var nSize = fileStats.size;
		var buf = new Uint8Array(nSize);
		FS.read(stream, buf, 0, nSize, 0);
		FS.close(stream);

		var bb = new Blob([buf], { type: 'text/plain' });
		var a = document.createElement('a');
		
		a.download = strFileName;
		a.href = window.URL.createObjectURL(bb);
		a.click();
		return;
	}
	
	alert('Error : Export not found.')
}

function AddCINFileFromServer(strFileToLoad)
{
	VensimLoadingFilesCount++;

	var oReq = new XMLHttpRequest();
	oReq.open("GET", strFileToLoad, true);
	oReq.responseType = "arraybuffer";
	
	oReq.onload = function (oEvent)
	{
		var arrayBuffer = oReq.response; // Note: not oReq.responseText
		VensimLoadingFilesCount--;
		if (arrayBuffer)
		{
			var byteArray = new Uint8Array(arrayBuffer);
			var bFileCreated = FS.writeFile(strFileToLoad, byteArray);

			//Run the model and update the graphs.
			var ptr  = allocate(intArrayFromString(strFileToLoad), ALLOC_NORMAL);
			InitializeModel();
			_AddCINFile(ptr);
			RunSim();
			UpdateCharts(1);
		}
	};
	oReq.send(null);
}

function SetConstantUsingIndex(nIndex, fValue)
{
	return _SetConstant(nIndex, "", fValue);
}

function GetNumVariables()
{
	return _GetNumVariables();
}

function GetVariableName(nIndex)
{
	var tempptr = _GetVariableName(nIndex);
	var strVarName = UTF8ToString(tempptr);
	return strVarName;
}

function GetVariableType(nIndex)
{
	return _GetVariableType(nIndex);
}

function InitializeModel()
{
	return _InitializeModel();
}

function GetNumberOfSubscriptElements(strParameter)
{
	var ptr  = allocate(intArrayFromString(strVarName), ALLOC_NORMAL);
	return _GetNumberOfSubscriptElements(ptr);
}

function RunSim()
{
	return _RunSim();
}

function GetSeriesNumVals(strVarName)
{
	var ptr  = allocate(intArrayFromString(strVarName), ALLOC_NORMAL);
	return _GetTimeSeriesNumVals(ptr);
}

function GetSeries(strVarName)
{
	var nNumVals = GetSeriesNumVals(strVarName);
	var ptr  = allocate(intArrayFromString(strVarName), ALLOC_NORMAL);
	var nNumValsReturned = nNumVals;
	var fResultsArray = ccallArrays("GetSeries", "array", ["intArray"], [ptr], {heapIn: "HEAPF64", heapOut: "HEAPF64", returnArraySize: nNumValsReturned});
	return fResultsArray;
}

function GetValueAtTime(strVarName, fTime)
{
	var ptr  = allocate(intArrayFromString(strVarName), ALLOC_NORMAL);
	return _GetValueAtTime(ptr, fTime);
}


Re: Publish to Web

Posted: Fri Dec 04, 2020 12:25 am
by tomfid
The 8.2 update should also work without any editing.

Re: Publish to Web

Posted: Fri Dec 04, 2020 4:13 am
by IvanMJ
The dynamic charts are now working on my website.

Thank you for your prompt response. Very much appreciated.

Re: Publish to Web

Posted: Fri Dec 11, 2020 4:50 pm
by IvanMJ
I have update to Vensim DSS 8.2 and repeated the above publish to the web with the same problem - no dynamic charts (see attached file). I have replaced the vensim_wasm.js file with the above file you supplied which works with Vensim DSS 8.1. The chart axes are displayed with axes titles, but no dynamic charts (see attached file). I am have now replaced Vensim DSS 8.2 with version 8.1.

Re: Publish to Web

Posted: Fri Dec 11, 2020 4:57 pm
by IvanMJ
Oops. I have a dual screen setup and I took a screenshot of the wrong screen. Here is the replacement screenshot of the the original publish to web using Vensim DSS 8.2

Re: Publish to Web

Posted: Mon Dec 14, 2020 8:12 am
by Administrator
Can you paste the URL of the web model created using 8.2?

Re: Publish to Web

Posted: Mon Dec 14, 2020 3:16 pm
by tomfid
The original has the allocate() problem, which suggests that either the 8.2 installer didn't provide the right comp/wasm file, or the box to update the compiled files wasn't checked (easy to do since it's the default and normally not needed).

The second dies via heap corruption without any javascript errors.
https://www.insearchofsteadystate.org/w ... lace-file/

Re: Publish to Web

Posted: Mon Dec 14, 2020 4:28 pm
by Administrator
I'll reinstall the Emscripten SDK here and test. Something is not right either with the latest SDK or our wasm files.

Re: Publish to Web

Posted: Tue Dec 15, 2020 8:45 am
by Administrator
I've installed the very latest Emscripten SDK and attached the set of compilation files I've just used successfully.

Please backup your existing files before using these.

If you have a standard installation, extract the zip file to to
C:\Users\Public\Vensim\COMP\wasm

Re: Publish to Web

Posted: Fri Dec 18, 2020 6:20 pm
by IvanMJ
I appreciate the work put in to resolve the above problem.

I have used the contents of the provided zip file to replace files in the Users wasm folder. I then reinstalled Vensim DSS 8.2 and published the same Corona file to the web and uploaded the resulting files to my website. The result was blank charts, no titles. I used the same zip files to overwrite the files in the Users wasm folder in case installing Vensim DSS 8.2 changed files in this folder. The files seemed to be the same. I then published to the web with the same result - blank charts , no titles. I have attached a zip file of the files I uploaded to my website.

I have deleted Vensim DSS 8.2 and reinstalled Vensim DSS 8.1. I then installed the previous Users wasm files and published the Corona file to the web, replaced the single wasm file provided earlier on, and then uploaded to my website. The result was fully functioning dynamic charts as expected.

I am happy to continue using Vensim DSS 8.1 and replacing the single wasm file. There is no urgency on my behalf for version 8.2 to provide the same results.

Re: Publish to Web

Posted: Thu Nov 11, 2021 1:56 am
by CreativeTech
Hi everyone!

I am having this same problem, when I downloaded the Coronavirus model example from the Vensim website the charts were blank. Is this because I am using Vensim PLE?

Thanks for your help!

-----------------------------------------------------------------

IvanMJ wrote: Tue Dec 01, 2020 3:56 pm I have downloaded the Coronavirus model example from the Vensim website and it runs OK on my Vensim 8.1 update.

I then published the model to the web and uploaded all files to my website. The model displays OK from my website, but the charts are blank (see attachment). I have also run the web version on my desktop with the same result.

Changing the sliders change values and Reset All Sliders changes values back to the original values (see attachments)

I have exported a CSV file (see attachment) which might help in diagnosis of why the charts are blank.

Please advise me how to get the dynamic charts working OK.

Many thanks, Ivan

Re: Publish to Web

Posted: Thu Nov 11, 2021 2:09 am
by tomfid
I think you're having a different problem.

Have you run the model yet? (Green triangle icon in the toolbar.)

Re: Publish to Web

Posted: Thu Nov 11, 2021 2:23 am
by CreativeTech
Thank you so much! That green triangle worked perfectly haha. I am just now learning how to use Vensim for the first time and am enjoying playing with this model. Do you have any advice for playing with Venapps and games (https://vensim.com/vensim-applications/ ... plications)? Is this something I can easily do in Vensim PLE?

Re: Publish to Web

Posted: Thu Nov 11, 2021 3:28 am
by tomfid
For Venapps and games, you'll probably need the Model Reader (also free).

Re: Publish to Web

Posted: Thu Nov 11, 2021 7:42 am
by Administrator
CreativeTech wrote: Thu Nov 11, 2021 2:23 am Thank you so much! That green triangle worked perfectly haha. I am just now learning how to use Vensim for the first time and am enjoying playing with this model. Do you have any advice for playing with Venapps and games (https://vensim.com/vensim-applications/ ... plications)? Is this something I can easily do in Vensim PLE?
PLE is really for learning only. More advanced things (such as games) need a different version,
https://vensim.com/comparison/