⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csdproximity.js

📁  PSoC(可编程片上系统)是Cypress半导体公司生产的包含有8位微处理器核和数字与模拟混合的信号阵列芯片
💻 JS
字号:
//////////////////////////////////////////////////////////////////////////
//  FILENAME:    CSDPROXIMITY.js
//
//  @Version@
//
//  DESCRIPTION: Generates CSDPROXIMITY Metadata
//   
//------------------------------------------------------------------------
//  Copyright (c) Cypress MicroSystems 2007. All Rights Reserved.
//////////////////////////////////////////////////////////////////////////

//********************
// Globals
//********************
var g_UM_debug = false; // controls printing output in the script host
var g_UM_BankSwitch_xmlDoc;
var g_UM_BankSwitch_xmlLogicOut;

var g_UM_BankSwitch_BaseIODriver;
var g_UM_BankSwitch_DriverList;
var g_UM_BankSwitch_BasePropertyList;
var g_UM_BankSwitch_NumberOfSwitches;
var g_UM_BankSwitch_SubNameList;
var g_UM_BankSwitch_VariableList;
var g_UM_BankSwitch_ContainerInstanceName;
var g_UM_BankSwitch_PackedInputValName = "Status";
var g_UM_BankSwitch_PackedInputValName2 = "Baseline";
var g_UM_BankSwitch_PackedInputValName3 = "RawCount";
var g_UM_BankSwitch_PackedInputValName4 = "Difference";
var g_CMXTuningEnabled = null;

var g_TFListSave	= null;
var g_ValueListSaveTrigger = null;
var g_ValueListSaveStatus = null;

/*************
function setPSoC()
{
	g_UM_BankSwitch_xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	g_UM_BankSwitch_xmlDoc.async = false
	g_UM_BankSwitch_xmlDoc.load("c:\\wtest\\local\\sphinx\\work\\BankSwitchInput.xml")
	//print("Hello from BankSwitch.js");
}
***********/

/***************
function onAccept() 
{
	transformBankSwitch();
	g_UM_BankSwitch_xmlDoc.save("c:\\wtest\\local\\sphinx\\work\\BankSwitchOutput.xml");	
}
***************/


function transformContainer(sInstanceName, sDOM) 
{
	g_UM_BankSwitch_xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	g_UM_BankSwitch_xmlDoc.async = false
	g_UM_BankSwitch_xmlDoc.loadXML(sDOM);
	
	try
	{
		saveTF();
		saveValueList();
		clearOldData();
		setContainerInstanceName(sInstanceName);
		getNumberofSwitches();
		createSubNameList();
		createVariableList();
		createDriverList();

	}
	catch(kuku)
	{
		alert("Exception in transformContainer " +  kuku);
	}
	g_pDlg.LogToFile(g_UM_BankSwitch_xmlDoc.xml, "C:\\hello.xml");
	return g_UM_BankSwitch_xmlDoc.xml;
}


function saveTF()
{
	g_TFListSave = g_UM_BankSwitch_xmlDoc.selectSingleNode("//CMX_IO_DRIVER/CMX_VARIABLE_CONTAINER/CMX_VARIABLE_LIST/CMX_VARIABLE/CMX_TRANSFERFUNCTION_LIST");
}

function saveValueList()
{
//g_ValueListSaveStatus = g_UM_BankSwitch_xmlDoc.selectSingleNode("//CMX_IO_DRIVER/CMX_VARIABLE_CONTAINER/CMX_VARIABLE_LIST/CMX_VARIABLE/CMX_VALUE_LIST");
//	alert(g_ValueListSaveStatus.xml);
}

function clearOldData()
{

	// remove the old stuff and replace with empty elements
	try
	{
		var parent;
		var replacementNode = g_UM_BankSwitch_xmlDoc.createElement("CMX_SUB_NAME_LIST");
		var nodeToRemove = g_UM_BankSwitch_xmlDoc.selectSingleNode("//CMX_IO_DRIVER/CMX_VARIABLE_CONTAINER/CMX_SUB_NAME_LIST");
		if (nodeToRemove != null) 
		{
			parent = nodeToRemove.parentNode;
			parent.removeChild(nodeToRemove);
			parent.appendChild(replacementNode);
		} 

		replacementNode = g_UM_BankSwitch_xmlDoc.createElement("CMX_VARIABLE_LIST");
		nodeToRemove = g_UM_BankSwitch_xmlDoc.selectSingleNode("//CMX_IO_DRIVER/CMX_VARIABLE_CONTAINER/CMX_VARIABLE_LIST");
		if (nodeToRemove != null) 
		{
			parent = nodeToRemove.parentNode;
			parent.removeChild(nodeToRemove);
			parent.appendChild(replacementNode);
		}

		replacementNode = g_UM_BankSwitch_xmlDoc.createElement("CMX_IO_DRIVER_LIST");
		nodeToRemove = g_UM_BankSwitch_xmlDoc.selectSingleNode("//CMX_IO_DRIVER/CMX_VARIABLE_CONTAINER/CMX_IO_DRIVER_LIST");
		if (nodeToRemove != null) 
		{
			parent = nodeToRemove.parentNode;
			parent.removeChild(nodeToRemove);
			parent.appendChild(replacementNode);
		}
	}
	catch(kuku)
	{
		alert("Exception clearOldData " + kuku);
	}
	//end remove the old stuff
}

function getNumberofSwitches()
{
    g_UM_BankSwitch_BaseIODriver = g_UM_BankSwitch_xmlDoc.selectSingleNode("//CMX_IO_DRIVER");
    if (g_UM_BankSwitch_BaseIODriver != null)
    {
		g_UM_BankSwitch_BasePropertyList = g_UM_BankSwitch_BaseIODriver.selectSingleNode("CMX_PROPERTY_LIST");
		if (g_UM_BankSwitch_BasePropertyList != null)
    	{
			var NumberOfSwitchesProperty = g_UM_BankSwitch_BasePropertyList.selectSingleNode("CMX_PROPERTY[@NAME=\"Number of pins\"]");
			if (NumberOfSwitchesProperty != null)
    		{
				//print("XPATH is da bomb");
				g_UM_BankSwitch_NumberOfSwitches = parseInt(NumberOfSwitchesProperty.getAttribute("CURRENT_VALUE"));
			}
		}
	}
	else
	{
		//print("Error, BaseIODriver is null\n");
	}
	g_UM_BankSwitch_NumberOfSwitches = 1;
	
	g_CMXTuningEnabled = getContainerTuningEnabled();
}

function setContainerInstanceName(sInstanceName)
{
	var Container = g_UM_BankSwitch_xmlDoc.selectSingleNode("//CMX_IO_DRIVER/CMX_VARIABLE_CONTAINER");
	
	if (Container != null) 
	{
		g_UM_BankSwitch_ContainerInstanceName  = sInstanceName;

		Container.setAttribute("INSTANCE_NAME", sInstanceName);
	} 	
}

//Data looks like:
//<CMX_SUB_NAME NAME="bit0" TYPE="DRIVER" ORDINAL="0"/>
//<CMX_SUB_NAME NAME="packed_val" TYPE="VARIABLE" ORDINAL="1"/>
function createSubNameList()
{
	g_UM_BankSwitch_SubNameList = g_UM_BankSwitch_xmlDoc.selectSingleNode("//CMX_IO_DRIVER/CMX_VARIABLE_CONTAINER/CMX_SUB_NAME_LIST");
	if (g_UM_BankSwitch_SubNameList != null)
    {
		var CMXSubName;
		var OrdinalCount;
		// create the bitN variable sub names
		for (OrdinalCount = 0; OrdinalCount < g_UM_BankSwitch_NumberOfSwitches; OrdinalCount++)
		{
			CMXSubName = g_UM_BankSwitch_xmlDoc.createElement("CMX_SUB_NAME"); // create a sub name
			CMXSubName.setAttribute("NAME", "csdproximity"+OrdinalCount);
			CMXSubName.setAttribute("TYPE", "DRIVER");
			CMXSubName.setAttribute("ORDINAL", OrdinalCount);
			g_UM_BankSwitch_SubNameList.appendChild(CMXSubName);
		}

		// create the packed_input_val variable sub name
		CMXSubName = g_UM_BankSwitch_xmlDoc.createElement("CMX_SUB_NAME"); // create a sub name
		CMXSubName.setAttribute("NAME", g_UM_BankSwitch_PackedInputValName);
		CMXSubName.setAttribute("TYPE", "VARIABLE");
		CMXSubName.setAttribute("IO_TYPE", "INPUT");
		CMXSubName.setAttribute("ORDINAL", OrdinalCount++);
		g_UM_BankSwitch_SubNameList.appendChild(CMXSubName);

		if(g_CMXTuningEnabled == "Yes")
		{
			// create the packed_input_val2 variable sub name
			CMXSubName = g_UM_BankSwitch_xmlDoc.createElement("CMX_SUB_NAME"); // create a sub name
			CMXSubName.setAttribute("NAME", g_UM_BankSwitch_PackedInputValName2);
			CMXSubName.setAttribute("TYPE", "VARIABLE");
//		CMXSubName.setAttribute("IO_TYPE", "INPUT");
			CMXSubName.setAttribute("ORDINAL", OrdinalCount++);
			g_UM_BankSwitch_SubNameList.appendChild(CMXSubName);

			// create the packed_input_val3 variable sub name
			CMXSubName = g_UM_BankSwitch_xmlDoc.createElement("CMX_SUB_NAME"); // create a sub name
			CMXSubName.setAttribute("NAME", g_UM_BankSwitch_PackedInputValName3);
			CMXSubName.setAttribute("TYPE", "VARIABLE");
//		CMXSubName.setAttribute("IO_TYPE", "INPUT");
			CMXSubName.setAttribute("ORDINAL", OrdinalCount++);
			g_UM_BankSwitch_SubNameList.appendChild(CMXSubName);

			// create the packed_input_val4 variable sub name
			CMXSubName = g_UM_BankSwitch_xmlDoc.createElement("CMX_SUB_NAME"); // create a sub name
			CMXSubName.setAttribute("NAME", g_UM_BankSwitch_PackedInputValName4);
			CMXSubName.setAttribute("TYPE", "VARIABLE");
//		CMXSubName.setAttribute("IO_TYPE", "INPUT");
			CMXSubName.setAttribute("ORDINAL", OrdinalCount++);
			g_UM_BankSwitch_SubNameList.appendChild(CMXSubName);
		}
	}
}

//Data looks like:
//<CMX_VARIABLE NAME="MySwitchBank_packed_val" WRITEABLE="FALSE" VALUE_TYPE="CMX_DISCRETE" DEFAULT_VALUE="" ORDINAL="0" CONTAINER_NAME="MySwitchBank">
//</CMX_VARIABLE>
function createVariableList()
{
	g_UM_BankSwitch_VariableList = g_UM_BankSwitch_xmlDoc.selectSingleNode("//CMX_IO_DRIVER/CMX_VARIABLE_CONTAINER/CMX_VARIABLE_LIST");
	
	if (g_UM_BankSwitch_VariableList != null)
    {
		var CMXVariable;

		// create the packed_input_val variable
		CMXVariable = g_UM_BankSwitch_xmlDoc.createElement("CMX_VARIABLE"); // create a variable
		CMXVariable.setAttribute("NAME", g_UM_BankSwitch_ContainerInstanceName + "_" + g_UM_BankSwitch_PackedInputValName);
		CMXVariable.setAttribute("WRITEABLE", "FALSE");
		CMXVariable.setAttribute("VALUE_TYPE", "CONTINUOUS");
//		CMXVariable.setAttribute("DRIVER_TYPE", "INPUT");
		CMXVariable.setAttribute("DEFAULT_VALUE", "0");
		CMXVariable.setAttribute("ORDINAL", "1");
		CMXVariable.setAttribute("CONTAINER_NAME", g_UM_BankSwitch_ContainerInstanceName);
		CMXVariable.setAttribute("VARIABLE_TYPE", "int");
		CMXVariable.setAttribute("VARIABLE_SIZE", "2");
		CMXVariable.setAttribute("WIDGMIN", "0");
		CMXVariable.setAttribute("WIDGMAX", "32000");
		CMXVariable.setAttribute("WIDGSCALE", "1");

		g_UM_BankSwitch_VariableList.appendChild(CMXVariable);

		if(g_CMXTuningEnabled == "Yes")
		{
			// create the packed_input2_val variable
			CMXVariable = g_UM_BankSwitch_xmlDoc.createElement("CMX_VARIABLE"); // create a variable
			CMXVariable.setAttribute("NAME", g_UM_BankSwitch_ContainerInstanceName + "_" + g_UM_BankSwitch_PackedInputValName2);
			CMXVariable.setAttribute("WRITEABLE", "FALSE");
			CMXVariable.setAttribute("VALUE_TYPE", "CONTINUOUS");
//		CMXVariable.setAttribute("DRIVER_TYPE", "INPUT");
			CMXVariable.setAttribute("DEFAULT_VALUE", "0");
			CMXVariable.setAttribute("ORDINAL", "2");
			CMXVariable.setAttribute("CONTAINER_NAME", g_UM_BankSwitch_ContainerInstanceName);
			CMXVariable.setAttribute("VARIABLE_TYPE", "int");
			CMXVariable.setAttribute("VARIABLE_SIZE", "2");
			CMXVariable.setAttribute("WIDGMIN", "0");
			CMXVariable.setAttribute("WIDGMAX", "32000");
			CMXVariable.setAttribute("WIDGSCALE", "1");
			CMXVariable.setAttribute("TFEXPOSED", "FALSE");

			g_UM_BankSwitch_VariableList.appendChild(CMXVariable);

			// create the packed_input3_val variable
			CMXVariable = g_UM_BankSwitch_xmlDoc.createElement("CMX_VARIABLE"); // create a variable
			CMXVariable.setAttribute("NAME", g_UM_BankSwitch_ContainerInstanceName + "_" + g_UM_BankSwitch_PackedInputValName3);
			CMXVariable.setAttribute("WRITEABLE", "FALSE");
			CMXVariable.setAttribute("VALUE_TYPE", "CONTINUOUS");
//		CMXVariable.setAttribute("DRIVER_TYPE", "INPUT");
			CMXVariable.setAttribute("DEFAULT_VALUE", "0");
			CMXVariable.setAttribute("ORDINAL", "3");
			CMXVariable.setAttribute("CONTAINER_NAME", g_UM_BankSwitch_ContainerInstanceName);
			CMXVariable.setAttribute("VARIABLE_TYPE", "int");
			CMXVariable.setAttribute("VARIABLE_SIZE", "2");
			CMXVariable.setAttribute("WIDGMIN", "0");
			CMXVariable.setAttribute("WIDGMAX", "32000");
			CMXVariable.setAttribute("WIDGSCALE", "1");
			CMXVariable.setAttribute("TFEXPOSED", "FALSE");

			g_UM_BankSwitch_VariableList.appendChild(CMXVariable);

			// create the packed_input4_val variable
			CMXVariable = g_UM_BankSwitch_xmlDoc.createElement("CMX_VARIABLE"); // create a variable
			CMXVariable.setAttribute("NAME", g_UM_BankSwitch_ContainerInstanceName + "_" + g_UM_BankSwitch_PackedInputValName4);
			CMXVariable.setAttribute("WRITEABLE", "FALSE");
			CMXVariable.setAttribute("VALUE_TYPE", "CONTINUOUS");
//		CMXVariable.setAttribute("DRIVER_TYPE", "INPUT");
			CMXVariable.setAttribute("DEFAULT_VALUE", "0");
			CMXVariable.setAttribute("ORDINAL", "4");
			CMXVariable.setAttribute("CONTAINER_NAME", g_UM_BankSwitch_ContainerInstanceName);
			CMXVariable.setAttribute("VARIABLE_TYPE", "int");
			CMXVariable.setAttribute("VARIABLE_SIZE", "2");
			CMXVariable.setAttribute("WIDGMIN", "0");
			CMXVariable.setAttribute("WIDGMAX", "32000");
			CMXVariable.setAttribute("WIDGSCALE", "1");
			CMXVariable.setAttribute("TFEXPOSED", "FALSE");

			g_UM_BankSwitch_VariableList.appendChild(CMXVariable);
		}
	}
}

function createDriverList()
{
	g_UM_BankSwitch_DriverList = g_UM_BankSwitch_xmlDoc.selectSingleNode("//CMX_IO_DRIVER/CMX_VARIABLE_CONTAINER/CMX_IO_DRIVER_LIST");
	if (g_UM_BankSwitch_DriverList != null)
    {
		//print("found driver list");
		for (var i = 0; i < g_UM_BankSwitch_NumberOfSwitches; i++)
		{
			var LogicOutDriverElement = getLogicOutDriverElement();
			if (LogicOutDriverElement != null)
			{
				// Set instance name
				LogicOutDriverElement.setAttribute("DRIVER_INSTANCE", g_UM_BankSwitch_ContainerInstanceName+"_CSD");
				// Set the same sub_tree_selection as the Base IO Driver
				LogicOutDriverElement.setAttribute("SUB_TREE_SELECTION", g_UM_BankSwitch_BaseIODriver.getAttribute("SUB_TREE_SELECTION"));
				// Append to the IO Driver List
				g_UM_BankSwitch_DriverList.appendChild(LogicOutDriverElement);		
			}
		}
	}
}

function getContainerTuningEnabled()
{
    g_UM_BankSwitch_BaseIODriver = g_UM_BankSwitch_xmlDoc.selectSingleNode("//CMX_IO_DRIVER");
    if (g_UM_BankSwitch_BaseIODriver != null)
    {
		g_UM_BankSwitch_BasePropertyList = g_UM_BankSwitch_BaseIODriver.selectSingleNode("CMX_PROPERTY_LIST");
		if (g_UM_BankSwitch_BasePropertyList != null)
    	{
			var BaseDriveModeProperty = g_UM_BankSwitch_BasePropertyList.selectSingleNode("CMX_PROPERTY[@NAME=\"Expose Tuning Values\"]");
			if (BaseDriveModeProperty != null)
    		{
				return BaseDriveModeProperty.getAttribute("CURRENT_VALUE");
			}
		}
	}
	else
	{
		return "getContainerDriveMode Script Error";
	}
}


function getLogicOutDriverElement()
{
	var LogicOutDriver	= g_pDlg.GetData("GET_CATALOG_IO_DRIVER", "CSDBUTTBASE", "");
	
	var dm1				= new ActiveXObject("Microsoft.XMLDOM");
	dm1.async			= false;
	dm1.loadXML(LogicOutDriver);

	var nodeXML = dm1.selectSingleNode("//CMX_IO_DRIVER");

	return nodeXML;
}	
/***************************
//function print(Output)
//{
//	if (g_UM_debug == true)
//	{
//		WScript.echo(Output);
//	}
//}
****************************/



	







⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -