Publish to Web

Use this forum to post Vensim related questions.
Post Reply
IvanMJ
Junior Member
Posts: 7
Joined: Wed Oct 14, 2015 10:17 pm
Vensim version: DSS

Publish to Web

Post 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
Attachments
Change-Slider.png
Change-Slider.png (194.08 KiB) Viewed 11381 times
Reset-All-Sliders.png
Reset-All-Sliders.png (193.98 KiB) Viewed 11381 times
export.zip
(637 Bytes) Downloaded 733 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Publish to Web

Post 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).
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
IvanMJ
Junior Member
Posts: 7
Joined: Wed Oct 14, 2015 10:17 pm
Vensim version: DSS

Re: Publish to Web

Post by IvanMJ »

My DSS License details have now been supplied.

Kind regards, Ivan
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Publish to Web

Post by Administrator »

Thank you.

Before you published from Vensim, did the model have graphs displaying on the screen?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Publish to Web

Post 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
Attachments
2020-12-02_07-28-19.png
2020-12-02_07-28-19.png (28.08 KiB) Viewed 11360 times
IvanMJ
Junior Member
Posts: 7
Joined: Wed Oct 14, 2015 10:17 pm
Vensim version: DSS

Re: Publish to Web

Post by IvanMJ »

In reply to the Administrator's query, the charts of the Coronavirus model are fully dynamic within Vensim DSS.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Publish to Web

Post 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);
}

Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Publish to Web

Post by tomfid »

The 8.2 update should also work without any editing.
IvanMJ
Junior Member
Posts: 7
Joined: Wed Oct 14, 2015 10:17 pm
Vensim version: DSS

Re: Publish to Web

Post by IvanMJ »

The dynamic charts are now working on my website.

Thank you for your prompt response. Very much appreciated.
IvanMJ
Junior Member
Posts: 7
Joined: Wed Oct 14, 2015 10:17 pm
Vensim version: DSS

Re: Publish to Web

Post 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.
Attachments
Screenshot-web-8-2-original-publish-web.png
Screenshot-web-8-2-original-publish-web.png (119.12 KiB) Viewed 11272 times
Screenshot-web8-2-replace-file.png
Screenshot-web8-2-replace-file.png (206.67 KiB) Viewed 11272 times
IvanMJ
Junior Member
Posts: 7
Joined: Wed Oct 14, 2015 10:17 pm
Vensim version: DSS

Re: Publish to Web

Post 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
Attachments
Screenshot8-2-original-publish-replacement.png
Screenshot8-2-original-publish-replacement.png (198.3 KiB) Viewed 11269 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Publish to Web

Post by Administrator »

Can you paste the URL of the web model created using 8.2?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Publish to Web

Post 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/
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Publish to Web

Post by Administrator »

I'll reinstall the Emscripten SDK here and test. Something is not right either with the latest SDK or our wasm files.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Publish to Web

Post 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
Attachments
2020-12-15 Ventana WASM Folder.zip
(189.48 KiB) Downloaded 746 times
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
IvanMJ
Junior Member
Posts: 7
Joined: Wed Oct 14, 2015 10:17 pm
Vensim version: DSS

Re: Publish to Web

Post 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.
Attachments
Vensim8-2&change-to-wasm-folder.zip
(364.93 KiB) Downloaded 763 times
CreativeTech
Junior Member
Posts: 2
Joined: Thu Nov 04, 2021 7:14 pm
Vensim version: PLE

Re: Publish to Web

Post 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
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Publish to Web

Post by tomfid »

I think you're having a different problem.

Have you run the model yet? (Green triangle icon in the toolbar.)
CreativeTech
Junior Member
Posts: 2
Joined: Thu Nov 04, 2021 7:14 pm
Vensim version: PLE

Re: Publish to Web

Post 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?
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Publish to Web

Post by tomfid »

For Venapps and games, you'll probably need the Model Reader (also free).
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Publish to Web

Post 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/
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Post Reply